Napalm | Network Automation

Napalm is a vendor neutral, cross-platform open source project that provides a unified API to network devices, is written in Python and already works with the most popular automation frameworks.

You don't have to use an existing automation framework to automate with Napalm. Since it's an open source library you could just integrate it with your own Python application.

NAPALM supports several methods to connect to the devices, to manipulate configurations or to retrieve data:

  • Arista EOS;

  • Cisco IOS;

  • Cisco IOS-XR;

  • Cisco NX-OS;

  • Juniper JunOS.

You can select the driver you need by doing the following:

>>> from napalm import get_network_driver
>>> get_network_driver('eos')
<class napalm.eos.eos.EOSDriver at 0x10ebad6d0>
>>> get_network_driver('iosxr')
<class napalm.iosxr.iosxr.IOSXRDriver at 0x10ec90050>
>>> get_network_driver('junos')
<class napalm.junos.junos.JunOSDriver at 0x10f8f61f0>
>>> get_network_driver('nxos')
<class napalm.nxos.nxos.NXOSDriver at 0x10f9304c8>
>>> get_network_driver('ios')
<class napalm.ios.ios.IOSDriver at 0x10f9b0738>


pip install napalm 

Open the python on your machine:

root@DRM:/home/STENGE# python3
Python 3.8.5 (default, Jul 28 2020, 12:59:40)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

Start by importing the NAPALM module into Python:

from napalm import get_network_driver

You can select the driver you need by doing the following:

driver = get_network_driver("ios")

Create the python code using the IOS-XE always on sandbox information:

device = driver ('ip-address', 'your-loggin', 'your-password')

Next, we open a connection the device and pass the 'get_interfaces' command:

The output will come all messed up - we can make the output more readable, by importing 'json' and printing this in 'json format':

import json
print(json.dumps(device.get_interfaces(), sort_keys=True, indent=4))

Finally, we close the connection. It is advised to issue use the 'close' to disconnect our session from the device:

125 views0 comments

Recent Posts

See All

The Cisco Integrated Management Interface (CIMC) permits monitoring of the server inventory, health, and system event logs using the built-in Cisco Integrated Management Controller (CIMC) GUI or CLI i

Cisco ISE Upgrade Readiness Tool (URT) helps detect and fix any data upgrade issues before you start the upgrade process. Most of the upgrade failures occur because of data upgrade/corruption issues.

When you try to back up the ISE configuration, the backup process fails even though there is enough disk space available. Follow some steps to fix this issue: ise/admin# show backup status %% Configur