33 lines
999 B
Python
33 lines
999 B
Python
# Originele uitvoering: Robbin, netheid: Taha
|
|
from ncclient import manager # python3 -m pip install ncclient
|
|
import xml.dom.minidom
|
|
|
|
routers = {'ISP':'10.5.5.2', 'EdgeRouter':'10.5.5.3', 'R3':'10.5.5.4'}
|
|
|
|
for router in routers:
|
|
print(f"{'*'*6} working on: {router} {'*'*6}")
|
|
m = manager.connect(
|
|
host=routers[router],
|
|
port=830,
|
|
username="cisco",
|
|
password="cisco",
|
|
hostkey_verify=False
|
|
)
|
|
|
|
netconf_user = """
|
|
<config>
|
|
<native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native">
|
|
<username>
|
|
<name>HU</name>
|
|
<privilege>15</privilege>
|
|
<password>
|
|
<encryption>0</encryption>
|
|
<password>cisco1234</password>
|
|
</password>
|
|
</username>
|
|
</native>
|
|
</config>
|
|
"""
|
|
netconf_reply = m.edit_config(target="running", config=netconf_user)
|
|
|
|
print(xml.dom.minidom.parseString(netconf_reply.xml).toprettyxml()) |