cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
675
Views
0
Helpful
7
Replies

decode identityref with wrong namespace/module?

yung.hsu
Level 1
Level 1

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?

1 Accepted Solution

Accepted Solutions

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.

View solution in original post

7 Replies 7

abhirame
Cisco Employee
Cisco Employee

Hi Yung,

Can you provide your yang file and your script as this will help in debugging this issue?

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.

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.

saalvare
Cisco Employee
Cisco Employee

Yung, were you able to get those logs?

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.

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

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

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: