Files
2025-11-27 13:20:04 +01:00

19 lines
857 B
Python

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
from nornir_netmiko.tasks import netmiko_send_config, netmiko_send_command, netmiko_save_config,netmiko_commit
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