cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
623
Views
5
Helpful
2
Replies

[gNMI Service Provider] Yang models not downloaded to specified repository

kmathiya
Cisco Employee
Cisco Employee

Hi Team,

 

When I tried to connect via gNMI Service Provider and execute CRUD, getting "ydk.errors.YCoreError: YCodecError:Unknown element "lldp".. Path:" for Model Cisco_IOS_XR_ethernet_lldp_cfg. On further analysis, found that yang models are not downloaded to my specified repository whereas with NetconfServiceProvider all the required models are getting downloaded with the same device. Added logs for reference.

 

Could you please help me to resolve the issue?

 

Connecting via NetconfServiceProvider:

(rhel7-PY367_Y84) kmathiya@kulambi ~/.ydk > ls /users/kmathiya/.ydk
(rhel7-PY367_Y84) kmathiya@kulambi ~/.ydk > python
Python 3.6.7 (v3.6.7:6ec5cf2, Oct 24 2018, 15:53:56)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> from ydk.path import Repository
>>> from ydk.gnmi.providers import gNMIServiceProvider
>>> repository=Repository()
>>>provider=gNMIServiceProvider(repo=repository,address="6.x.x.x",port=57400,username="cafyauto",password="cisco123")
>>> from ydk.services import CRUDService
>>> crud = CRUDService()
>>>
>>> from ydk.models.cisco_ios_xr import Cisco_IOS_XR_ethernet_lldp_cfg
>>> lldp=Cisco_IOS_XR_ethernet_lldp_cfg.Lldp()
>>> lldp.enable=True
>>> lldp.enable_subintf=True
>>> crud.read(provider,lldp)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/auto/tftp-access-ops/kmat/release/PY367_Y84/rhel7-PY367_Y84/lib/python3.6/site-packages/ydk/services/crud_service.py", line 60, in read
return _crud_read(provider, read_filter, False, self._crud.read)
File "/auto/tftp-access-ops/kmat/release/PY367_Y84/rhel7-PY367_Y84/lib/python3.6/site-packages/ydk/services/crud_service.py", line 88, in _crud_read
read_top_entity = crud_call(provider, top_filters)
File "/usr/cisco/packages/python/python-3.6.7/lib/python3.6/contextlib.py", line 99, in __exit__
self.gen.throw(type, value, traceback)
File "/auto/tftp-access-ops/kmat/release/PY367_Y84/rhel7-PY367_Y84/lib/python3.6/site-packages/ydk/errors/error_handler.py", line 82, in handle_runtime_error
_raise(_exc)
File "/auto/tftp-access-ops/kmat/release/PY367_Y84/rhel7-PY367_Y84/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: YCodecError:Unknown element "lldp".. Path:
>>> quit()

 

Model files downloaded with gNMIServiceProvider:
(rhel7-PY367_Y84) kmathiya@kulambi ~/.ydk > ls /users/kmathiya/.ydk/6.15.42.191/
ietf-netconf@2011-06-01.yang

ydk@2016-02-26.yang
(rhel7-PY367_Y84) kmathiya@kulambi ~/.ydk > rm -rf *
(rhel7-PY367_Y84) kmathiya@kulambi ~/.ydk > ls

 

Connecting via NetconfServiceProvider:

(rhel7-PY367_Y84) kmathiya@kulambi ~/.ydk > python
Python 3.6.7 (v3.6.7:6ec5cf2, Oct 24 2018, 15:53:56)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from ydk.providers import NetconfServiceProvider
>>> import os
>>> from ydk.path import Repository
>>> repository = Repository()
>>> from ydk.providers import NetconfServiceProvider
>>> import os
>>> from ydk.path import Repository
>>>
>>> repository = Repository()
>>> from ydk.models.cisco_ios_xr import Cisco_IOS_XR_ptp_oper
>>> tmp=Cisco_IOS_XR_ptp_oper.Ptp.Dataset.DefaultDs()
>>> from ydk.providers import NetconfServiceProvider
>>> Provider = NetconfServiceProvider(address="6.15.42.191", username="cafyauto",password="cisco123")
>>>
>>> from ydk.services import CRUDService
>>> crud = CRUDService()
>>> crud.read(Provider,tmp)
>>> from ydk.models.cisco_ios_xr import Cisco_IOS_XR_ethernet_lldp_cfg as xr_ethernet_lldp_cfg
>>> lldp = xr_ethernet_lldp_cfg.Lldp()
>>> lldp.enable = True
>>> lldp.enable_subintf = True
>>> crud.read(Provider,lldp)
<ydk.models.cisco_ios_xr.Cisco_IOS_XR_ethernet_lldp_cfg.Lldp object at 0x2b0fb78eee60>
>>> quit()

 

Model files downloaded with NetconfServiceProvider:

(rhel7-PY367_Y84) kmathiya@kulambi ~/.ydk > ls /users/kmathiya/.ydk/6.15.42.191/
Cisco-IOS-XR-ethernet-lldp-cfg.yang

Cisco-IOS-XR-ptp-oper-sub1@2020-02-06.yang

Cisco-IOS-XR-types.yang ietf-netconf@2011-06-01.yang
Cisco-IOS-XR-ifmgr-cfg.yang

Cisco-IOS-XR-ptp-oper.yang

cisco-semver.yang ydk@2016-02-26.yang

 

Packages info:

ydk 0.8.4
ydk-models-cisco-ios-xr 7.3.1
ydk-models-cisco-thinxr-install 6.5.1
ydk-models-ietf 0.1.5.post2
ydk-models-openconfig 0.1.6.post1
ydk-service-gnmi 0.4.0.post4

 

(rhel7-PY367_Y84) kmathiya@kulambi ~/.ydk > yum info libydk_gnmi
Loaded plugins: fastestmirror, langpacks, priorities
Loading mirror speeds from cached hostfile
* base: packages.oit.ncsu.edu
* centos-sclo-rh: ftp.ussg.iu.edu
* centos-sclo-sclo: mirror.atlantic.net
* epel: packages.oit.ncsu.edu
* extras: mirror.net.cen.ct.gov
* updates: mirrors.usinternet.com
Installed Packages
Name : libydk_gnmi
Arch : x86_64
Version : 0.4.0
Release : 4
Size : 3.7 M
Repo : installed
From repo : /libydk_gnmi-0.4.0-4.x86_64
Summary : YDK gNMI Library
URL : https://github.com/CiscoDevNet/ydk-cpp
License : Apache 2.0
Description : YDK library to support gNMI services.
: It must be installed on top of core YDK package.

 

Adding debug enabled logs:

provider=gNMIServiceProvider(repo=repository,address="6.15.42.191",port=57400,username="cafyauto",password="cisco123")
Path where models are to be downloaded: /users/kmathiya/.ydk/6.15.42.191/6.15.42.191
gNMIServiceProvider Connected to 6.15.42.191via Insecure Channel
>>> crud.read(provider,lldp)
Executing CRUD read operation on [Cisco-IOS-XR-ethernet-lldp-cfg:lldp]

=============== Get Request Sent ================
path {
origin: "Cisco-IOS-XR-ethernet-lldp-cfg"
elem {
name: "lldp"
}
}
encoding: JSON_IETF



============= Get Response Received =============
notification {
timestamp: 1595337648393238815
update {
path {
origin: "Cisco-IOS-XR-ethernet-lldp-cfg"
elem {
name: "lldp"
}
}
val {
json_ietf_val: "{\"enable\":true,\"enable-subintf\":true}"
}
}
}
error {
}


Get Operation Succeeded
Cannot find model with module name 'Cisco-IOS-XR-ethernet-lldp-cfg'
Data is invalid according to the yang model. Libyang error: Data model "Cisco-IOS-XR-ethernet-lldp-cfg" not found.
Data is invalid according to the yang model. Libyang error: Unknown element "lldp".
Parsing failed with message Unknown element "lldp".
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/auto/tftp-access-ops/kmat/release/PY367_Y84/rhel7-PY367_Y84/lib/python3.6/site-packages/ydk/services/crud_service.py", line 60, in read
return _crud_read(provider, read_filter, False, self._crud.read)
File "/auto/tftp-access-ops/kmat/release/PY367_Y84/rhel7-PY367_Y84/lib/python3.6/site-packages/ydk/services/crud_service.py", line 88, in _crud_read
read_top_entity = crud_call(provider, top_filters)
File "/usr/cisco/packages/python/python-3.6.7/lib/python3.6/contextlib.py", line 99, in __exit__
self.gen.throw(type, value, traceback)
File "/auto/tftp-access-ops/kmat/release/PY367_Y84/rhel7-PY367_Y84/lib/python3.6/site-packages/ydk/errors/error_handler.py", line 82, in handle_runtime_error
_raise(_exc)
File "/auto/tftp-access-ops/kmat/release/PY367_Y84/rhel7-PY367_Y84/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: YCodecError:Unknown element "lldp".. Path:
>>> quit()

 

Thanks,

Kousalya

1 Accepted Solution

Accepted Solutions

yangorelik
Spotlight
Spotlight

Hi Kousalya

This is expected behavior. The ptotobuf 0.4.0 implemented in YDK (Same in IOS XR) does not provides means to download YANG models on demand like it is done in Netconf. This is why it is user's responsibility to provide for gNMEServiceProvider a repository, which contains complete set of YANG models.

In my test environment I run the script with NetconfServiceProvider first. That will download to temporary repository all required for completeness YANG modules. Then I would change the provider to gNMIServiceProvider specifying the directory of just downloaded YANG models as a repository.

Yan Gorelik
YDK Solutions

View solution in original post

2 Replies 2

yangorelik
Spotlight
Spotlight

Hi Kousalya

This is expected behavior. The ptotobuf 0.4.0 implemented in YDK (Same in IOS XR) does not provides means to download YANG models on demand like it is done in Netconf. This is why it is user's responsibility to provide for gNMEServiceProvider a repository, which contains complete set of YANG models.

In my test environment I run the script with NetconfServiceProvider first. That will download to temporary repository all required for completeness YANG modules. Then I would change the provider to gNMIServiceProvider specifying the directory of just downloaded YANG models as a repository.

Yan Gorelik
YDK Solutions

Hi Yan,

Thanks a lot for your time and support !!

I have tried copying all models directly from device to a local repository and established gNMIServiceProvider.  Able to connect successfully and proceed without any error.

 

Thanks,

Kousalya