Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Path API create_datanode rejects valid value #1006

Closed
tdesh10 opened this issue Jul 2, 2020 · 1 comment
Closed

Path API create_datanode rejects valid value #1006

tdesh10 opened this issue Jul 2, 2020 · 1 comment
Labels

Comments

@tdesh10
Copy link

tdesh10 commented Jul 2, 2020

Expected Behavior

ydk.path.RootSchemaNode.create_datanode(path, value=None) should never reject valid paths and values.

Current Behavior

In some cases, ydk.path.RootSchemaNode.create_datanode(path, value=None) rejects valid values with exception YModelError. Even though the value is set and in accordance with the model, the exception indicates that an empty string ("") was provided.

Note that the error does not occur if the datanode is created directly from its parent datanode using the function ydk.path.DataNode.create_datanode(path, value=None)

Steps to Reproduce

Execute the script below in ydk-py docker container.

Your Script

from ydk.path import Repository, Capability
from ydk.types import EncodingFormat
import logging
# log = logging.getLogger('ydk')
# log.setLevel(logging.DEBUG)
# handler = logging.StreamHandler()
# log.addHandler(handler)

repo = Repository('/root/ydk-py/cisco-ios-xr/ydk/models/cisco_ios_xr/_yang')
root_schema = repo.create_root_schema([])

xpath = "Cisco-IOS-XR-cdp-cfg:cdp/timer"
value = "60"

# cdp = root_schema.create_datanode("Cisco-IOS-XR-cdp-cfg:cdp")
# timer = cdp.create_datanode("timer", value)

datanode = root_schema.create_datanode(xpath, value)

Logs

Creating libyang context in path: /root/ydk-py/cisco-ios-xr/ydk/models/cisco_ios_xr/_yang
[libyang] Extension plugin "/usr/local/lib/libyang/libyang_ext_test.so" successfully loaded.
[libyang] Extension plugin "/usr/local/lib/libyang/metadata.so" successfully loaded.
[libyang] Extension plugin "/usr/local/lib/libyang/nacm.so" successfully loaded.
[libyang] Reading module "ietf-yang-metadata".
[libyang] Module "ietf-yang-metadata@2016-08-05" successfully parsed as implemented.
[libyang] Reading module "yang".
[libyang] Resolving "yang" unresolved schema nodes and their constraints...
[libyang] All "yang" schema nodes and constraints resolved.
[libyang] Module "yang@2017-02-20" successfully parsed as implemented.
[libyang] Reading module "ietf-inet-types".
[libyang] Resolving derived type "union" failed, it will be attempted later.
[libyang] Resolving derived type "union" failed, it will be attempted later.
[libyang] Resolving derived type "union" failed, it will be attempted later.
[libyang] Resolving derived type "union" failed, it will be attempted later.
[libyang] Resolving "ietf-inet-types" unresolved schema nodes and their constraints...
[libyang] All "ietf-inet-types" schema nodes and constraints resolved.
[libyang] Module "ietf-inet-types@2013-07-15" successfully parsed as implemented.
[libyang] Reading module "ietf-yang-types".
[libyang] Module "ietf-yang-types@2013-07-15" successfully parsed as implemented.
[libyang] Reading module "ietf-datastores".
[libyang] Module "ietf-datastores@2017-08-17" successfully parsed as implemented.
[libyang] Reading module "ietf-yang-library".
[libyang] Module "ietf-yang-library@2017-08-17" successfully parsed as implemented.
Populating new module schema 'ietf-yang-metadata'
Populating new module schema 'yang'
Populating new module schema 'ietf-inet-types'
Populating new module schema 'ietf-yang-types'
Populating new module schema 'ietf-datastores'
Populating new module schema 'ietf-yang-library'
Getting new modules for path 'Cisco-IOS-XR-cdp-cfg:cdp/timer'
Loading module 'Cisco-IOS-XR-cdp-cfg', revision ''
[libyang] Searching for "Cisco-IOS-XR-cdp-cfg" in /root/ydk-py/cisco-ios-xr/ydk/models/cisco_ios_xr/_yang.
[libyang] Searching for "Cisco-IOS-XR-cdp-cfg" in /root/ydk-py/cisco-ios-xr/ydk/models/cisco_ios_xr/_yang/ietf@0.1.5-post2.
[libyang] Searching for "Cisco-IOS-XR-cdp-cfg" in /root/ydk-py/pathapi-taran.
[libyang] Loading schema from "/root/ydk-py/cisco-ios-xr/ydk/models/cisco_ios_xr/_yang/Cisco-IOS-XR-cdp-cfg.yang" file.
[libyang] Searching for "Cisco-IOS-XR-ifmgr-cfg" in /root/ydk-py/cisco-ios-xr/ydk/models/cisco_ios_xr/_yang.
[libyang] Searching for "Cisco-IOS-XR-ifmgr-cfg" in /root/ydk-py/cisco-ios-xr/ydk/models/cisco_ios_xr/_yang/ietf@0.1.5-post2.
[libyang] Searching for "Cisco-IOS-XR-ifmgr-cfg" in /root/ydk-py/pathapi-taran.
[libyang] Loading schema from "/root/ydk-py/cisco-ios-xr/ydk/models/cisco_ios_xr/_yang/Cisco-IOS-XR-ifmgr-cfg.yang" file.
[libyang] Searching for "Cisco-IOS-XR-types" in /root/ydk-py/cisco-ios-xr/ydk/models/cisco_ios_xr/_yang.
[libyang] Searching for "Cisco-IOS-XR-types" in /root/ydk-py/cisco-ios-xr/ydk/models/cisco_ios_xr/_yang/ietf@0.1.5-post2.
[libyang] Searching for "Cisco-IOS-XR-types" in /root/ydk-py/pathapi-taran.
[libyang] Loading schema from "/root/ydk-py/cisco-ios-xr/ydk/models/cisco_ios_xr/_yang/Cisco-IOS-XR-types.yang" file.
[libyang] Module "Cisco-IOS-XR-types@2018-06-29" successfully parsed as implemented.
[libyang] Resolving "Cisco-IOS-XR-ifmgr-cfg" unresolved schema nodes and their constraints...
[libyang] All "Cisco-IOS-XR-ifmgr-cfg" schema nodes and constraints resolved.
[libyang] Module "Cisco-IOS-XR-ifmgr-cfg@2017-09-07" successfully parsed as implemented.
[libyang] Module "Cisco-IOS-XR-cdp-cfg@2017-08-16" successfully parsed as implemented.
Added new libyang module 'Cisco-IOS-XR-cdp-cfg'
Populating new module schema 'Cisco-IOS-XR-cdp-cfg'
Populating augmented schema node 'cdp'
Populating new schema node 'cdp'
Looking to populate schemas for 'Cisco-IOS-XR-cdp-cfg:cdp/timer'
Getting new modules for path 'Cisco-IOS-XR-cdp-cfg:cdp/timer'
Loading module 'Cisco-IOS-XR-cdp-cfg', revision ''
The module 'Cisco-IOS-XR-cdp-cfg' schema has already been populated in YDK repository
Looking to populate schemas for '60'
Getting new modules for path '60'
Creating root data node with path '/Cisco-IOS-XR-cdp-cfg:cdp'
Populating schema for 'timer'
Looking to populate schemas for 'timer'
Getting new modules for path 'timer'
Creating node 'timer' with value ''
Current path: /Cisco-IOS-XR-cdp-cfg:cdp
Top container path: Cisco-IOS-XR-cdp-cfg:cdp
Populating schema for 'timer'
Looking to populate schemas for 'timer'
Getting new modules for path 'timer'
Getting child schema with path 'timer' in /Cisco-IOS-XR-cdp-cfg:cdp
Getting data nodes with path 'timer'
Creating new data path 'timer' with value '' in 'cdp'
Data is invalid according to the yang model. Libyang error: Invalid value "" in "timer" element. Path: '/Cisco-IOS-XR-cdp-cfg:cdp/timer'
Traceback (most recent call last):
  File "bugtest.py", line 18, in <module>
    datanode = root_schema.create_datanode(xpath, value)
RuntimeError: YModelError: Invalid value "" in "timer" element. Path: /Cisco-IOS-XR-cdp-cfg:cdp/timer

System Information

ydk (0.8.3)
docker run -it ydkdev/ydk-py

@111pontes 111pontes added the bug label Jul 2, 2020
ygorelik added a commit to ygorelik/ydk-gen that referenced this issue Jul 3, 2020
@ygorelik
Copy link
Collaborator

Resolved in YDK-0.8.5.

shmuelnatan added a commit to siklu/ydk-gen that referenced this issue Jul 12, 2022
* Fixed bug in extracting module name from namespace

* Added distribution packages in GitHub

* Added distribution packages for Ubuntu/xenial on GitHub

* Added distribution packages for Centos to GitHub

* Added distributables for darwin to GitHub

* In Entity class Added method to clone current entity instance

* In Entity class Added method to clone current entity instance

* Added shortcut operator to set yfilter value in YLeaf and YLeafList instances

* Fixing Travis test for gNMI

* Implemented Entity clone in Go (enh. CiscoDevNet#967)

* Fixing Travis test

* Resolved issue CiscoDevNet#968

* Addressed few Codacy issues

* Addressed documentation issue CiscoDevNet#971

* Fixed bug in gNMI set RPC processing

* Corrected documentation of YDK raised exceptions

* Resolved issue CiscoDevNet#978, implemented enhancement 894

* Resolved issue CiscoDevNet#980

* Fixing Travis test for MacOSX

* Resolved GitHub issue CiscoDevNet#983

* Updated bundle for XR-6.6.2 (post1)

* Upgraded GitPython package to version 2.1.15 due to Travis failure

* Upgraded openconfig bundle to version dated 2019-06-21

* Resolved github issue CiscoDevNet#996

* Resolved github issue CiscoDevNet#996

* Corrected error message

* Fixed bug in previous commit

* Fixed GitHub issue CiscoDevNet#997

* Resolved GitHub issue CiscoDevNet#969

* Bumped version to 0.8.5

* Initial development of install_ydk script

* Made corrections for Travis run

* Fixing Travis run

* Adjusted YDK installation script for CentOS

* Added support for ubuntu:focal (20.04 LTS)

* Added deployment packages for ubuntu:xenial

* Fixing Travis run for xenial

* Corrected Dockerfile to include golang packages

* Bumped YDK version to 0.8.5

* Added documentation for missing 'initialize' method

* Added unit test for XmlSubtreeCodec on user defined repository

* Adressed some issues related to installation on CentOS

* Added deployment core packages for CentOS-7

* Added disclaimer on 0.8.5 modified files

* Corrected debug statement

* Added test cases for reading on single container

* Corrected license comment

* Resolved GitHub issues CiscoDevNet#1003, CiscoDevNet#1005, CiscoDevNet#1006

* Updated YDK core deployment packages for Ubuntu xenial and bionic

* Updated YDK core and gNMI libraries for CentOS-7

* Update CONTRIBUTIONS.md with license details

* Update .gitignore

* Added YDK core and gNMI deployment packages for OSX

* Added new options in install_ydk script

* Update YDK version for XR 6.6.3 bundle

* Added C++ test cases for path::Codec with no service provider

* Added use case for deleting entire list

* Added capability for Restconf to work with HTTPS protocol (initial commit)

* Some documentation changes for YDK-0.8.5

* Partially addressed issue CiscoDevNet#917 (HTTPS support for Restconf)

* Resolved GitHub issues CiscoDevNet#1012 ans CiscoDevNet#1013

* Corrected documentation pertaining release 0.8.5

* Removed binary artifacts

* Fixing Travis test

* Fixing Travis test

* Changed bundle backward compatibility test to YDK-0.7.3

* Fixing bundle backward compatibility test

* Enabled Travis test on CentOS-7 docker

* Restored artifacts to 0.8.5

* Lowered version of go testify version

* Lowered version of go testify version

* Updated artifacts for OSX

* Updated artifacts for ubuntu:xenial

* Updated artifacts for CentOS-7

* Update travis testing for Ubuntu

Re-enable Python3 testing for Ubuntu Xenial.

* Fixed few bugs in C++ code

* Resolved issue CiscoDevNet#1021

* added github based online documentation

* Added support for Centos 8 CiscoDevNet#1019

* Resolved issue CiscoDevNet#1024

* Added support for Centos 8 CiscoDevNet#1019

* Fixing Travis test for Centos 8

* Fixing Travis test for Centos 8

* Fixing Travis test for Centos 8

* Fixing Travis test for Centos 8

* Fixing Travis test for Centos 8

* Added support for Ubuntu:focal

* Fixing Travis test for Ubuntu:focal

* Fixing Travis tests for ubuntu:focal

* Fixing Travis tests for ubuntu:focal

* Fixing Travis test for ubuntu:focal

* Fixing Travis test for ubuntu:focal

* Fixing Travis test for ubuntu:focal

* Fixing Travis test for ubuntu:focal

* Fixing Travis test for ubuntu:focal

* Improving unit tests for Mac OS Mojave

* Improving unit tests for Mac OS Mojave

* Added unit test for issue CiscoDevNet#1026

* Added test case after fixing CiscoDevNet#1026 in Libyang

* Corrected YDK service classes initialization issue for python

* Resolved issues CiscoDevNet#1026 and CiscoDevNet#1032

* Updated 0.8.5 documentation

* Resolved issue CiscoDevNet#1036

* Resolved issue CiscoDevNet#1035

* Correcting Travis tests

* Fixing deviation tests

* Fixed confd setting for deviation tests

* Addressed memory leak issue in Executor Service unit tests

* Implemented enhancement CiscoDevNet#1007

* Bumped version to 0.8.5.post1

* Additional code changes for enhancement CiscoDevNet#1007

* Added installation of flex and bison for CentOS platform

* Inforced use of pybind11 v2.2.2

* Corrected test scripts to work with confd version 7.3

* Improved test scripts

* Fixed bug in the bundle generator

* Fixed decoding of leaf-list in XMLSubtreeCodec

* Bumped build version to 2

* Added unit test case for issue CiscoDevNet#1045

* Corrected installation of curl and libcurl for ubuntu:focal

* Corrected documentation for release 0.8.5.2

* Corrected documentation for release 0.8.5.2

* Resolved issue CiscoDevNet#1049

* Fixed memory leak issue

* Added unit test for issue CiscoDevNet#635

* Fixing issue 053

* Created Go wrapper for NetconfSession, added Path API unit tests, CiscoDevNet#779

* Created Go wrappdded Path API unit tests, CiscoDevNet#779

* Resolved GitHub issue CiscoDevNet#1053

* Enabled all CRUD tests related to deleting of list and leaf-list

* Added unit tests and documentation for Path API in Go

* Bumped version to 0.8.5.3 (0.8.5.post3 for python)

* Generated docs. Changed Puthon package version to 0.8.5.3.

* Corrected Copyright statement

* Added support for RestconfSession in Go

* Added C++ documentation related to resolution of enhancement CiscoDevNet#779

* Corrected documentation related to enhancement CiscoDevNet#779

* Upgraded pyang version to 2.5.0

* Upgraded pyang version to 2.5.0

* Dropped Python2 support in the code

* Dropped Python2 support in the code (2)

* Added bundle profiles to support newer versions of IETF OpenConfig and Cisco IOS XR models

* Added bundle profiles for IOS XR version 7.0.1 and 7.0.2

* Added bundle profiles for IOS XR version 7.0.1 and 7.0.2

* Added SSH support for NetconfServiceProvider in Go

* Added SSH support for NetconfServiceProvider in Go

* Added explicit setting of OnDemand flag in NetconfServiceProvider

* Fixed setting of OnDemand flag in NetconfSession in Go

* Solves nil pointer dereference

When calling (NetconfServiceProvider).GetConfig with an empty EntityCollection panics cause of a nil pointer dereference. Adding these if-guards seems to solve the problem.

* Updated release documentation

* Bumped version to 0.8.6

* Implements requested changes

* Update types.go

Corrected suggested code changes.

* Bumped version to 0.8.6.2

* Improving installation script

* Improved installation script to allow use Python system installation

* Fixed few profiles for ietf and cisco-ios-xr bundles

* Fixed few profiles for ietf and cisco-ios-xr bundles

* Reverted version to 0.8.6

* Reverted changes to comply with Python 3.5 syntax

* Restored damaged ydktest profile

* Cleaned up older profiles

* Changed script parameter '--no-py-venv' to '--no-venv'

* Fixed unit test script

* Resolved issue CiscoDevNet#1034

* Corrected documentation after fixing issue CiscoDevNet#1034

* Corrected unit tests for CiscoDevNet#1047 and CiscoDevNet#1048

* Corrected YDK core version requirement

* Corrected YDK core version to 0.8.6.2

* Addressed segmentation fault error

* Corrected Codecy issues

* Minor doc corrections

* Made adjustments for installation on mac osx 11.6

* Added YDK demo. Mentioned added support for MacOS Big Sur

* Provided patch to ensure definition of constant SIGSTKSZ

* Patched catch.hpp for Linux distributions that do not define SIGSTKSZ

* Addressing GitHub issue CiscoDevNet#1059

* Addressing GitHub issue CiscoDevNet#1059

* added demo profile and bundles for Cisco IOS XR

* Fixed unit test in Go for the issue 1059

* Renewed documentation for release 0.8.6.2

* Resolved issue CiscoDevNet#1059

* Resolved issue CiscoDevNet#1056

* Revert "ydkgen: run autopep8 on all ydkgen py files"

This reverts commit e5c17c1.

* fixup

* Close YList class with parenthethis

* Remove one EncodingFormat from the two enums

* Remove unused Entity* in resolve_leaf_value_namespace function in xml_subtree_codec

* Remove Entity from call to resolve_leaf_value_namespace function in xml_subtree_codec

* Remove errors.hpp.
Remove _print_yang_models_function from _print_top_level_entity_functions.
Remove _print_bundle_name_function from _print_top_level_entity_functions.

Co-authored-by: Yan Gorelik <34285093+ygorelik@users.noreply.github.com>
Co-authored-by: ygorelik <ygorelik@cisco.com>
Co-authored-by: Yan Gorelik <yangorelik@yahoo.com>
Co-authored-by: Yan Gorelik <ygorelik@localhost.localdomain>
Co-authored-by: CentOS <centos@centos7.linuxvmimages.com>
Co-authored-by: ubuntu <ubuntu@ubunu2004.linuxvmimagrs.local>
Co-authored-by: Santiago Alvarez <saalvare@cisco.com>
Co-authored-by: Santiago Álvarez <111pontes@users.noreply.github.com>
Co-authored-by: ygorelik <yangorelik@gmail.com>
Co-authored-by: Yan Gorelik <ygorelik@ubunu2004.linuxvmimagrs.local>
Co-authored-by: Daniele Gargano <84291326+viardant@users.noreply.github.com>
Co-authored-by: Shmuel Hazan <shmuel.h@siklu.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants