-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bump to 0.16.1, fix for salt-nornir netbox pillar and added couple fi…
…els for retrieved connections data
- Loading branch information
Showing
8 changed files
with
273 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "salt_nornir" | ||
version = "0.16.0" | ||
version = "0.16.1" | ||
description = "Salt-Nornir Proxy Minion SaltStack Modules" | ||
authors = ["Denis Mulyalin <[email protected]>"] | ||
maintainers = ["Denis Mulyalin <[email protected]>"] | ||
|
@@ -180,6 +180,9 @@ dataprocessor = [ | |
"xmltodict", | ||
"lxml" | ||
] | ||
netbox = [ | ||
"pynetbox" | ||
] | ||
|
||
[tool.poetry.plugins."salt.loader"] | ||
"module_dirs" = "salt_nornir.loader:module_dirs" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
""" | ||
Netbox Utils | ||
============ | ||
Collection of functions for Salt-Nornir to interact with Netbox. | ||
""" | ||
import logging | ||
import json | ||
import requests | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
try: | ||
import pynetbox | ||
|
||
HAS_PYNETBOX = True | ||
except ImportError: | ||
HAS_PYNETBOX = False | ||
|
||
|
||
def get_load_config_tasks(hosts: dict): | ||
""" | ||
Function to produce a list of tasks to collect output from devices | ||
for load_config function. | ||
:param data: dictionary with Nornir Inventory data of hosts to produce tasks for | ||
""" | ||
ret = [] | ||
platforms_added = set() | ||
for host_name, platform in hosts.items(): | ||
task_kwargs = {} | ||
if platform in platforms_added: | ||
continue | ||
elif platform in ["cisco_xr", "iosxr"]: | ||
template = "ttp://misc/Netbox/parse_cisco_xr_config.txt" | ||
elif platform in ["juniper_junos", "junos", "juniper"]: | ||
template = "ttp://misc/Netbox/parse_juniper_junos_config.txt" | ||
elif platform in ["arista_eos", "eos"]: | ||
template = "ttp://misc/Netbox/parse_arista_eos_config.txt" | ||
task_kwargs["enable"] = True | ||
else: | ||
log.info( | ||
f"netbox_utils:get_load_config_tasks unsupported " | ||
f"platform '{platform}', host name '{host_name}'" | ||
) | ||
continue | ||
ret.append( | ||
{ | ||
"fun": "cli", | ||
"kwargs": { | ||
**task_kwargs, | ||
"FL": [h for h, p in hosts.items() if p == platform], | ||
"run_ttp": template, | ||
"ttp_structure": "dictionary", | ||
}, | ||
} | ||
) | ||
platforms_added.add(platform) | ||
|
||
return ret | ||
|
||
|
||
def load_config(data: dict): | ||
""" | ||
Function to parse devices confgiuration and load it into Netbox device | ||
confguration context. | ||
""" | ||
pass | ||
|
||
|
||
# dispatch dictionary of Netbox tasks exposed for calling | ||
netbox_tasks = {"load_config": {"fun": load_config, "tasks": get_load_config_tasks}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters