Simple Inventory
Simple Local Inventory is an inventory plugin to load inventory data from locally stored files.
Sample inventory file
broker:
endpoint: "tcp://127.0.0.1:5555"
workers:
nornir-*:
- nornir/common.yaml
nornir-worker-1:
- nornir/nornir-worker-1.yaml
topology:
broker: True
workers:
- nornir-worker-1
where nornir/common.yaml
contains
service: nornir
broker_endpoint: "tcp://127.0.0.1:5555"
runner:
plugin: RetryRunner
options:
num_workers: 100
num_connectors: 10
connect_retry: 3
connect_backoff: 1000
connect_splay: 100
task_retry: 3
task_backoff: 1000
task_splay: 100
reconnect_on_fail: True
task_timeout: 600
and nornir/nornir-worker-1.yaml
contains
hosts:
csr1000v-1:
hostname: sandbox-1.lab.com
platform: cisco_ios
username: developer
password: secretpassword
csr1000v-2:
hostname: sandbox-2.lab.com
platform: cisco_ios
username: developer
password: secretpassword
groups: {}
defaults: {}
Whenever inventory queried to provide data for worker with name nornir-worker-1
Simple Inventory iterates over workers
dictionary and recursively merges
data for keys (glob patterns) that matched worker name.
WorkersInventory(path, data)
¤
Class to collect and server NorFab workers inventory data, forming it by recursively merging all data files that associated with the name of worker requesting inventory data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
OS path to top folder with workers inventory data |
required |
data
|
dict
|
dictionary keyed by glob patterns matching workers names and values being a list of OS paths to files with workers inventory data |
required |
Source code in norfab\core\inventory.py
108 109 110 111 112 113 114 115 116 117 118 119 120 |
|
NorFabInventory(path)
¤
NorFabInventory class to instantiate simple inventory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
OS path to YAML file with inventory data |
required |
Source code in norfab\core\inventory.py
151 152 153 154 155 156 157 158 159 160 161 |
|
merge_recursively(data, merge)
¤
Function to merge two dictionaries data recursively.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
dict
|
primary dictionary |
required |
merge
|
dict
|
dictionary to merge into primary overriding the content |
required |
Source code in norfab\core\inventory.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
|