112 lines
2.4 KiB
Plaintext
112 lines
2.4 KiB
Plaintext
#Onderstaande commando uitvoeren op alle routers onder config-t
|
|
Netconf-yang
|
|
|
|
#Onderstaande installeren op CentOS8
|
|
yum install python3-pip
|
|
python3 -m pip install ncclient
|
|
|
|
touch netconfr3.py
|
|
nano netconfr3.py
|
|
|
|
#Onderstaande is het script om een user toevoegen op ISP!
|
|
from ncclient import manager
|
|
import xml.dom.minidom
|
|
|
|
m = manager.connect(
|
|
host="ISP",
|
|
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())
|
|
|
|
touch netconfedgerouter.py
|
|
nano netconfedgerouter.py
|
|
|
|
#Onderstaande is het script om een user toevoegen op Edgerouter!
|
|
m = manager.connect(
|
|
host="EdgeRouter",
|
|
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())
|
|
|
|
touch netconfisp.py
|
|
nano netconfisp.py
|
|
|
|
#Onderstaande is het script om een user toevoegen op R3!
|
|
|
|
#User toevoegen ISP
|
|
from ncclient import manager
|
|
import xml.dom.minidom
|
|
|
|
m = manager.connect(
|
|
host="R3",
|
|
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())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|