How are you using nornir?

I’d love to hear how you are using, or planning to use, nornir:

  • Use cases (config management, automate operations, extract information…)
  • Architecture (a simple script, via some other system like stackstorm, with a homemade frontend…)

Anything you want to share. If you have a blogpost or some other public resource you may want to share that’d be great too.

1 Like

Current things:

  1. Have an automated backup script written in Nornir to connect to lab + production devices and create a backup.

  2. Just created a way to reset our Arista virtual lab switches back to their default config (if they get disconnected by a student). For this, I used Netmiko on my nornir-admin machine and SSH into the KVM servers that are hosting the Arista VMs and then connect into the console of the VMs via telnet. A bit interesting here as we had to bounce through the intermediate machine and use Netmiko’s redispatch.

  3. Have a script to auto-upgrade the OS for some Cisco routers. Only used it as a proof-of-concept on a couple of routers though. This was using Nornir + Netmiko.

Future:

  1. We want to add onto item 2 above an integration into StackStorm such that if we get notified by our monitoring system that an Arista switch is down that we auto-remediate it. We have StackStorm up and running, but need to do more integration work.

  2. We have some misc Netmiko scripts that I want to integrate into Nornir+Netmiko (mostly for the integrated inventory and a more systematic way of managing this).

1 Like

I’m brand new to Nornir (as of this weekend).

I want to convert the script I wrote in Netmiko to Nornir to take advantage of the multi threading so I can upgrade OS on multiple ASAs at one time.

2 Likes
  1. We are mid-integration having been purchased by a larger carrier. I have an inventory of devices I’ll need to change management parameters on, also a large portion of them were previously managed by another individual and need…updates, to say the least.

I’m working out the templates in jinja that I’d like to push out with nornir when we are ready, mostly as a proof-of-concept to continue pushing to do things programmatically within our organization.

  1. Polling devices that are not SNMP capable for basic stats like bandwidth usage, etc.
2 Likes

Just getting my feet wet:

-I use Nornir to gather information from all Cisco devices in our network, daily. I am using argparse to pass the site and role to the script from CMD. This saves me from manually editing the script and having to save it before I can run it when I want to target a different group of devices. Works great!
-Recently created a script to backup devices configuration to a folder including timestamp in the file name
-I have used it to send configuration change commands, from a text file, to routers and to return output of show commands for change confirmation.

1 Like

I was able to write a code that gathers all the arp entries on our organization and put it on an excel file. Now, all i need to do whenever I need to check issues is to ctrl + f for the mac or ip :stuck_out_tongue_winking_eye:, gathering these info from nexus and arista.

1 Like

I am building a Click app that my team members can use to leverage the inventory and concurrency to run “getters” in our network. It has a pre-defined list of nornir task functions that they can call. Since it is an app, I can install it on a server so that the net eng users on the team that don’t really know Python at all can consume the code via a user interface.

3 Likes

I’m in the process of building a “day one toolkit” using Nornir and NAPALM. My idea is that by the end of day one at a new customer or new job, you have the following from my toolkit:

  • Running and startup/candidate configs for all devices in the inventory
  • Outputs of all getters as per the NAPALM OS supported getters in JSON files, organised into the relevant hostname directory https://napalm.readthedocs.io/en/latest/support/index.html#getters-support-matrix
  • An Excel spreadsheet which collates all the key information about an inventory with the following on different tabs:
    • Facts
    • Interfaces
    • Interfaces IP
    • LLDP Neighbors
    • Users
      The spreadsheet is meant to be something you can distribute to other network people or managers to give them a high-level summary.

I’m almost done, just need to work out a best practice way for usage of passwords. I don’t want to encourage people putting passwords in their groups.yaml or hosts.yaml file.

3 Likes

Hi Kirk, are the first 3 on github ?

OS upgrade is in the following locations:


https://pynet.twb-tech.com/blog/nornir/os-upgrade-p1.html

I don’t think we have the other two online.

1 Like

thanks, I was interested to see what approach you took to backup configs periodically. would appreciate if you can shed some light.

I have been using different platforms for a while and needed to script something to retrieve information from a bunch of Cisco kit for a customer. Having not touched Nornir, I thought this would be the best time for it.

I created a simple python script that trawled through around 40 switch stacks to gather information for auditing interface descriptions (seeing free ports etc). Once the data was gathered I used the handy NTC-Templates for TextFSM to translate the configuration output of show interface description into structured data.

This was then put into a report (excel) for the customer to use at their pleasure.

Looking forward to using it for more projects in future.

2 Likes

I’ve finished this now. The toolkit is here:

And a blog post for some more background is here too:

https://blog.danielteycheney.com/posts/exploring-nornir-part-two/

I left the credential issue as is for now.

2 Likes

I need your support to use netmiko with redispatch option for Nornir, as it is working for me with netmiko using below template, but i need to apply it with Nornir and make it the default ssh for all use cases. Thanks

windows(script server) – Linux(jump server) – Router

jumpserver = {‘device_type’: ‘terminal_server’,‘ip’: IP,‘username’: User,‘password’: Pass,‘default_enter’: ‘\r\n’,‘global_delay_factor’: 5}

net_connect = ConnectHandler(**jumpserver)

net_connect.find_prompt()
server = net_connect.read_channel()
net_connect.write_channel(‘ssh -l’ + User + ’ ’ + Device)
net_connect.write_channel(’\n’)

redispatch(net_connect, device_type=‘cisco_ios’, session_prep=False)

net_connect.send_command(’\n’)
net_connect.send_command(‘terminal length 0’)
get_cdp_neighbor_details = net_connect.send_command(“show cdp neighbor detail”, delay_factor=5)
net_connect.send_command_expect(‘exit’, expect_string=str(ServerPrompt))

redispatch(net_connect, device_type=‘terminal_server’)

ServerPrompt = net_connect.find_prompt(delay_factor=1)
net_connect.disconnect()

Hi,

We are using Nornir to deploy/delete services on our SP/DC network. Services include L2 and L3 VPN over VXLAN/MPLS networks. To push configuration we use yang/netconf via scrapli.
We also use Nornir for ‘visibility’ into the same network. For example, to check on which devices a VRF is configured or perform capacity planning.
A (basic) homemade GUI has also been developped with flask.

1 Like