cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2388
Views
3
Helpful
13
Replies

Unable to run hello-ydk.py

rakesh.hegde
Level 1
Level 1

I am having trouble running the hello-ydk.py example. Below is the error. Any suggestions ?

--------

/ydk-gen/gen-api/python/ydk/samples$ ./hello-ydk.py

2018-03-14 00:09:32,490 - ydk - DEBUG - Trace: Password authentication (host 172.20.254.231, user admin1)

2018-03-14 00:09:32,640 - ydk - DEBUG - Trace: Writing message (session ): <?xml version="1.0" encoding="UTF-8"?>

<hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">

  <capabilities>

    <capability>urn:ietf:params:netconf:base:1.0</capability>

    <capability>urn:ietf:params:netconf:base:1.1</capability>

    <capability>urn:ietf:params:netconf:capability:writable-running:1.0</capability>

    <capability>urn:ietf:params:netconf:capability:candidate:1.0</capability>

    <capability>urn:ietf:params:netconf:capability:startup:1.0</capability>

    <capability>urn:ietf:params:netconf:capability:rollback-on-error:1.0</capability>

  </capabilities>

</hello>

2018-03-14 00:09:32,782 - ydk - DEBUG - Trace: Received message (session ): <hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">

<capabilities>

  <capability>urn:ietf:params:netconf:base:1.1</capability>

  <capability>urn:ietf:params:netconf:capability:candidate:1.0</capability>

  <capability>urn:ietf:params:netconf:capability:rollback-on-error:1.0</capability>

  <capability>urn:ietf:params:netconf:capability:validate:1.1</capability>

  <capability>urn:ietf:params:netconf:capability:confirmed-commit:1.1</capability>

  <capability>http://cisco.com/ns/yang/Cisco-IOS-XR-aaa-lib-cfg?module=Cisco-IOS-XR-aaa-lib-cfg&revision=2015-11-09</capability>

  <capability>http://cisco.com/ns/yang/Cisco-IOS-XR-aaa-locald-admin-cfg?module=Cisco-IOS-XR-aaa-locald-admin-cfg&revision=2015-11-09</capability>

  <capability>http://cisco.com/ns/yang/Cisco-IOS-XR-aaa-locald-cfg?module=Cisco-IOS-XR-aaa-locald-cfg&revision=2015-11-09</capability>

  <capability>http://cisco.com/ns/yang/Cisco-IOS-XR-aaa-locald-oper?module=Cisco-IOS-XR-aaa-locald-oper&revision=2015-11-09</capability>

  <capability>http://cisco.com/ns/yang/Cisco-IOS-XR-aaa-protocol-radius-cfg?module=Cisco-IOS-XR-aaa-protocol-radius-cfg&revision=2015-11-09</capability>

  <capability>http://cisco.com/ns/yang/Cisco-IOS-XR-aaa-protocol-radius-oper?module=Cisco-IOS-XR-aaa-protocol-radius-oper&revision=2015-11-09</capability>

  <capability>http://cisco.com/ns/yang/Cisco-IOS-XR-aaa-tacacs-cfg?module=Cisco-IOS-XR-aaa-tacacs-cfg&revision=2015-11-09</capability>

  <capability>http://cisco.com/ns/yang/Cisco-IOS-XR-aaa-tacacs-oper?module=Cisco-IOS-XR-aaa-tacacs-oper&revision=2015-11-09</capability>

  <capability>http://cisco.com/ns/yang/Cisco-IOS-XR-bundlemgr-cfg?module=Cisco-IOS-XR-bundlemgr-cfg&revision=2016-05-12</capability>

  <capability>http://cisco.com/ns/yang/Cisco-IOS-XR-bundlemgr-oper?module=Cisco-IOS-XR-bundlemgr-oper&revision=2015-11-09</capability>

  <capability>http://cisco.com/ns/yang/Cisco-IOS-XR-cdp-cfg?module=Cisco-IOS-XR-cdp-cfg&revision=2015-07-30</capability>

  <capability>http://cisco.com/ns/yang/Cisco-IOS-XR-cdp-oper?module=Cisco-IOS-XR-cdp-oper&revision=2015-07-30</capability>

  <capability>http://cisco.com/ns/yang/Cisco-IOS-XR-cfgmgr-rollback-act?module=Cisco-IOS-XR-cfgmgr-rollback-act&revision=2016-04-17</capability>

  <capability>http://cisco.com/ns/yang/Cisco-IOS-XR-clns-isis-cfg?module=Cisco-IOS-XR-clns-isis-cfg&revision=2015-11-09</capability>

  <capability>http://cisco.com/ns/yang/Cisco-IOS-XR-clns-isis-datatypes?module=Cisco-IOS-XR-clns-isis-datatypes&revision=2015-11-09</capability>

  <capability>http://cisco.com/ns/yang/Cisco-IOS-XR-clns-isis-oper?module=Cisco-IOS-XR-clns-isis-oper&revision=2015-11-09</capability>

  <capability>http://cisco.com/ns/yang/Cisco-IOS-XR-common-acl-datatypes?module=Cisco-IOS-XR-common-acl-datatypes&revision=2015-11-09</capability>

  <capability>http://cisco.com/ns/yang/Cisco-IOS-XR-config-cfgmgr-exec-oper?module=Cisco-IOS-XR-config-cfgmgr-exec-oper&revision=2015-11-09</capability>

  <capability>http://cisco.com/ns/yang/Cisco-IOS-XR-config-mda-cfg?module=Cisco-IOS-XR-config-mda-cfg&revision=2015-11-09</capability>

  <capability>http://cisco.com/ns/yang/Cisco-IOS-XR-config-mibs-cfg?module=Cisco-IOS-XR-config-mibs-cfg&revision=2015-01-07</capability>

  <capability>http://cisco.com/ns/yang/Cisco-IOS-XR-controller-optics-cfg?module=Cisco-IOS-XR-controller-optics-cfg&revision=2015-11-09</capability>

  <capability>http://cisco.com/ns/yang/Cisco-IOS-XR-controller-optics-oper?module=Cisco-IOS-XR-controller-optics-oper&revision=2015-11-09</capability>

  <capability>http://cisco.com/ns/yang/Cisco-IOS-XR-controller-otu-cfg?module=Cisco-IOS-XR-controller-otu-cfg&revision=2015-11-09</capability>

  <capability>http://cisco.com/ns/yang/Cisco-IOS-XR-controller-otu-oper?module=Cisco-IOS-XR-controller-otu-oper&revision=2015-11-09</capability>

  <capability>http://cisco.com/ns/yang/Cisco-IOS-XR-crypto-sam-cfg?module=Cisco-IOS-XR-crypto-sam-cfg&revision=2015-01-07</capability>

  <capability>http://c

2018-03-14 00:09:32,786 - ydk - INFO - Path where models are to be downloaded: /home/lab/.ydk/172.20.254.231_830

2018-03-14 00:09:32,786 - ydk - DEBUG - Creating libyang context in path: /home/lab/.ydk/172.20.254.231_830

2018-03-14 00:09:32,786 - ydk - DEBUG - Debug: Extension plugin "/usr/local/lib/libyang/libyang_ext_test.so" successfully loaded.

2018-03-14 00:09:32,787 - ydk - DEBUG - Debug: Extension plugin "/usr/local/lib/libyang/nacm.so" successfully loaded.

2018-03-14 00:09:32,787 - ydk - DEBUG - Debug: Extension plugin "/usr/local/lib/libyang/metadata.so" successfully loaded.

2018-03-14 00:09:32,788 - ydk - DEBUG - Debug: Reading module "ietf-yang-metadata".

2018-03-14 00:09:32,788 - ydk - DEBUG - Debug: Module "ietf-yang-metadata@2016-08-05" successfully parsed as implemented.

2018-03-14 00:09:32,788 - ydk - DEBUG - Debug: Reading module "yang".

2018-03-14 00:09:32,788 - ydk - DEBUG - Debug: Resolving "yang" unresolved schema nodes and their constraints...

2018-03-14 00:09:32,789 - ydk - DEBUG - Debug: All "yang" schema nodes and constraints resolved.

2018-03-14 00:09:32,789 - ydk - DEBUG - Debug: Module "yang@2017-02-20" successfully parsed as implemented.

2018-03-14 00:09:32,790 - ydk - DEBUG - Debug: Reading module "ietf-inet-types".

2018-03-14 00:09:32,790 - ydk - DEBUG - Debug: Resolving derived type "union" failed, it will be attempted later.

2018-03-14 00:09:32,790 - ydk - DEBUG - Debug: Resolving derived type "union" failed, it will be attempted later.

2018-03-14 00:09:32,790 - ydk - DEBUG - Debug: Resolving derived type "union" failed, it will be attempted later.

2018-03-14 00:09:32,791 - ydk - DEBUG - Debug: Resolving derived type "union" failed, it will be attempted later.

2018-03-14 00:09:32,791 - ydk - DEBUG - Debug: Resolving "ietf-inet-types" unresolved schema nodes and their constraints...

2018-03-14 00:09:32,791 - ydk - DEBUG - Debug: All "ietf-inet-types" schema nodes and constraints resolved.

2018-03-14 00:09:32,791 - ydk - DEBUG - Debug: Module "ietf-inet-types@2013-07-15" successfully parsed as implemented.

2018-03-14 00:09:32,792 - ydk - DEBUG - Debug: Reading module "ietf-yang-types".

2018-03-14 00:09:32,793 - ydk - DEBUG - Debug: Module "ietf-yang-types@2013-07-15" successfully parsed as implemented.

2018-03-14 00:09:32,793 - ydk - DEBUG - Debug: Reading module "ietf-datastores".

2018-03-14 00:09:32,793 - ydk - DEBUG - Debug: Module "ietf-datastores@2017-08-17" successfully parsed as implemented.

2018-03-14 00:09:32,794 - ydk - DEBUG - Debug: Reading module "ietf-yang-library".

2018-03-14 00:09:32,795 - ydk - DEBUG - Debug: Module "ietf-yang-library@2017-08-17" successfully parsed as implemented.

2018-03-14 00:09:32,795 - ydk - DEBUG - Loading Module 'ydk' Revision '2016-02-26'

2018-03-14 00:09:32,795 - ydk - DEBUG - Getting module ydk submodule none

2018-03-14 00:09:32,796 - ydk - DEBUG - Looking for file in folder: /home/lab/.ydk/172.20.254.231_830

2018-03-14 00:09:32,796 - ydk - DEBUG - Opening file /home/lab/.ydk/172.20.254.231_830/ydk@2016-02-26.yang

2018-03-14 00:09:32,796 - ydk - DEBUG - Path found with rev: true. Path without rev: false

2018-03-14 00:09:32,798 - ydk - DEBUG - Debug: Module "ydk@2016-02-26" successfully parsed as implemented.

2018-03-14 00:09:32,798 - ydk - DEBUG - Loading Module 'ietf-netconf' Revision '2011-06-01'

2018-03-14 00:09:32,798 - ydk - DEBUG - Getting module ietf-netconf submodule none

2018-03-14 00:09:32,798 - ydk - DEBUG - Looking for file in folder: /home/lab/.ydk/172.20.254.231_830

2018-03-14 00:09:32,799 - ydk - DEBUG - Opening file /home/lab/.ydk/172.20.254.231_830/ietf-netconf@2011-06-01.yang

2018-03-14 00:09:32,799 - ydk - DEBUG - Path found with rev: true. Path without rev: false

2018-03-14 00:09:32,801 - ydk - DEBUG - Debug: Module "ietf-netconf@2011-06-01" successfully parsed as implemented.

2018-03-14 00:09:32,801 - ydk - DEBUG - Populating new module schema 'ietf-yang-metadata'

2018-03-14 00:09:32,801 - ydk - DEBUG - Populating new module schema 'yang'

2018-03-14 00:09:32,801 - ydk - DEBUG - Populating new module schema 'ietf-inet-types'

2018-03-14 00:09:32,802 - ydk - DEBUG - Populating new module schema 'ietf-yang-types'

2018-03-14 00:09:32,802 - ydk - DEBUG - Populating new module schema 'ietf-datastores'

2018-03-14 00:09:32,802 - ydk - DEBUG - Populating new module schema 'ietf-yang-library'

2018-03-14 00:09:32,802 - ydk - DEBUG - Populating new module schema 'ydk'

2018-03-14 00:09:32,802 - ydk - DEBUG - Populating new module schema 'ietf-netconf'

2018-03-14 00:09:32,802 - ydk - INFO - Connected to 172.20.254.231 on port 830 using ssh with timeout of -1

2018-03-14 00:09:32,804 - ydk - INFO - Executing CRUD read operation

2018-03-14 00:09:32,804 - ydk - DEBUG - Getting new modules for ydk:read

2018-03-14 00:09:32,804 - ydk - DEBUG - Getting new modules for ydk:read

2018-03-14 00:09:32,804 - ydk - DEBUG - Loading Module 'ydk' Revision ''

2018-03-14 00:09:32,804 - ydk - DEBUG - Cache hit Module 'ydk' Revision ''

2018-03-14 00:09:32,804 - ydk - DEBUG - Encoding the subtree filter request using XML subtree codec

2018-03-14 00:09:32,804 - ydk - DEBUG - Getting new modules for Cisco-IOS-XR-shellutil-oper:system-time

2018-03-14 00:09:32,805 - ydk - DEBUG - Getting new modules for Cisco-IOS-XR-shellutil-oper:system-time

2018-03-14 00:09:32,805 - ydk - DEBUG - Loading Module 'Cisco-IOS-XR-shellutil-oper' Revision ''

2018-03-14 00:09:32,805 - ydk - DEBUG - Getting module Cisco-IOS-XR-shellutil-oper submodule none

2018-03-14 00:09:32,805 - ydk - DEBUG - Looking for file in folder: /home/lab/.ydk/172.20.254.231_830

2018-03-14 00:09:32,805 - ydk - DEBUG - Opening file /home/lab/.ydk/172.20.254.231_830/Cisco-IOS-XR-shellutil-oper.yang

2018-03-14 00:09:32,805 - ydk - DEBUG - Path found with rev: true. Path without rev: false

2018-03-14 00:09:32,805 - ydk - DEBUG - Getting module Cisco-IOS-XR-types submodule none

2018-03-14 00:09:32,806 - ydk - DEBUG - Looking for file in folder: /home/lab/.ydk/172.20.254.231_830

2018-03-14 00:09:32,806 - ydk - DEBUG - Opening file /home/lab/.ydk/172.20.254.231_830/Cisco-IOS-XR-types.yang

2018-03-14 00:09:32,806 - ydk - DEBUG - Path found with rev: true. Path without rev: false

2018-03-14 00:09:32,806 - ydk - ERROR - Data is invalid according to the yang model. Error details: Invalid keyword "[0-9]|25[0-5])\.){3}([1-9]?[0-9]|1[0-9][0-9]|2[0-4][0-9]"".

2018-03-14 00:09:32,806 - ydk - ERROR - Data is invalid according to the yang model. Error details: Module "Cisco-IOS-XR-types" parsing failed.

2018-03-14 00:09:32,807 - ydk - ERROR - Data is invalid according to the yang model. Error details: Importing "Cisco-IOS-XR-types" module into "Cisco-IOS-XR-shellutil-oper" failed.

2018-03-14 00:09:32,807 - ydk - ERROR - Data is invalid according to the yang model. Error details: Module "Cisco-IOS-XR-shellutil-oper" parsing failed.

2018-03-14 00:09:32,807 - ydk - DEBUG - Looking to populate schemas for Cisco-IOS-XR-shellutil-oper:system-time

2018-03-14 00:09:32,807 - ydk - DEBUG - Ready to populate schemas for Cisco-IOS-XR-shellutil-oper:system-time

2018-03-14 00:09:32,807 - ydk - DEBUG - Getting new modules for Cisco-IOS-XR-shellutil-oper:system-time

2018-03-14 00:09:32,807 - ydk - DEBUG - Getting new modules for Cisco-IOS-XR-shellutil-oper:system-time

2018-03-14 00:09:32,807 - ydk - DEBUG - Loading Module 'Cisco-IOS-XR-shellutil-oper' Revision ''

2018-03-14 00:09:32,807 - ydk - DEBUG - Getting module Cisco-IOS-XR-shellutil-oper submodule none

2018-03-14 00:09:32,807 - ydk - DEBUG - Looking for file in folder: /home/lab/.ydk/172.20.254.231_830

2018-03-14 00:09:32,808 - ydk - DEBUG - Opening file /home/lab/.ydk/172.20.254.231_830/Cisco-IOS-XR-shellutil-oper.yang

2018-03-14 00:09:32,808 - ydk - DEBUG - Path found with rev: true. Path without rev: false

2018-03-14 00:09:32,808 - ydk - DEBUG - Getting module Cisco-IOS-XR-types submodule none

2018-03-14 00:09:32,808 - ydk - DEBUG - Looking for file in folder: /home/lab/.ydk/172.20.254.231_830

2018-03-14 00:09:32,808 - ydk - DEBUG - Opening file /home/lab/.ydk/172.20.254.231_830/Cisco-IOS-XR-types.yang

2018-03-14 00:09:32,808 - ydk - DEBUG - Path found with rev: true. Path without rev: false

2018-03-14 00:09:32,809 - ydk - ERROR - Data is invalid according to the yang model. Error details: Invalid keyword "[0-9]|25[0-5])\.){3}([1-9]?[0-9]|1[0-9][0-9]|2[0-4][0-9]"".

2018-03-14 00:09:32,809 - ydk - ERROR - Data is invalid according to the yang model. Error details: Module "Cisco-IOS-XR-types" parsing failed.

2018-03-14 00:09:32,809 - ydk - ERROR - Data is invalid according to the yang model. Error details: Importing "Cisco-IOS-XR-types" module into "Cisco-IOS-XR-shellutil-oper" failed.

2018-03-14 00:09:32,809 - ydk - ERROR - Data is invalid according to the yang model. Error details: Module "Cisco-IOS-XR-shellutil-oper" parsing failed.

2018-03-14 00:09:32,809 - ydk - DEBUG - Looking to populate schemas for

2018-03-14 00:09:32,809 - ydk - DEBUG - Ready to populate schemas for

2018-03-14 00:09:32,810 - ydk - DEBUG - Getting new modules for

2018-03-14 00:09:32,810 - ydk - DEBUG - Getting new modules for

2018-03-14 00:09:32,810 - ydk - DEBUG - Creating root data node with path '/Cisco-IOS-XR-shellutil-oper:system-time'

2018-03-14 00:09:32,810 - ydk - ERROR - Data is invalid according to the yang model. Error details: Module not found. Path: '/Cisco-IOS-XR-shellutil-oper'

2018-03-14 00:09:32,810 - ydk - ERROR - Path 'Cisco-IOS-XR-shellutil-oper:system-time' is invalid

Traceback (most recent call last):

  File "./hello-ydk.py", line 30, in <module>

    system_time = crud.read(provider,system_time)

  File "/home/lab/.virtualenvs/ydk-gen/local/lib/python2.7/site-packages/ydk/errors/error_handler.py", line 112, in helper

    return func(self, provider, entity, *args, **kwargs)

  File "/home/lab/.virtualenvs/ydk-gen/local/lib/python2.7/site-packages/ydk/services/crud_service.py", line 35, in read

    return self._crud.read(provider, read_filter)

  File "/usr/lib/python2.7/contextlib.py", line 35, in __exit__

    self.gen.throw(type, value, traceback)

  File "/home/lab/.virtualenvs/ydk-gen/local/lib/python2.7/site-packages/ydk/errors/error_handler.py", line 82, in handle_runtime_error

    _raise(_exc)

  File "/home/lab/.virtualenvs/ydk-gen/local/lib/python2.7/site-packages/ydk/errors/error_handler.py", line 56, in _raise

    raise exc

ydk.errors.YPYInvalidArgumentError:  Path is invalid: Cisco-IOS-XR-shellutil-oper:system-time

2018-03-14 00:09:32,815 - ydk - INFO - Disconnected from device

2018-03-14 00:09:32,817 - ydk - DEBUG - Trace: Writing message (session 28059853): <?xml version="1.0" encoding="UTF-8"?>

<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1">

  <close-session/>

</rpc>

2018-03-14 00:09:33,048 - ydk - DEBUG - Trace: Received message (session 28059853): <?xml version="1.0"?>

<rpc-reply message-id="1" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">

<ok/>

</rpc-reply>

13 Replies 13

saalvare
Cisco Employee
Cisco Employee

What version of IOS XR are you using?  What version of YDK and the XR module bundle are you using? (pip list | grep ydk)

Hi Santiago,

I am using IOS XR  virtual router  6.1.2  and  ydk 0.7.0

ydk-gen$ pip list | grep ydk

ydk (0.7.0)

ydk-models-cisco-ios-xr (6.3.1)

ydk-models-ietf (0.1.4)

ydk-models-openconfig (0.1.4)

ydk-gen$

-Rakesh

I have verified that any sample .py file that uses Cisco-IOS-XR-types.yang file fails with the same error.

ydk - ERROR - Data is invalid according to the yang model. Error details: Invalid keyword "[0-9]|25[0-5])\.){3}([1-9]?[0-9]|1[0-9][0-9]|2[0-4][0-9]"". ydk - ERROR - Data is invalid according to the yang model. Error details: Module "Cisco-IOS-XR-types" parsing failed.


It looks like the yang parser in ydk-gen is not processing the contents of Cisco-IOS-XR-types.yang  properly. Also, this is an issue only when I use python bundle created using ydk-gen. Everything works fine on ydk-py that I am running on a different machine.

Rakesh hegde R wrote:

It looks like the yang parser in ydk-gen is not processing the contents of Cisco-IOS-XR-types.yang  properly. Also, this is an issue only when I use python bundle created using ydk-gen. Everything works fine on ydk-py that I am running on a different machine.

ydk-py is generated using the ydk-gen generator tool. Can you please let me know the full steps you took to generate the python bundle using ydk-gen? Which yang models are you using?

Also, let me know the output of the below for your ydk-gen repository:

  git log -1 

This can be helpful to understand which version of ydk-gen is being used.

Also, which version of ydk-py are you using (pip list|grep ydk)?

Hi,  Below are the steps .

sudo apt install python-pip

pip install virtualenv

pip install virtualenvwrapper

mkdir ~/.virtualenvs

export WORKON_HOME=~/.virtualenvs

export PROJECT_HOME=~/projects

source /usr/local/bin/virtualenvwrapper.sh

mkproject -p python2.7 ydk-gen

sudo apt-get install gdebi-core python3-dev python-dev libtool-bin

wget https://devhub.cisco.com/artifactory/debian-ydk/0.7.0/libydk_0.7.0-1_amd64.deb

sudo gdebi libydk_0.7.0-1_amd64.deb

sudo apt-get install libcurl4-openssl-dev libpcre3-dev libssh-dev libxml2-dev libxslt1-dev libtool-bin cmake python3-dev python-dev

git clone https://github.com/CiscoDevNet/ydk-gen.git

cd ydk-gen

pip install -r requirements.txt

  ./generate.py --cpp --core

cd gen-api/cpp/ydk/build

  make && sudo make install

cd ydk-gen

./generate.py --python --core

pip install gen-api/python/ydk/dist/ydk*.tar.gz

./generate.py --python --bundle profiles/bundles/ietf_0_1_4.json

pip install gen-api/python/ietf-bundle/dist/ydk*.tar.gz

./generate.py --python --bundle profiles/bundles/openconfig_0_1_4.json

pip install gen-api/python/openconfig-bundle/dist/ydk*.tar.gz

./generate.py --python --bundle profiles/bundles/cisco-ios-xr_6_3_1.json

pip install gen-api/python/cisco_ios_xr-bundle/dist/ydk*.tar.gz

----

(ydk-gen) lab@odl-02:~/projects/ydk-gen/ydk-gen/gen-api/python$ pip list | grep ydk

DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.

ydk (0.7.0)

ydk-models-cisco-ios-xr (6.3.1)

ydk-models-ietf (0.1.4)

ydk-models-openconfig (0.1.4)

(ydk-gen) lab@odl-02:~/projects/ydk-gen/ydk-gen/gen-api/python$

-----

(ydk-gen) lab@odl-02:~/projects/ydk-gen/ydk-gen/gen-api/python$ git log -1

commit 6172a9a09849063a9836bba62e24776d4c2f8cfe

Merge: 01689ee 8b26d0d

Author: Abhi Keshav <abhirame@cisco.com>

Date:   Thu Mar 15 21:47:12 2018 -0400

    Merge pull request #713 from ygorelik/master

    Introduced multiple entities in filter for CRUD and Netconf dervices

(ydk-gen) lab@odl-02:~/projects/ydk-gen/ydk-gen/gen-api/python$

-----

Below is the pip output for  the ydk-py environment that works.

(ydk-py) lab@odl-02:~$ pip list | grep ydk

DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.

ydk (0.7.0)

ydk-models-cisco-ios-xr (6.3.1)

ydk-models-ietf (0.1.4)

ydk-models-openconfig (0.1.4)

(ydk-py) lab@odl-02:~$

Independent of the issue you're experiencing right now, take into account that hello-ydk.py is currently impacted by this issue:

https://github.com/CiscoDevNet/ydk-gen/issues/604

The following changes can be used as a workaround:

user@host:ydk-py-samples/(master *$%=)$ git diff hello-ydk.py

diff --git a/hello-ydk.py b/hello-ydk.py

index aed1b4d..9ffd9aa 100755

--- a/hello-ydk.py

+++ b/hello-ydk.py

@@ -47,7 +47,7 @@ if __name__ == "__main__":

     # print system uptime

     print("System uptime is " +

-          str(timedelta(seconds=system_time.uptime.uptime)))

+          str(timedelta(seconds=int(str(system_time.uptime.uptime)))))

     exit()

# End of script

user@host:ydk-py-samples/(master *$%=)$

The fix for this issue should be made available in our next release (0.7.1).

Strange. Not able to reproduce this with the latest ydk-gen code. Maybe the issue is the below two lines?

wget https://devhub.cisco.com/artifactory/debian-ydk/0.7.0/libydk_0.7.0-1_amd64.deb

sudo gdebi libydk_0.7.0-1_amd64.deb

Can you try removing this package?

sudo apt-get remove libydk

I tried the suggestion form saalvaresaalvareit works for me. (on ubuntu 4.13.0-37)

tried with no luck.

I then installed ydk-gen  on a brand new ubuntu 16.04.4 server, but got the same error.

Error details: Invalid keyword "[0-9]|25[0-5])\.){3}([1-9]?[0-9]|1[0-9][0-9]|2[0-4][0-9]"". ydk - ERROR - Data is invalid according to the yang model. Error details: Module "Cisco-IOS-XR-types" parsing failed.


Could it be that the parser  is seeing two double quotes after [0-9] in the regex for some reason?  The Cisco-IOS-XR-types.yang file has only one double quote.

-Rakesh.

Any reason why you're not using the generated Python packages in this case?

The parser is the same for both ydk-py and ydk-gen. YDK uses a third party tool called libyang. I am not able to reproduce this issue using the libyang tool. Not sure why you are facing this issue

Sorry for the late reply. On further investigation, it looks like the XR 6.1.2 model has an invalid pattern using double quotes, which is causing the error you are seeing. This was fixed in the 621 model where it was changed to use single quote. This means the issue should be fixed if you use a XR 612 or newer device after clearing the cache (rm -rf ~/.ydk).

I was using Python3

@ubuntu:~/ydk-py-samples$ pip3 list | grep ydk

DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.

ydk (0.7.0)

ydk-models-cisco-ios-xe (16.7.1)

ydk-models-cisco-ios-xr (6.3.1)

ydk-models-ietf (0.1.4)

ydk-models-openconfig (0.1.4)

P/0/0/CPU0:iosxrv532-2#sh ver

Wed Mar 21 18:53:30.088 UTC

Cisco IOS XR Software, Version 5.3.2[Default]

Copyright (c) 2015 by Cisco Systems, Inc.

ROM: GRUB, Version 1.99(0), DEV RELEASE

iosxrv532-2 uptime is 38 weeks, 3 days, 3 hours, 8 minutes

System image file is "bootflash:disk0/xrvr-os-mbi-5.3.2/mbixrvr-rp.vm"

@ubuntu:~/ydk-py-samples$ ./hello-ydk.py

System uptime is 269 days, 3:06:17

``````````````````

# import providers, services and models

from ydk.services import CRUDService

from ydk.providers import NetconfServiceProvider

from ydk.models.cisco_ios_xr import Cisco_IOS_XR_shellutil_oper \

    as xr_shellutil_oper

from datetime import timedelta



if __name__ == "__main__":

    """Main execution path"""


    # create NETCONF session

    provider = NetconfServiceProvider(address="xxx.xxx.xxx.xxx",

                                      port=830,

                                      username="xxxx",

                                      password="xxxx",

                                      protocol="ssh")

    # create CRUD service

    crud = CRUDService()


    # create system time object

    system_time = xr_shellutil_oper.SystemTime()


    # read system time from device

    system_time = crud.read(provider, system_time)


    # print system uptime

    print("System uptime is " +

          # str(timedelta(seconds=system_time.uptime.uptime)))

          str(timedelta(seconds=int(str(system_time.uptime.uptime))))) 


    exit()

# End of script