NAPALM: vendor-neutral getters, config merge, replace and compare
In short: NAPALM (Network Automation and Programmability Abstraction Layer with Multivendor support) offers the same Python methods across several platforms. Getters return structured data such as facts and interfaces. Configuration changes are loaded as a candidate, compared, then committed or discarded, with rollback available.
What NAPALM is for
Every vendor has its own commands for the same question, such as "what are this device’s interfaces?". NAPALM (Network Automation and Programmability Abstraction Layer with Multivendor support) hides those differences behind one Python API. You pick a driver for the platform, and the same method names work everywhere. Under the hood each driver uses the best transport it can: SSH for IOS, eAPI for Arista EOS, NETCONF for Junos.
Getters: structured data without parsing
Getters are read-only methods that return dictionaries in a documented, vendor-neutral format. Examples include get_facts(), get_interfaces(), get_interfaces_ip(), get_arp_table(), get_lldp_neighbors() and get_bgp_neighbors(). Not every driver supports every getter, so check the support matrix in the NAPALM documentation.
import os
from napalm import get_network_driver
driver = get_network_driver("ios")
with driver(hostname="192.168.10.1",
username=os.environ["NET_USER"],
password=os.environ["NET_PASS"]) as device:
facts = device.get_facts()
print(facts["hostname"], facts["os_version"], facts["serial_number"])
for name, intf in device.get_interfaces().items():
if intf["is_enabled"] and not intf["is_up"]:
print("Enabled but down:", name)
Because the output shape is the same for every vendor, one report script can audit a mixed network.
Merge, replace and compare
NAPALM changes configuration through a candidate. You load changes, inspect the difference, then commit or throw them away.
- Merge (
load_merge_candidate): adds your lines to the running configuration, like typing them in. Good for small, additive changes. - Replace (
load_replace_candidate): makes the device match your file exactly, removing anything not in it. Powerful for enforcing a full intended configuration, and dangerous if the file is incomplete.
import os
from napalm import get_network_driver
driver = get_network_driver("eos")
with driver("192.168.10.2", os.environ["NET_USER"], os.environ["NET_PASS"]) as device:
device.load_merge_candidate(filename="ntp_snippet.cfg")
diff = device.compare_config()
if not diff:
print("Nothing to change")
device.discard_config()
else:
print(diff)
if input("Commit? [y/N] ").lower() == "y":
device.commit_config()
else:
device.discard_config()
Tip: compare_config() with no commit is a safe, read-only way to detect drift: load the intended configuration as a replace candidate, print the difference, then discard.
Platform notes and good practice
| Platform | How candidates work |
|---|---|
| Junos, IOS-XR | Native candidate configuration and commit |
| Arista EOS | Configuration sessions |
| Cisco IOS | Emulated with files and the archive feature; needs SCP and archive configured |
| NX-OS | Emulated using checkpoint files |
- Test replace operations in a lab first; a missing management line in your file can cut off your own access.
- Keep intended configurations in Git so every change has history and review.
- Use
rollback()after a commit if verification fails, and know how it behaves on your platform. - Combine NAPALM with Nornir (the
nornir_napalmplugin) or Ansible to run across many devices.
Practice
What is the key difference between merge and replace?
How can NAPALM help detect configuration drift without changing anything?
Why is get_interfaces() useful in a mixed-vendor network?
Key takeaways
- NAPALM gives one Python API across several vendors via drivers.
- Getters return structured, vendor-neutral data.
- Changes use a candidate: load, compare, then commit or discard.
- Merge adds lines; replace enforces a full configuration.
- Test replace in a lab and keep intended configs in Git.
Original content written by Mohamed Fayas for FM TecHub. © 2026 FM TecHub. You're welcome to share a link to this page; please don't copy the text elsewhere without permission.