Add your description here
Project description
sc-napalm
This repo is for building custom NAPALM "getters" to pull operational data from network devices.
At the moment only one custom getter is implemented: get_inventory, and it is only implemented for junos, iosxr, and nxos.
What's cool about NAPALM is that if you nest your custom drivers under custom_napalm as is done in this project, when you call get_network_driver
in a runtime environment that has your modules, these drivers will override the core NAPALM drivers. This allows us to leverage NAPALM in a pretty seamless way,
in particular it allows us to use the nornir-napalm connection plugins and tasks to point at our custom drivers.
Using sc-napalm
For now the repo comes with two scripts:
sc-napalm-getwill run a particular getter against a particular device and output the results to your terminal.sc-napalm-runuses Nornir to run a set of getters against a set of devices in Nautobot and print out the results.
Right now to use this code you must do the following things:
- Install uv
- Clone the repo onto your local machine, then do a local development install of the repo into a uv virtual environment.
git clone https://scinet.supercomputing.org:8443/automation/sc25/sc-napalm.git
cd sc-napalm
uv run pip install -e .
- Copy
sample_envfile into.envand fill out.envwith the credentials you need. Some notes about this.
- You only need the nautobot stuff for
sc-napalm-run. - You could also specify these values in your local environment as well, the scripts will check there if they're not set in
.env
- Run the two scripts with
uv run [the script].
amylieb@m-n76107kqmh sc-napalm % uv run sc-napalm-get -h
usage: sc-napalm-get [-h] [-l {DEBUG,INFO,WARNING,ERROR,CRITICAL} | -L {DEBUG,INFO,WARNING,ERROR,CRITICAL}] [--logfile LOGFILE] [--username USERNAME]
[--password PASSWORD]
device {iosxr,nxos,junos,sros,srl,eos} {get_config,get_facts,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}
The platform of this device
{get_config,get_facts,get_lldp_neighbors,get_inventory}
The getter command to run against this device
options:
-h, --help show this help message and exit
-l, --log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL}
Set log level for sc_napalm only
-L, --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
--username USERNAME Specify credentials
--password PASSWORD Specify credentials
amylieb@m-n76107kqmh sc-napalm % uv run sc-napalm-get dl-shallow-1 nxos get_inventory
[{'name': 'Slot 1',
'part_number': 'N9K-C93180YC-FX',
'serial_number': 'FLM252403M9',
'type': 'linecard'},
{'name': 'Fan 1',
'part_number': 'NXA-FAN-30CFM-B',
'serial_number': 'N/A',
'type': 'fan'},
.....
amylieb@m-n76107kqmh sc-napalm % uv run sc-napalm-run --device amytest --cmds get_facts
Uninstalled 1 package in 8ms
Installed 1 package in 3ms
napalm_get**********************************************************************
* amytest ** changed : False ***************************************************
vvvv napalm_get ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO
{ 'get_facts': { 'fqdn': '',
'hostname': 'dl-shallow-1',
'interface_list': [ 'Management0',
'Ethernet1/1',
'Ethernet1/2',
'Ethernet1/3',
'Ethernet1/4',
'Ethernet1/5',
Developing sc-napalm
Currently, the getters that are exposed as options in the get and run scripts are defined in the base class of the custom drivers.
Note that because all 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 custom Nornir tasks or with Processors.
I have also noticed that Nautobot has a Nornir plugin - we could potentially leverage that as well.
To-dos
- Decide where this code is run and how (periodically? Manually? From Nautobot? if so, how?)
- Decide what output we want to capture (eg "show version"? "show lldp neighbor"?) and where it should go
- Fuctions/tasks that transform output and save it appropriately
get_inventorymethods for eos, srlinux, sros- Test/mock classes for custom getters
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sc_napalm-0.1.1.tar.gz.
File metadata
- Download URL: sc_napalm-0.1.1.tar.gz
- Upload date:
- Size: 148.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9723372704a17fe6fdb964ea576186cf1acc5201240a1a9f5e431c2e5b9220d6
|
|
| MD5 |
1070e3eac15fcb1ae0dc746eabc1bf8b
|
|
| BLAKE2b-256 |
b4077377e555315b84c16a53a9f5bd6c46e8c5b117a90e30ed42bb2e5d52e672
|
File details
Details for the file sc_napalm-0.1.1-py3-none-any.whl.
File metadata
- Download URL: sc_napalm-0.1.1-py3-none-any.whl
- Upload date:
- Size: 22.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38f7ad04312e21d3184a2cc2271bab7cb04d416a0832f8902a85b3249a7197cf
|
|
| MD5 |
9818d7cab6f20326b912ffc4cfe10403
|
|
| BLAKE2b-256 |
d0adcc6d4b003a2697e8b49cbca1009f393d07942944d9e8a40277afe529e396
|