cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
539
Views
5
Helpful
1
Replies

How to retrieve substatements using Path API?

tadeshpa
Cisco Employee
Cisco Employee

How can I find the substatements of a schema node? For example, if it is a configuration node or mandatory node? Or in the case of list nodes, how do I find the keys? I the script below, I can find out the keyword and argument for timer, but I can't find out if it is configuration, mandatory, or what the status is (current, deprecated, obsolete)?

from ydk.path import Repository, Capability

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)

timer_schema_node = timer.get_schema_node()

timer_statement = timer_schema_node.get_statement()
print(timer_statement.keyword, timer_statement.arg)
1 Reply 1

yangorelik
Spotlight
Spotlight

Unfortunately information that you are looking for currently is not available in Python code. It is available only in C++ code, where class SchemaNodeImpl holds pointer to Libyang structure lys_node, which contains all the information about correspondent YANG model node. New development is required to expose that information in Python code. I suggest to open enhancement request for this new development on ydk-gen GitHub.

Yan Gorelik
YDK Solutions