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>

Installation:

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:

device.open()
device.get_interfaces()

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:

device.close()
103 views0 comments

Recent Posts

See All

The Duo Authentication Proxy is an on-premises software service that receives authentication requests from your local devices and applications via RADIUS or LDAP, optionally performs primary authentic

This post provides a step-by-step procedure for installing the hot patch released by Cisco for ISE servers, in light of the recent Log4j vulnerability (Apache Log4j Java Logging Library). More details

We have already seen how Umbrella works in previous posts and now let's do the basic configuration. https://www.stenge.info/post/umbrella-va Configuration Mode on a VA Deployed: When you open the VA i