cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
674
Views
0
Helpful
3
Replies

YDK-GEN Libyang error seen in generated Cisco-ios-xr packages

kmathiya
Cisco Employee
Cisco Employee

Hi Team,

I have compiled models of version 7.3.1 16I in ENV (Python 3.6.7, YDK 0.8.4, Pyang 1.6)

Generated cisco-ios-xr bundle successfully and installed the same.

Issue 1 :

But I am getting Libyang errors with few models of version (7.3.1 16I), Whereas the same models of same version(7.3.1 16I) works fine when compiled and ran with ENV(Python 3.5, YDK0.5.5, Pyang 1.6) (All CRUD operations are executed w/o model/schema error and thereby config is pushed into device).

Note : Version of both compiled model and device model is same. So I hope there is no diff to lead schema mismatch.

 

Issue 2 :

Also I can see deviation files are missing in created bundle with ENV (python 3.6.7, YDK 0.8.4, Pyang 1.6), though all the deviation models are added in the yang folder to be compiled. Is this something creating libyang errors?

ls /auto/tftp-access-ops/cafy_ydk0.8.3/env3.6.7/lib/python3.6/site-packages/ydk/models/
__init__.py cisco_ios_xr cisco_thinxr_install ietf openconfig openconfig_network_instance

 

Could you please help me to resolve this discrepancy?

 

Steps followed to compile models with 0.8.4:

Step 1 :

Sourced the ENV (python 3.6.7, YDK 0.8.4, Pyang 1.6) and copied all yang models(which includes openconfig, ietf, cisco-ios-xr, devaiation files) to location ~yang/731_16I/

Step 2 :

Checked for PYANG errors and resolved if any.

Step 3 :

 Update file profiles/bundles/cisco-ios-xr_7_3_1I.json as below,

 Note: I didnt add any dependency of ietf/openconfig since i added all models under same folder and compiled all together as a cisco-ios-xr bundle.

{

  "name": "cisco-ios-xr",

  "version": "7.2.1", >>> change version

  "core_version": "0.5.5",

  "author": "Cisco",

  "copyright": "Cisco",

  "description": "YDK bundle for Cisco IOS XR models",

  "long_description": "This YANG Development Kit (YDK) bundle provides APIs for Cisco IOS XR YANG models.",

  "models": {

    "dir": [

        "yang/PROD_BUILD_7_3_1_07I" >>> Change new Yang path

    ]

  }

}

Step 4 :

Compile using command ./generate.py --bundle profiles/bundles/cisco-ios-xr_7_3.1.json --python -i

 

Snapshot of few libyang errors(same model works well with ydk 0.5.5),

Error 1:

2020-07-27 13:24:20,639 - ydk - Debug--- - Creating new data path 'source-address' with value '2404:6800:4000::/37' in 'config'
Debug---:ydk:Creating new data path 'source-address' with value '2404:6800:4000::/37' in 'config'
2020-07-27 13:24:20,640 - ydk - Error--- - Data is invalid according to the yang model. Libyang error: Value "2404:6800:4000::/37" does not satisfy the constraint "^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))/(12[0-8]|1[0-1][0-9]|[1-9][0-9]|[0-9])$" (range, length, or pattern). Path: '/openconfig-acl:acl/acl-sets/acl-set[name='config008'][type='openconfig-acl:ACL_IPV6']/acl-entries/acl-entry[sequence-id='10']/ipv6/config/source-address'
2020-07-27 13:24:20,640 - ydk - Error--- - Data is invalid according to the yang model. Libyang error: Value "2404:6800:4000::/37" does not satisfy the constraint "^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))/(12[0-8]|1[0-1][0-9]|[1-9][0-9]|[0-9])$" (range, length, or pattern). Path: '/openconfig-acl:acl/acl-sets/acl-set[name='config008'][type='openconfig-acl:ACL_IPV6']/acl-entries/acl-entry[sequence-id='10']/ipv6/config/source-address'
Error---:ydk:Data is invalid according to the yang model. Libyang error: Value "2404:6800:4000::/37" does not satisfy the constraint "^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))/(12[0-8]|1[0-1][0-9]|[1-9][0-9]|[0-9])$" (range, length, or pattern). Path: '/openconfig-acl:acl/acl-sets/acl-set[name='config008'][type='openconfig-acl:ACL_IPV6']/acl-entries/acl-entry[sequence-id='10']/ipv6/config/source-address'

 

Error 2:

Error---:ydk:Data is invalid according to the yang model. Libyang error: Invalid value "" in "frequency-priority" element. Path: '/Cisco-IOS-XR-ptp-cfg:ptp/frequency-priority'
*** ydk.errors.YModelError: Invalid value "" in "frequency-priority" element. Path: /Cisco-IOS-XR-ptp-cfg:ptp/frequency-priority

 

Error 3:

Error---:ydk:Data is invalid according to the yang model. Libyang error: Invalid value "install-replace" in "available-action" element. Path: '/Cisco-IOS-XR-install-augmented-oper:install/request/verbose/available-actions/available-action[.='install-replace']

Thanks,

Kousalya

3 Replies 3

yangorelik
Spotlight
Spotlight

Hi Kousalya

Issue_1

You cannot compare YDK 0.5.5. and 0.8.x, because they have different basis and therefore generate different bundle code.

Issue_2

You need recompile and install YDK from source. The latest YDK-0.8.5 is in the master branch and available for installation from source (I believe the artifacts currently not available). Here is simple procedure (assuming all dependencies have already been satisfied):

git clone https://github.com/CiscoDevNet/ydk-gen.git
cd ydk-gen
# enable Python3 virtual environment
pip install -r requirements.txt
python generate.py --core --cpp -is # needs sudo access for installation
python generate.py --core --py -i
# if gNMI service needed
python generate.py --service profiles/services/gnmi-0.4.0.json --cpp -is # needs sudo access
python generate.py --service profiles/services/gnmi-0.4.0.json --py -i

  Good luck!

Yan Gorelik
YDK Solutions

Hi Yan,
Thanks for the steps. It has helped me build and install YDK core successfully.
But with one server I am still facing libyang error aa below,

>>> Provider = NetconfServiceProvider(address="7.30.13.56", username="root",password="root123")
2020-08-03 12:10:01,100 - ydk - INFO - Path where models are to be downloaded: /users/kmathiya/.ydk/7.30.13.56
2020-08-03 12:10:01,100 - ydk - INFO - Path where models are to be downloaded: /users/kmathiya/.ydk/7.30.13.56
2020-08-03 12:10:01,101 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Invalid keyword "type" as a child to "annotation". Path: '/'
2020-08-03 12:10:01,101 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Invalid keyword "type" as a child to "annotation". Path: '/'
2020-08-03 12:10:01,101 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "yang" parsing failed.
2020-08-03 12:10:01,101 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "yang" parsing failed.
2020-08-03 12:10:01,102 - ydk - ERROR - Could not create repository in: /users/kmathiya/.ydk/7.30.13.56
2020-08-03 12:10:01,102 - ydk - ERROR - Could not create repository in: /users/kmathiya/.ydk/7.30.13.56

I doubted it could be a yanglint error and tried installing libyang with below steps and set env, but still facing one or other error related to yanglint

git clone https://github.com/CESNET/libyang

cd libyang/

ldconfig

mkdir build; cd build

cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr/local/lib ..

make

make install
export LIBYANG_USER_TYPES_PLUGINS_DIR=/usr/lib64/libyang1/user_types
export LIBYANG_EXTENSIONS_PLUGINS_DIR=/usr/local/lib/bin/yanglint
>>> Provider = NetconfServiceProvider(address="7.30.13.56", username="root",password="root123")
2020-08-03 15:57:57,480 - ydk - INFO - Path where models are to be downloaded: /root/.ydk/7.30.13.56
2020-08-03 15:57:57,492 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Memory allocation failed (resolve_extension()).
2020-08-03 15:57:57,492 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "yang" parsing failed.
2020-08-03 15:57:57,493 - ydk - ERROR - Could not create repository in: /root/.ydk/7.30.13.56

Could you please help with libyang/yanglint installation steps and environment variables and also should I need to run via sudo?
Thanks,
Kousalya

The direct compilation and installation of Libyang from master branch is a mistake, because YDK uses fork repository, which was adopted for the YDK needs and is not compatible with the master repository.

The error that you are getting usually appears when Libyang library is not properly installed under /usr/local/lib/. You need to do the following:

cd ydk-gen
cd gen-api/cpp/ydk/build
sudo make install
cd -
# Set your Python virtual environment
cd gen-api/python/ydk/dist
pip install -U ydk*.tar.gz

Follow the console output to make sure all the steps went with no errors, and all libyang components are replaced!! If not, remove them manually from /usr/local/lib and /usr/local/include, then repeat the steps above.

I assume that you are working on RHEL or Centos platform. That requires proper setting of environment variable LD_LIBRARY_PATH. Make sure it includes path /usr/local/lib. Then you can go back to your script.

NOTE. The YDK-0.8.5 generates different bundle code. So you need to regenerate the bundles, which were built with 0.8.4.

Yan Gorelik
YDK Solutions