As I begin looking into Python and the DevNet materials, I’ve been wanting to utilize my own lab in order for me to run various tests against. I also wanted it to be closer to Wi-Fi, aside from testing against Meraki’s Sandbox.
So to get started, I figured the Cisco C9800-CL would be a good place to start. I’ve been using it to test Wi-Fi 6 and now I can use it to test my Python knowledge.
Do you find this content useful? If so, consider buying me a coffee! ☕
Configure NETCONF
First thing we need to do is enable NETCONF-YANG on the C9800-CL. This is very easy to do.
First, let’s see what’s running by running show platform software yang-management process
WLC#show platform software yang-management process
confd : Not Running
nesd : Not Running
syncfd : Not Running
ncsshd : Not Running
dmiauthd : Not Running
nginx : Running
ndbmand : Not Running
pubd : Running
gnmib : Not Running
Ok, NETCONF-YANG is not running. Only nginx
and pubd
are running. We need all the processes running except for gnmib
.
Enabling NETCONF-YANG is simple with this config command: netconf-yang
To do that type in the following commands and verify:
WLC#conf t
Enter configuration commands, one per line. End with CNTL/Z.
WLC(config)#
WLC(config)#netconf-yang
WLC(config)#exit
WLC#
WLC#
WLC#show platform software yang-management process
confd : Running
nesd : Running
syncfd : Running
ncsshd : Running
dmiauthd : Running
nginx : Running
ndbmand : Running
pubd : Running
gnmib : Not Running
That’s it. Now I have to figure out how to use NETCONF-YANG models 😂
Use the YANGExplorer, Cisco YANGSuite, Advanced Netconf Explorer, pyang… etc work working with the data models
I’ve heard of some of those. Haven’t gotten around to using them yet but now is a good time to start.
from ncclient import manager
wlc=’xx.xx.xx.xx’
user=’xx’
password=’xx’
netconf_connection=manager.connect(host=wlc,
port=830,
username=user,
password=password,
hostkey_verify=False,
device_params={‘name’:’csr’},
timeout=300)
print(netconf_connection)
I got an erro informaiton:
raise SSHError(“Could not open socket to %s:%s” % (host, port))
ncclient.transport.errors.SSHError: Could not open socket to 10.124.55.34:830
is there something wrong with this code?
Can you confirm that 10.124.55.34 is listening on port 830?