Skip to main content

Add your description here

Project description

sc-napalm

This repo is for building custom NAPALM "getters" to pull operational data from network devices, as well as override existing NAPALM getters with custom code if needed. At the moment only one custom getter is implemented: get_inventory. This getter pulls model and serial numbers of device components: fans, psus, and optics.

What's cool about NAPALM is that if you nest your custom drivers under custom_napalm as is done in this project, you can install your custom drivers in the same virtual environment as the main NAPALM package, and they will override NAPALM's core drivers. This allows us to leverage NAPALM in a pretty seamless way - by that I mean applications that leverage NAPALM (like Nautobot or Nornir) can be easily altered to use this code instead.

Note that this repo is very "minimum viable product" - testing was bare minimum "does it work on SC25 devices". Use it at your own risk!

Overview of the various platforms supported

Driver OS/Platform Type Inerited Driver
aoscx Aruba CX REST N/A
eos Arista EOS SSH Napalm core
iosxr Cisco IOS-XR SSH N/A
iosxr_netconf IOS-XR NETCONF Napalm core
junos Juniper JunOS NETCONF Napalm core
nos DriveNets NETCONF N/A
nxos Cisco Nexus SSH Napalm Core
srl Nokia SRLinux NETCONF Community Driver
sros Nokia SROS NETCONF Community Driver
waveserver Ciena Waveserver SSH N/A

Using sc-napalm

The package comes with a cli script called sc-napalm-get that will run a particular getter against a particular device and output the results to your terminal.

To use the script, you can install the package from pypi, ideally into a virtual environment:

python3 -m venv venv
source venv/bin/activate
pip install sc-napalm

Now that you've done this you can run sc-napalm-get from your venv. Note that you must either provide your credentials directly to the script, or set them as environment variables SC_USERNAME and SC_PASSWORD. Run it with --help to see all the various options.

(venv) aliebowitz@sysauto:~$ export SC_USERNAME=nso
(venv) aliebowitz@sysauto:~$ export SC_PASSWORD=<redacted>
(venv) aliebowitz@sysauto:~$ sc-napalm-get --help
usage: sc-napalm-get [-h] [--ssh-cfg SSH_CFG] [-l {DEBUG,INFO,WARNING,ERROR,CRITICAL} | -L {DEBUG,INFO,WARNING,ERROR,CRITICAL}] [--logfile LOGFILE] [--sc_username SC_USERNAME]
                     [--sc_password SC_PASSWORD]
                     device {iosxr,nxos,junos,sros,srl,eos,nos} {get_config,get_facts,get_optics,get_lldp_neighbors,get_inventory}

Run a specific sc_napalm "getter" against a device.

positional arguments:
  device                device hostname or IP address
  {iosxr,nxos,junos,sros,srl,eos,nos}
                        The platform of this device
  {get_config,get_facts,get_optics,get_lldp_neighbors,get_inventory}
                        The getter command to run against this device

options:
  -h, --help            show this help message and exit
  --ssh-cfg SSH_CFG     Use SSH config file to connect
  -l {DEBUG,INFO,WARNING,ERROR,CRITICAL}, --log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL}
                        Set log level for sc_napalm only
  -L {DEBUG,INFO,WARNING,ERROR,CRITICAL}, --LOG-LEVEL {DEBUG,INFO,WARNING,ERROR,CRITICAL}
                        set global log level
  --logfile LOGFILE     Save logging to a file (specified by name) instead of to stdout
  --sc_username SC_USERNAME
                        Specify credentials
  --sc_password SC_PASSWORD
                        Specify credentials
(venv) aliebowitz@sysauto:~$ sc-napalm-get 2001:468:1f07:ff19::1d eos get_inventory
[{'name': 'Ethernet45',
  'part_number': 'QSFP-100G-LR4',
  'serial_number': 'XYL252206819',
  'subtype': 'QSFP-100G-LR4',
  'type': 'optic'},
 {'name': 'Ethernet46',
  'part_number': 'QSFP-100G-LR4',
  'serial_number': 'XYL252206822',
  'subtype': 'QSFP-100G-LR4',
  'type': 'optic'},
 {'name': 'PSU 1',
  'part_number': 'PWR-511-AC-RED',
  'serial_number': 'EEWT2420216960',
  'subtype': None,
  'type': 'psu'},
  ...

Developing sc-napalm

Currently, the getters that are exposed as options in the get script are defined in the base class of the custom drivers. Note that because most of the custom classes inherit the NAPALM getters, we could easily define all the other NAPALM getters there, but I've only included ones I think are obviously useful to us.

My hope is that instead of just printing out results we can write code that saves data in Nautobot, or some other place. This could be done with Nornir or Nautobot jobs.

To-dos

  • More waveserver getters
  • Infinera SNMP driver
  • Mock classes and test data

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sc_napalm-2.7.2.tar.gz (164.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sc_napalm-2.7.2-py3-none-any.whl (45.9 kB view details)

Uploaded Python 3

File details

Details for the file sc_napalm-2.7.2.tar.gz.

File metadata

  • Download URL: sc_napalm-2.7.2.tar.gz
  • Upload date:
  • Size: 164.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.7

File hashes

Hashes for sc_napalm-2.7.2.tar.gz
Algorithm Hash digest
SHA256 a9ab0174bc09a356932f238e902ccf4378191bd6539ad8d747b38711ead07162
MD5 ce0a2efb8682ad3c8528ef0764225209
BLAKE2b-256 d534220392c01ab7119d1770b078e4932f9b2647a4e669531d577a904d8359d1

See more details on using hashes here.

File details

Details for the file sc_napalm-2.7.2-py3-none-any.whl.

File metadata

  • Download URL: sc_napalm-2.7.2-py3-none-any.whl
  • Upload date:
  • Size: 45.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.7

File hashes

Hashes for sc_napalm-2.7.2-py3-none-any.whl
Algorithm Hash digest
SHA256 47a55c82c883952e12e194ff488c2ccdd4b81446e2f6748cdb56a1a26db5b45d
MD5 71c6b1b4e029fc0bfcc24e208f5c73e1
BLAKE2b-256 5ba0c0801f10aaef28a33e89cca9fae7d9002a7d90190ac4a823a12cfaa970b1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page