This commit is contained in:
2025-11-27 11:59:36 +01:00
parent 39f8b87743
commit 558a4c30f7
15 changed files with 1525 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
from api import app
from nornir_napalm.plugins.tasks import napalm_get, napalm_configure, napalm_cli
from nornir.core.task import Task, Result
from nornir_utils.plugins.functions import print_result
def get_config_by_device(device):
nr = app.config.get('nr')
result = nr.filter(device_name=device.get('name')).run(task=napalm_get, getters=["get_config"])
return result[device.get('name')][0].result.get("get_config")
def run_config_from_file_by_device(device=None, file_path=None):
nr = app.config.get('nr')
if device and file_path:
result = nr.filter(device_name=device.get('name')).run(task=netmiko_send_config,
config_file=file_path)
print_result(result)
return result[device.get('name')].changed