Using YDK-gen and YDK-py (R0.5.5),built and installed a private YANG file with its own namespace to supplement trib-protocol (of type identityref) in openconfig-terminal-device. But YDK-py fails to decode trib-protocol from a NETCONF message such as:
<terminal-device xmlns="http://openconfig.net/yang/terminal-device">
...
<config>
<index>101020411</index>
<trib-protocol xmlns="http://my.com/yang/my-openconfig-exttypes">PROT_UNASSIGNED</trib-protocol>
</config>
Looking at YDK implementation, when trying to resolve/decode an identityref, it ignores the namespace (my-openconfig-exttypes) with trib-protocol and uses "open-terminal-device" from its root node instead. This seems to be a bug..
Since the effort is in setting up a device that gives the right response.
The yang file is simple and it looks like below.
module my-openconfig-exttypes {
yang-version "1";
namespace "http://my.com/yang/my-openconfig-exttypes";
prefix "my-oc-exttypes";
import openconfig-transport-types { prefix oc-opt-types; }
organization "My";
contact "My Optical Networks";
description "For debug/testing only";
identity PROT_UNASSIGNED {
base oc-opt-types:TRIBUTARY_PROTOCOL_TYPE;
description "No protocol specified";
}
}
The script basically does this:
term = TerminalDevice()
devices = crud.read(provider, term, only_config=True)
It will be easier if you find an existing device that does something similar with identityref.
Can you also enable logging (see this) and provide the logs from your script? I'm interested in seeing the payloads being created by YDK (if any)
We have some example scripts, which do the similar thing as your yang model, which have been tested and known to work without problems. See this one for example. Corresponding yang file is here.
- Consider _bind_to_object_helper() method in providers/_decoder.py. It has the following code:
for member in entity_members: | |
module_name = member.module_name | |
nmsp = _yang_ns._namespaces[module_name] | |
tag_name = '{' + nmsp + '}' + member.name | |
rt = [rt for rt in root.getchildren() if rt.tag == tag_name] |
- It tries to extract members from encoded XML using their namespace according to their modules/Yang. But this does not work for member of identityref (think of it as a typed "pointer") that may not assume its defined namespace (i.e., "base" type). From the example in my original question:
- <trib-protocol xmlns="http://my.com/yang/my-openconfig-exttypes">PROT_UNASSIGNED</trib-protocol>
- As shown, this instance of trib-protocol is an identityref of a "derived" namespace (not defined in the module/Yang). In current YDK (0.5.5) implementation, this encoded trib-protocol will be ignored since its tag name does not meet the search criteria.
Want to confirm that you have compiled your module "my-openconfig-exttypes.yang" as part of your ydk bundle using ydk-gen. If you have done so and are still seeing the issue, Will agree that it is bug and an issue needs to be filed on Issues · CiscoDevNet/ydk-gen · GitHub
This is a bug in how we handle identity values. The XML namespace issues around identities unless we already have, we should raise an issue to address this.
Comments
0 comments
Please sign in to leave a comment.