In this lesson, we will cover:
- What is Nornir Scrapli?
- What is Nornir?
- How to install Nornir Scrapli.
- Scrapli Nornir tasks.
- Accessing the native Scrapli
- The Nornir Scrapli
What is Nornir Scrapli?
Nornir Scrapli is the Scrapli plugin for Nornir. It provides support within Nornir for the majority of the Scrapli Core and Scrapli Netconf methods via Nornir tasks, along with providing an additional Nornir function. As Nornir does not currently support
asyncio (it is based on multi-threaded synchronous execution), only the synchronous transports can be used.
What is Nornir?
For those of you new to Nornir:
Nornir is a pluggable multi-threaded framework, with inventory management that helps operate network devices.
Nornir is 100% Python. Whereas many automation frameworks (such as Ansible) use their own domain-specific language (DSL), Nornir lets you control everything from Python.
Nornir consists of the following core components:
- Tasks – a task is a Python function that is run on a per-host basis.
- Functions – functions run globally. For example,
print_resultis a function that prints the results of all of the executed tasks.
- Inventory – defines the devices (and any related attributes) that our tasks will be performed against. The inventory structure consists of:
hosts.yaml– individual hosts and any related attributes.
groups.yaml– group definitions and any related attributes for the groups. Hosts are then added to these groups within
defaults.yaml– contains attributes that can be assigned to all hosts regardless of group assignment.
To install the Nornir Scrapli plugin, run the following:
$ pip3 install nornir-scrapli==2021.1.30
Note: This will also install Nornir, which will also be needed for getting hands-on in the upcoming sections.
Scrapli Nornir Tasks
A Nornir task is:
a reusable piece of code that implements some functionality for a single host.
Therefore, one of the main benefits of the Nornir Scrapli plugin is that it provides Nornir tasks for each of the different Scrapli methods (
send_configs_from_file, etc). The full list of supported Scrapli Nornir tasks can be found below: