03-18-2020 02:44 AM
Hi Pals,
I am studying for the CCNA DevNet Certifications and I was testing the YANG models from the Cisco IOS 1000v
I am using this code for my home lab.
from ncclient import manager # import logging # logging.basicConfig(level=logging.DEBUG) router = {"host": "192.168.50.253", "port": "22", "username": "R2", "password":"***"} with manager.connect(host=router["host"], port=router["port"], username=router["username"], password=router["password"], hostkey_verify=False) as m: for capability in m.server_capabilities: print('*' * 50) print(capability)
and I am getting this response
XE/netconf-2.py" ************************************************** urn:ietf:params:netconf:base:1.0 ************************************************** urn:ietf:params:netconf:capability:writeable-running:1.0 ************************************************** urn:ietf:params:netconf:capability:startup:1.0 ************************************************** urn:ietf:params:netconf:capability:url:1.0 ************************************************** urn:cisco:params:netconf:capability:pi-data-model:1.0 ************************************************** urn:cisco:params:netconf:capability:notification:1.0 PS C:\Users\user_\Desktop\CCNA DEVNET>
But when I use the Cisco DevNet Sandbox, I get a lot of modules.
router = {"host": "ios-xe-mgmt-latest.cisco.com", "port": "10000", "username": "developer", "password": "*******"}
XE/netconf-2.py" ************************************************** urn:ietf:params:netconf:base:1.0 ************************************************** urn:ietf:params:netconf:base:1.1 ************************************************** urn:ietf:params:netconf:capability:candidate:1.0 ************************************************** urn:ietf:params:netconf:capability:xpath:1.0 ************************************************** urn:ietf:params:netconf:capability:validate:1.0 ************************************************** urn:ietf:params:netconf:capability:validate:1.1 ************************************************** urn:ietf:params:netconf:capability:rollback-on-error:1.0 ************************************************** urn:ietf:params:netconf:capability:notification:1.0 ************************************************** urn:ietf:params:netconf:capability:interleave:1.0 ************************************************** urn:ietf:params:netconf:capability:with-defaults:1.0?basic-mode=explicit&also-supported=report-all-tagged ... ... ... etc
I am planning to use this module:
in the future for reading and configure an interface in my home IOS 1000v Lab, buy seems it does not work.
Could you please help to answer how can I enable more Yang modules in my home lab?
This is the IOS version I am using
R2#show ver Cisco IOS XE Software, Version 16.06.05 Cisco IOS Software [Everest], Virtual XE Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 16.6.5, RELEASE SOFTWARE (fc3) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2018 by Cisco Systems, Inc. Compiled Mon 10-Dec-18 13:07 by mcpre
IOS image
Solved! Go to Solution.
03-18-2020 09:21 AM
Hi Juan
I noticed that you specify port 22 for your device. I doubt that is the port for Netconf, because it is reserved for Telnet. If port is not configured, then Netconf is listening on port 840. Please make sure that Netconf is configured on your device properly. You also can try to run ssh command directly to your device:
ssh R2@192.168.50.253 -p 840 -s netconf
If Netconf is configured, the command will return list of capabilities.
03-18-2020 09:21 AM
Hi Juan
I noticed that you specify port 22 for your device. I doubt that is the port for Netconf, because it is reserved for Telnet. If port is not configured, then Netconf is listening on port 840. Please make sure that Netconf is configured on your device properly. You also can try to run ssh command directly to your device:
ssh R2@192.168.50.253 -p 840 -s netconf
If Netconf is configured, the command will return list of capabilities.
03-18-2020 08:21 PM
Thank you very much,
It did not worked with port 840, but I tried 830 and now I can see all the containers I need to read,modify the router.
Note: I had errors in my code because (well I used other router and) the current gigabit was lacking of a 'description' and 'ip address', while debugging python it just says there was an error. I just added back and error was gone.
#This is MY IOS 1000v Router router = {"host": "192.168.50.254", "port": "830","username": "R1", "password":"***"}
Exception has occurred: KeyError 'address' File "C:\Users\user_\Desktop\CCNA DEVNET\19 NETCONF script IOS XE\netconf-4.py", line 64, in <module> print(f"IP: {config['ipv4']['address']['ip']}")
but is working as expected.
Thank you!
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide