06-20-2017 07:34 AM
Using YDK-gen and YDK-py (R0.5.5), I 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?
Solved! Go to Solution.
06-21-2017 10:34 AM
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.
06-20-2017 10:34 AM
Hi Yung,
Can you provide your yang file and your script as this will help in debugging this issue?
06-20-2017 11:44 AM
Not sure how much this will help you 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.
06-21-2017 10:34 AM
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.
06-28-2017 08:34 AM
Yung, were you able to get those logs?
06-28-2017 03:02 PM
Sorry, I don't have much time to do this. But let me cut down the chase and explain where I believe the trouble is. 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.
06-29-2017 02:45 AM
I agree that this is a bug in how we handle identity values. The XML namespace issues around identities are a bit of a pain. Unless we already have, we should raise an issue to address this.
Cheers,
Einar
06-29-2017 09:06 AM
Thanks! Just 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, I agree with Einar that it is bug and an issue needs to be filed on Issues · CiscoDevNet/ydk-gen · GitHub
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide