DEVNET-2192-Automate Your Network With Nornir Python Automation Framework PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

#CLUS

Automate your
network with Nornir
Python automation framework

Dmitry Figol, SE EN Sales — Programmability


@dmfigol
DEVNET-2192

#CLUS
Cisco Webex Teams
Questions?
Use Cisco Webex Teams to chat
with the speaker after the session

How
1 Find this session in the Cisco Live Mobile App
2 Click “Join the Discussion”
3 Install Webex Teams or go directly to the team space
4 Enter messages/questions in the team space

Webex Teams will be moderated cs.co/ciscolivebot#DEVNET-2192


by the speaker until June 16, 2019.

#CLUS © 2019 Cisco and/or its affiliates. All rights reserved. Cisco Public 3
Agenda
• What is Nornir
• Nornir vs Ansible
• Demo
• Summary

#CLUS DEVNET-2192 © 2019 Cisco and/or its affiliates. All rights reserved. Cisco Public 4
About me

@dmfigol
dmfigol
dmfigol.me
dmfigol
dmfigol

#CLUS DEVNET-2192 © 2019 Cisco and/or its affiliates. All rights reserved. Cisco Public 5
”I am not sure why they are
reinventing Ansible”
Me in 2018

#CLUS DEVNET-2192 © 2019 Cisco and/or its affiliates. All rights reserved. Cisco Public 6
”I would like to help you maintain
Nornir”
Also me 9 months later

#CLUS DEVNET-2192 © 2019 Cisco and/or its affiliates. All rights reserved. Cisco Public 7
Flexible and
scalable network
automation
framework where
Nornir everything is done in
Python

DEVNET-2192 © 2019 Cisco and/or its affiliates. All rights reserved. Cisco Public 8
Why not Ansible
• Tasks written in domain-specific language (DSL)
• Programming in YAML?
• Troubleshooting and debugging playbooks is hard
• Poor architecture for local execution leading to scalability problems
• Poor developer experience
• CLI as the primary entry point

#CLUS DEVNET-2192 © 2019 Cisco and/or its affiliates. All rights reserved. Cisco Public 9
Nornir advantages
• Provides an abstraction for inventory (hosts and groups) and
concurrent task execution
• Everything in Python (or Golang, check out Gornir)
• Just another Python library to import
• Great flexibility and extensibility
• Very fast due to use of threads

#CLUS DEVNET-2192 © 2019 Cisco and/or its affiliates. All rights reserved. Cisco Public 10
Nornir advantages (cont.)
• Re-uses existing libraries for the connections: netmiko, napalm
• Caches, re-uses and automatically closes opened connections
• Use any troubleshooting, debugging or testing tool from Python
ecosystem
• Easy hosts filtering based on any attribute or combination of
attributes
• Easy integration with other Python frameworks (Flask, Django,
pytest)

#CLUS DEVNET-2192 © 2019 Cisco and/or its affiliates. All rights reserved. Cisco Public 11
”The more I work with Nornir; the
more I like it.
The more I work with Ansible;
the more I like Nornir”
Kirk Byers
Twin Bridges Technology

#CLUS DEVNET-2192 © 2019 Cisco and/or its affiliates. All rights reserved. Cisco Public 12
Development focus
• Small codebase (4k lines of code) which is easy to maintain
• Backwards compatibility
• Semantic versioning is strictly followed
• Modern tooling used with CI to improve code quality: linting, code
style, static type checking, unit testing
• Detailed documentation
• Even examples in tutorials are being automatically tested as part of
CI

#CLUS DEVNET-2192 © 2019 Cisco and/or its affiliates. All rights reserved. Cisco Public 13
Use-cases
• Run as a standalone script (print results, save to a file, etc.)
• Integrate with a web framework
• Integrate with pytest for network testing

#CLUS DEVNET-2192 © 2019 Cisco and/or its affiliates. All rights reserved. Cisco Public 14
Demo
https://github.com/dmfigol/nornir-workshop
Wrap-up
Summary
• Nornir is a flexible multi-threaded Python network automation
framework which abstracts inventory and task execution
• Everything is in Python so it’s very easy to integrate with any other
Python code

#CLUS DEVNET-2192 © 2019 Cisco and/or its affiliates. All rights reserved. Cisco Public 17
Where to go next
• Nornir documentation: https://nornir.readthedocs.io
• Using Nornir for OS Upgrades by Kirk Byers
• Talk to the developer team on:
• Our forum: https://nornir.discourse.group/
• Network To Code Slack, #nornir channel

• Open an issue on GitHub: https://github.com/nornir-


automation/nornir

#CLUS DEVNET-2192 © 2019 Cisco and/or its affiliates. All rights reserved. Cisco Public 18
Complete your
online session • Please complete your session survey
evaluation after each session. Your feedback
is very important.
• Complete a minimum of 4 session
surveys and the Overall Conference
survey (starting on Thursday) to
receive your Cisco Live water bottle.
• All surveys can be taken in the Cisco Live
Mobile App or by logging in to the Session
Catalog on ciscolive.cisco.com/us.
Cisco Live sessions will be available for viewing
on demand after the event at ciscolive.cisco.com.

#CLUS DEVNET-2192 © 2019 Cisco and/or its affiliates. All rights reserved. Cisco Public 19
Continue your education

Demos in the
Walk-in labs
Cisco campus

Meet the engineer


Related sessions
1:1 meetings

#CLUS DEVNET-2192 © 2019 Cisco and/or its affiliates. All rights reserved. Cisco Public 20
Thank you

#CLUS
#CLUS

You might also like