Octet

What does NAPALM give you that Netmiko does not? Explain getters and config replace vs merge.

Show the answer

Say this first

NAPALM is a vendor-neutral Python API over several platforms (core drivers for IOS, IOS XR, NX-OS, EOS and Junos). Getters such as get_facts, get_interfaces and get_bgp_neighbors return the same structured dictionaries on every platform. For config it loads a candidate, shows a diff with compare_config, then commit_config, discard_config or later rollback. Merge adds your lines to the running config; replace makes the running config exactly equal to the file you load.

Go deeper

Getters

get_facts, get_interfaces, get_interfaces_ip, get_arp_table, get_mac_address_table, get_lldp_neighbors, get_bgp_neighbors, get_environment, get_config, get_route_to and more. Not every driver implements every getter; unsupported ones raise NotImplementedError.

Config workflow

Python
from napalm import get_network_driver

driver = get_network_driver("eos")
with driver("10.0.0.21", "netops", "secret") as dev:
    print(dev.get_facts()["os_version"])
    dev.load_merge_candidate(config="ntp server 10.0.0.5\n")
    diff = dev.compare_config()
    if diff:
        print(diff)
        dev.commit_config()
    else:
        dev.discard_config()

Merge vs replace

load_merge_candidateload_replace_candidate
You supplyOnly the lines to add or changeThe full intended config
Lines on the device you did not mentionStayRemoved
Good forSmall additive changesFull config management, drift removal
RiskStale config builds upAn incomplete file deletes real config

How it works under the hood

Each driver uses the platform's best mechanism: Junos has a native candidate and commit, EOS uses configuration sessions, IOS XR has its own commit model. IOS has no candidate, so the driver copies the candidate file to flash with SCP and uses configure replace for a replace. That is why IOS needs ip scp server enable for NAPALM config operations.

Validation

compliance_report("validate.yml") compares getter results with expected values in a YAML file, for example "these BGP peers are up". It is a quick post-check.

Traps

  • Assuming every getter works on every driver. Check the support matrix for your platforms.
How did you do?