QuestionQ70
VerifiedOperationsAn engineer needs to audit drift between the startup and running configurations through NETCONF. The engineer must retrieve both datastores and write a unified-diff file for review. Options may be used more than once.
Drag & Drop
from ncclient import manager import difflib device = {"host": "198.51.100.30", "port": 830, "username": "netops", "password": "Cisco12345", "hostkey_verify": False} with manager.connect(**device) as m: rcfg = m.(="running") scfg = m.(="startup") running_text = rcfg. startup_text = scfg. diff = difflib.( startup_text.splitlines(keepends=True), running_text.splitlines(keepends=True), fromfile="startup", tofile="running" ) with open("config_drift.diff", "w") as f: f.writelines(diff)
Community Discussion