nornir | Pluggable multi-threaded framework | Automation library
kandi X-RAY | nornir Summary
kandi X-RAY | nornir Summary
Pluggable multi-threaded framework with inventory management to help operate collections of devices
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Run a single task
- Start the task instance
- Load the inventory
- List of extended groups
- Return extended data
- Return the list of items
- Create a Config from a config file
- Return a new inventory that matches the given filters
- Run the given task
- Return a copy of this task
- Default schema definition
- Schema for JSON Schema
- Schema for connection options
- Schema definition
- Return a dict representation of the configuration
- Return a dict representation of the connection
- Dictionary representation of the object
- Get an attribute from the server
- Merge two dictionaries
- Close all open connections
- Close a connection
- Run a task
- List of failed hosts
nornir Key Features
nornir Examples and Code Snippets
(myvenv) juliopdx:~/git/multi-vendor-python/nornir_example$ python3 ospf_run.py
Nornir initialized with the following hosts:
ArubaCX
vEOS
vIOS
deploy_ospf*********************************************************************
* ArubaCX ** changed
---
sites:
- name: moscow
networks:
- 10.1.0.0/17
- 10.2.0.0/16
core: n7k1
siteID: 1
- name: samara
networks:
- 10.1.160.0/19
- 10.1.220.0/24
core: sam-core
siteID: 2
---
n7k1:
hostname: nexus1
sudo -iu nautobot
$ pip3 install nautobot-plugin-nornir
$ echo nautobot-plugin-nornir >> $NAUTOBOT_ROOT/local_requirements.txt
# In your nautobot_config.py
PLUGINS = ["nautobot_plugin_nornir"]
PLUGINS_CONFIG = {
"nautobot_plugin_nornir"
def assign_aws_public_ips(task):
task.host.hostname = get_aws_public_ip(str(task.host), task.host['aws_region'])
return(f"{task.host} = {task.host.hostname}")
inventory:
plugin: nornir.plugins.inventory.simple.SimpleInventory
options:
host_file: 'inventory/hosts.yaml'
group_file: 'inventory/groups.yaml'
defaults_file: 'inventory/defaults.yaml'
runner:
plugin: threaded
optio
var = task.run(task=text.template_file,
name="Device Configuration",
template="router_master_config.j2",
path=f"./templates/",
calculate_subnet=calculate_subnet
)
<
Community Discussions
Trending Discussions on nornir
QUESTION
from nornir import InitNornir
from nornir_napalm.plugins.tasks import napalm_get
from nornir_utils.plugins.functions import print_result
import json
def prettyPrintDictionary(dict):
print(json.dumps(dict, indent=2))
nr = InitNornir(config_file="/home/python/nornir-scripts/config.yaml")
print(nr.inventory.hosts)
prettyPrintDictionary(nr.inventory.get_hosts_dict())
...ANSWER
Answered 2020-Dec-14 at 14:37According to the documentation, the num_workers
key should be inside the runner.options
key. Add it to the options
key and try again:
QUESTION
i am trying to work with nornir but i get this
whene i try this :
from nornir.plugins.functions.text import print_result
i get this:
...ANSWER
Answered 2020-Oct-07 at 16:07Looking in the nornir
module docs there is no print_result
function, but it is present in the nornir_utils
module.
The plugins present in nornir
are four, look here
You can install the nornir_utils
module with pip install nornir_utils
and the nornir
module as pip install nornir
.
The corrent import to do is from nornir_utils.plugins.functions import print_result
.
Make sure to use the right pip to install the packages, sometimes I install in the wrong env having multiple python installation.
QUESTION
I could not comment on the same question here, not enough Republic credits
I attempted the yaml cmd as suggested by @Anthon but does not shield the desired output and have no idea how to start modifying the yaml from-csv code, I did look into the code in "yaml_cmd.py"
Any guidance would be appreciated. Trying to convert a large csv file into hosts.yaml format to use with Nornir.
CSV format is: ...ANSWER
Answered 2020-May-12 at 22:16Well, this is not pretty but worked
QUESTION
I'm using Nornir to automate the configs for network devices. In my Jinja2 template, I want to call a Python function to do a subnet calculation for me. I can't seem to figure out how to get Jinja2 the ability to call the Python function with Nornir as the driver.
Error output:
...ANSWER
Answered 2019-Nov-13 at 19:33If you trace the code of nornir.core.task.run
you'll find that it simply passes the keyword arguments down to the plugins, eventually to t.render
in nornir.core.helpers.jinja_helper.render_from_file
.
You can therefore simply pass your function object as an additional keyword argument to task.run
to make it available in the namespace of the template:
QUESTION
Jinja Template Issue when using napalm function within nornir framework.
updated: My hosts are Cisco IOS devices.
I am running this nornir Jinja template script in a python3.6 virtualenv. I have other simple nornir and napalm code running fine, which makes we suspect the issue is related to jinja2 template function i am trying to use.
The error i am receiving is below. Can anyone assist me with spotting the problem?
working nornir script w/ napalm function - Example showing working environment
...ANSWER
Answered 2018-Aug-14 at 12:43You are not passing system
to the template. I think what you are trying to do in your template is:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install nornir
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page