12-14-2019 08:48 PM
Received the following error when running the below code and not sure how to troubleshoot it or see if it's a known bug on the code level I'm running on the switch or YDK library (any pointers on where to look for open bugs would be appreciated too).
Error:
>>> native_model = netconf_service.get_config(nd_provider, Datastore.running)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/dpeterson/NetAutomation/lib/python3.6/site-packages/ydk/services/netconf_service.py", line 108, in get_config
return _ns_get(provider, source, read_filter, self._ns.get_config)
File "/home/dpeterson/NetAutomation/lib/python3.6/site-packages/ydk/services/netconf_service.py", line 153, in _ns_get
return _read_entities(provider, get_config=is_config)
File "/usr/lib/python3.6/contextlib.py", line 99, in __exit__
self.gen.throw(type, value, traceback)
File "/home/dpeterson/NetAutomation/lib/python3.6/site-packages/ydk/errors/error_handler.py", line 82, in handle_runtime_error
_raise(_exc)
File "/home/dpeterson/NetAutomation/lib/python3.6/site-packages/ydk/errors/error_handler.py", line 54, in _raise
exec("raise exc from None")
File "<string>", line 1, in <module>
ydk.errors.YCoreError: Couldn't fetch child entity 'cisco-ospf:redistribution' in parent /ietf-routing:routing/routing-instance[name='default']/routing-protocols/routing-protocol[type='ietf-ospf:ospfv2'][name='1']/ietf-ospf:ospf/instance[af='ietf-routing:ipv4']
Code:
from ydk.providers import NetconfServiceProvider
from ydk.services import NetconfService, Datastore
from ydk.models.cisco_ios_xe import Cisco_IOS_XE_native \
as xe_native
#
import json
import yaml
class network_device(object):
# The class "constructor" - It's actually an initializer
def __init__(self, hostname, ssh_port = 22, yang_port = 830, username = "dnac_admin", password = "******"):
self.hostname = hostname
self.ssh_port = ssh_port
self.yang_port = yang_port
self.username = username
self.password = password
self.protocol = "ssh"
device = network_device("172.19.247.222")
nd_provider = NetconfServiceProvider(address=device.hostname,
port=device.yang_port,
username=device.username,
password=device.password,
protocol = device.protocol)
netconf_service = NetconfService()
test = netconf_service.get_config(nd_provider, Datastore.running)
12-14-2019 11:22 PM
12-15-2019 09:13 AM - edited 12-15-2019 09:15 AM
12-15-2019 09:53 AM
I found this error in the log:
Data is invalid according to the yang model. Libyang error: Invalid keyword "[1-9][0-9]{1,2}|[1-9])\.\.(409[0-4]|"".
Data is invalid according to the yang model. Libyang error: Module "openconfig-vlan-types" parsing failed.
This error points to a bug in third party library libyang, which I have fixed yesterday. In order to get the fix you need recompile libydk and reinstall core components. Here is simplified procedure:
git clone -b 0.8.4 https://github.com/CiscoDevNet/ydk-gen.git
cd ydk-gen
./generate.py --core --cpp -is
./generate.py --core --python -is
12-15-2019 01:10 PM
I'll try and get that going a little later today or tomorrow and validate the fix, thank you. Out of curiosity (and not meaning to dogpile) but I will occasionally receive a segmentation fault when connecting to a switch. It will typically clear out and I can't find a rhyme or reason but it seams like it's almost like the switch has to wake up or something and then it starts working. I know that doesn't help but is it a known instance and possibly related to this library? Last couple of lines I see before error shown below. If this is a separate topic just let me know and I'll create another post accordingly, thanks.
Going into child routing-protocol in parent /ietf-routing:routing/routing-instance[name='default']/routing-protocols
Looking for 'routing-protocol'
Created entity child 'routing-protocol' in parent '/ietf-routing:routing/routing-instance[name='default']/routing-protocols'
Looking at parent entity 'routing-protocol'
Looking at child leaf '/ietf-routing:routing/routing-instance[name='default']/routing-protocols/routing-protocol[type='ietf-routing:static'][name='1']/type'
Creating entity leaf 'type' of value 'ietf-routing:static' in parent '/ietf-routing:routing/routing-instance[name='default']/routing-protocols/routing-protocol[type='ietf-routing:static'][name='1']'
Created entity leaf 'type' of value 'ietf-routing:static' in parent '/ietf-routing:routing/routing-instance[name='default']/routing-protocols/routing-protocol[type='ietf-routing:static'][name='1']'
Looking at child leaf '/ietf-routing:routing/routing-instance[name='default']/routing-protocols/routing-protocol[type='ietf-routing:static'][name='1']/name'
Creating entity leaf 'name' of value '1' in parent '/ietf-routing:routing/routing-instance[name='default']/routing-protocols/routing-protocol[type='ietf-routing:static'][name='1']'
Created entity leaf 'name' of value '1' in parent '/ietf-routing:routing/routing-instance[name='default']/routing-protocols/routing-protocol[type='ietf-routing:static'][name='1']'
Segmentation fault (core dumped)
12-15-2019 09:25 PM
12-16-2019 09:48 AM
So I went back through the installation process and I think I found that I have the wrong libssh library. I'm running Ubuntu 18.04 and I'm not sure how to update the package (or downgrade it if recommended). When I look around for the libssh package versions I see that 0.8.0 is for Ubuntu 18.04 (which I'm running) any quick pointers on how to get to a good release for libssh?
(NetAutomation) dpeterson@Linux-DHCP:~$ apt list --installed | grep libssh
libssh-4/bionic-updates,bionic-security,now 0.8.0~20170825.94fa1e38-1ubuntu0.5 amd64 [installed]
libssh-dev/bionic-updates,bionic-security,now 0.8.0~20170825.94fa1e38-1ubuntu0.5 amd64 [installed]
12-16-2019 01:11 PM
The libssh installation is described here on the GitHub. Please make sure the system requirements are satisfied before the compilation.
Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: