Devnet 2192

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

Automate Your Network

with Nornir
Python automation framework

Dmitry Figol, Network Automation Engineer


@dmfigol

DEVNET-2192
Cisco Webex Teams

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

How
1 Find this session in the Cisco Events 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

DEVNET-2192 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 3
Agenda

• What is Nornir
• Nornir vs Ansible
• Demo
• Wrap-up

DEVNET-2192 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 4
Code

https://github.com/dmfigol/nornir-apps

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

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

DEVNET-2192 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 7
Pluggable multi-
threaded Python
framework with
Nornir inventory
management to help
operate collections
of devices

DEVNET-2192 © 2020 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, debugging and maintaining playbooks is hard


• Inflexible: problems with extensibility and non-trivial tasks
• Slow and resource-intensive
• Breaking changes between versions

DEVNET-2192 © 2020 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


• Fast thanks to threads

DEVNET-2192 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 10
Nornir advantages (cont.)

• Re-uses existing libraries for the connections: netmiko, napalm,


ncclient
• 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)

DEVNET-2192 © 2020 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

DEVNET-2192 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 12
Development focus

• Backwards compatibility
• Semantic versioning is strictly followed

• Modern tooling used with CI to improve code quality: linting, code


style, static type checking, unit testing
• Good documentation
• Even examples in tutorials are being automatically tested as part of CI

DEVNET-2192 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 13
Use-cases
• Run as a standalone script
• Integrate with a web framework
• Integrate with pytest for network testing

DEVNET-2192 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 14
Latest features

• NETCONF support (integration with ncclient)


• Processors – functions executed on events

DEVNET-2192 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 15
What we are working on
• Exploring asyncio support
• Customization of task runners (e.g. retry mechanisms)

DEVNET-2192 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 16
Demo
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

DEVNET-2192 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 18
Resources and where to go next

• Code: https://github.com/dmfigol/nornir-apps
• Nornir documentation: https://nornir.readthedocs.io
• 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

DEVNET-2192 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 19
Complete your
online session
survey • Please complete your session survey
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 t-shirt.
• All surveys can be taken in the Cisco Events
Mobile App or by logging in to the Content
Catalog on ciscolive.com/emea.

Cisco Live sessions will be available for viewing on


demand after the event at ciscolive.com.

DEVNET-2192 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 20
Continue your education

Demos in the
Walk-In Labs
Cisco Showcase

Meet the Engineer


Related sessions
1:1 meetings

DEVNET-2192 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 21
Thank you

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy