11-30-2016 09:44 PM
HI Santiago,
I tried to use nc-read-xr-shellutil-cfg-20-ydk.py to read the hostname on a IOS-XRv on VIRL. However, it said the server reject...
What I modified the code is changing "import urlparse" to "import urllib.parse" because I'm using python3.
any clue how to fix it??
In XR cli, I did in enable the yang, I just don't know why the default port is not 830 but port 22.
XR CLI:
=======
xml agent tty
!
netconf agent tty
!
netconf-yang agent
ssh
!
ssh server v2
ssh server vrf Mgmt-intf
=============================================================
python3 nc-read-xr-shellutil-cfg-20-ydk.py ssh://admin:admin@172.16.1.101:22 -v
2016-11-30 23:10:08,103 - ydk.providers.netconf_provider - INFO - NetconfServiceProvider connected to 172.16.1.101:22 using ssh
2016-11-30 23:10:08,114 - ydk.providers.NetconfServiceProvider - DEBUG -
****************************
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="101">
<get>
<filter type="subtree">
<host-names xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-shellutil-cfg"/>
</filter>
</get>
</rpc>
2016-11-30 23:10:08,114 - ydk.providers.NetconfServiceProvider - DEBUG -
****************************
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:9887d8a1-ae7f-4f4a-9a54-a21982af18bf">
<get>
<filter type="subtree">
<host-names xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-shellutil-cfg"/>
</filter>
</get>
</rpc>
2016-11-30 23:10:08,208 - ydk.providers.NetconfServiceProvider - ERROR - ****************************
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:9887d8a1-ae7f-4f4a-9a54-a21982af18bf">
<get>
<filter type="subtree">
<host-names xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-shellutil-cfg"/>
</filter>
</get>
</rpc>
<?xml version="1.0"?>
<rpc-reply message-id="urn:uuid:9887d8a1-ae7f-4f4a-9a54-a21982af18bf" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<rpc-error>
<error-type>protocol</error-type>
<error-tag>unknown-element</error-tag>
<error-severity>error</error-severity>
<error-path xmlns:ns1="http://cisco.com/ns/yang/Cisco-IOS-XR-shellutil-cfg">ns1:host-names</error-path>
<error-info>
<bad-element>host-names</bad-element>
</error-info>
</rpc-error>
</rpc-reply>
****************************
2016-11-30 23:10:08,209 - ydk.services.crud_service - INFO - READ operation completed
Traceback (most recent call last):
File "nc-read-xr-shellutil-cfg-20-ydk.py", line 78, in <module>
host_names = crud.read(provider, host_names)
File "/usr/local/lib/python3.5/dist-packages/ydk/services/crud_service.py", line 150, in read
payload = self._execute_crud_operation_on_provider(provider, read_filter, 'READ', only_config)
File "/usr/local/lib/python3.5/dist-packages/ydk/services/crud_service.py", line 167, in _execute_crud_operation_on_provider
operation
File "/usr/local/lib/python3.5/dist-packages/ydk/services/service.py", line 36, in execute_payload
reply = provider.execute(payload, operation)
File "/usr/local/lib/python3.5/dist-packages/ydk/providers/netconf_provider.py", line 90, in execute
return self.sp_instance.execute_operation(payload, operation)
File "/usr/local/lib/python3.5/dist-packages/ydk/providers/_provider_plugin.py", line 224, in execute_operation
return self._handle_rpc_reply(operation, payload, reply_str.xml)
File "/usr/local/lib/python3.5/dist-packages/ydk/providers/_provider_plugin.py", line 246, in _handle_rpc_reply
self._handle_rpc_error(payload, reply_str, pathlist)
File "/usr/local/lib/python3.5/dist-packages/ydk/providers/_provider_plugin.py", line 262, in _handle_rpc_error
raise YPYServiceProviderError(error_code=YPYErrorCode.SERVER_REJ, error_msg=reply_str)
ydk.errors.YPYServiceProviderError: Server rejected request.
error-type: protocol
error-tag: unknown-element
error-severity: error
error-path: ns1:host-names
bad-element: host-names
Solved! Go to Solution.
12-02-2016 01:36 AM
Finally upgraded the XRv to 6.1.2 from 6.0.1, it fixes the problem. But still the port is 22 instead of 830.
12-02-2016 01:36 AM
Finally upgraded the XRv to 6.1.2 from 6.0.1, it fixes the problem. But still the port is 22 instead of 830.
12-02-2016 12:14 PM
As you found out, the model structure changed sinced 6.0.1. It was missing a top container which translated to a missing top class in YDK. Not sure what you mean by using port 22 instead of 830. Remove this configuration:
xml agent tty ! netconf agent tty !
You only need the netconf-yang agent. Those other two agents are legacy.
12-07-2016 06:27 AM
Hi Santiago,
I need to specify port 22 "python3 nc-read-xr-shellutil-cfg-20-ydk.py ssh://admin:admin@172.16.1.101:22 -v" instead of port 830. Not sure if it is on XRv in VIRL.
12-07-2016 07:32 PM
You can just invoke with default port (830) like this:
"$ ./nc-read-xr-shellutil-cfg-20-ydk.py ssh://admin:admin@172.16.1.101 -v"
You can specify explicitly a port. Both 830 and 22 should work.
12-07-2016 08:03 PM
Tried and cannot open socket... not sure if it is VIRL XRv issue...
yitung@ubuntu:~/mycode/ydk-py-samples/samples/basic/crud/models/cisco-ios-xr/Cisco-IOS-XR-shellutil-cfg$ python3 nc-read-xr-shellutil-cfg-30-ydk.py ssh://admin:admin@172.16.1.101 -v
Traceback (most recent call last):
File "nc-read-xr-shellutil-cfg-30-ydk.py", line 71, in <module>
protocol=device.scheme)
File "/usr/local/lib/python3.5/dist-packages/ydk/providers/netconf_provider.py", line 69, in __init__
self._connect()
File "/usr/local/lib/python3.5/dist-packages/ydk/providers/netconf_provider.py", line 75, in _connect
self.sp_instance.connect(self.session_config)
File "/usr/local/lib/python3.5/dist-packages/ydk/providers/_provider_plugin.py", line 299, in connect
hostkey_verify=False)
File "/usr/local/lib/python3.5/dist-packages/ncclient/manager.py", line 153, in connect
return connect_ssh(*args, **kwds)
File "/usr/local/lib/python3.5/dist-packages/ncclient/manager.py", line 118, in connect_ssh
session.connect(*args, **kwds)
File "/usr/local/lib/python3.5/dist-packages/ncclient/transport/ssh.py", line 369, in connect
raise SSHError("Could not open socket to %s:%s" % (host, port))
ncclient.transport.errors.SSHError: Could not open socket to 172.16.1.101:830
12-08-2016 08:55 AM
Make sure that you router has this configuration:
netconf-yang agent
ssh
!
ssh server v2
ssh server netconf vrf default
!
No other XML or NETCONF configuration should be present. Also, you need to have generated your public key from Exec:
RP/0/RP0/CPU0:Router# crypto key generate rsa
Thu Dec 8 08:31:06.992 UTC
The name for the keys will be: the_default
Choose the size of the key modulus in the range of 512 to 4096 for your General Purpose Keypair. Choosing a key modulus greater than 512 may take a few minutes.
How many bits in the modulus [2048]: 4096
Generating RSA keys ...
Done w/ crypto generate keypair
[OK]
RP/0/RP0/CPU0:Router#
RP/0/RP0/CPU0:Router#sh crypto key mypubkey rsa
Thu Dec 8 08:31:31.213 UTC
Key label: the_default
Type : RSA General purpose
Size : 4096
Created : 08:31:17 UTC Thu Dec 08 2016
Data :
30820222 300D0609 2A864886 F70D0101 01050003 82020F00 3082020A 02820201
008A063B 6923DB5A 8D34C93C 3D27EDE0 2B5EF5CE 79FEB8FE 56BBCABF F14F896C
A0D6ED30 FE2F5E94 C7BA4D20 446FD89C 3838DECD 5503A71B C752CCF4 9D82BA4D
5F2B2EA6 8EBD2397 F3BD91C3 A855C4E2 6219C783 52E2FA01 D6BDEEF7 B16BDCBE
71D2FE4B A27B6987 27E12173 151CC8E1 80B04EA0 1B0225DC 1A70E2C3 25E20505
C191CB10 E0FAD17C 4E17A918 733BEE9A 70BEE404 EC06B7AF 1EDCC731 2F369135
03416F9C 795C64DC EEA0A0AB 72C08B42 C0B4B621 A3A8CE87 3AF23B63 AEA86ED0
FB562E9A 0C4733ED 0758EDE8 1B1D481F 925A6452 1705FFC7 2DD4F493 A37D274D
337AC5CE D81F5584 BF7B9402 EC236456 79309F17 B4466407 39406605 3E0BE9CC
50F54820 A5E1EABC 3E1508EB 1BF4879F 1F48CE30 EF1CFA6E 45C738B6 7E836E13
35CCFB59 ACECB39F 946D843C 7495A975 D121AB5D 4E49C681 B9B8FF32 92DEC3A7
B26A23D7 F440CA1C 03A2F854 82EF3C06 C1CF74E4 0D812EA2 A51A911A EF2C7D7C
2C6A4CF5 6FD1E003 9E4E7EFD ED90C5D1 736E6D7F 3EA60644 20B168B2 05F9A688
91E8E3FE D3634BCC F29CB03D E11FE730 CD4AEB9D 43F18529 592A18C2 8A2098CB
EB47E1F4 C5935CF7 4129ABDF DE10949F C80CFA99 26543F96 0AD657B9 DC4D81E3
4B852B7F 13B44CDA 7FD466F9 14CD2131 F9148F75 9AB5377A 380B19BE 3DFF1C31
CF3F924C 27ED0955 EA9F55E9 386B5D29 10ADEDA1 2FCA3A1C 41385E7F 3A1176C9
55020301 0001
RP/0/RP0/CPU0:Router#
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