Conditional display of a leaf working in confd cli but not in RESTCONF

Hi,

I am using openconfig-interfaces.yang as base module to augment/annotate interfaces as per my requirement.
We have ethernet module augmented in openconfig-if-ethernet.yang to use when interface type is “ethernetCsmacd”.
We have multiple ethernet interfaces and few ethernet leafs are not supported for few interfaces when it matches with a specific name like “DataIntf”.
As i read that “Conditional Deviation” is not supported" i used “tailf:display-when”/when to show
these leafs when it matches with interface name “DataIntf”.
This is working fine in confd cli. But when i do GET operation using RESTCONF(using curl) all parameters are getting displayed irrespective of condition.
I tried with both “tailf:display-when” and “when”, but result is same.
Can someone throw some light on this and help me in identifying if there is any limitation in display of parameters in RESTCONF?

Thanks in advance.

Regards,
Karthik

Hi,

Share the “when” statement you implemented + the YANG it points to. Your “when” statement XPath expression is likely broken.

Regards

Hi,

Below entry is added in an annotated yang file.
tailf:annotate “/oc-if:interfaces/oc-if:interface/oc-eth:ethernet/oc-eth:config/oc-eth:duplex-mode” {
when “…/…/…/oc-if:config/oc-if:name=‘DataIntf’”;
}

This is intended to display when interface name is “DataIntf”. This is behaving as expected in case of confd cli i.e this field is not displayed when interface name is not “DataIntf”. But in case of curl GET on this interface xpath all parameters are getting displayed irrespective of condition.

Thanks,
Karthik

That will work if you built the fxs with the annotation file.
Example:

confdc -c --yangpath yang -o fxs/openconfig-if-ethernet.fxs  -a yang/openconfig-if-ethernet-ann.yang -- yang/openconfig-if-ethernet.yang
module openconfig-if-ethernet-ann {
  namespace "urn:example";
  prefix x;
  import tailf-common { prefix tailf; }
  import openconfig-interfaces { prefix oc-if; }
  import openconfig-if-ethernet { prefix oc-eth; }

  tailf:annotate "/oc-if:interfaces/oc-if:interface/oc-eth:ethernet/oc-eth:config/oc-eth:duplex-mode" {
    when "../../../oc-if:config/oc-if:name='DataIntf'";
  }
}

Although, annotating a when statement into a standard YANG model is not best practices. Hiding the config over RESTCONF based on the name of the interface seems odd.
But I assume you have a very good reason.

Following is the behavior i observed with different combinations:

  1. tailf:display-when:
    config data & state data are coming even if condition fails.
  2. when:
    Config data is not coming when condition fails.
    So this is working as expected.
    State data:
    State data is coming even if condition do not matches when set from code.
    If i have some checks in code and avoid setting when interface type do not matches then it is not coming.

In short leafs are coming in RESTCONF output when set explicitly even when condition fails.

So you got the when statement on the “duplex-mode” leaf to work?
I verified that the when statement works as expected on state data too. So you need to check your when statement there too.

For example:

module openconfig-if-ethernet-ann {
  yang-version 1.1;
  namespace "urn:example";
  prefix x;
  import tailf-common { prefix tailf; }
  import openconfig-interfaces { prefix oc-if; }
  import openconfig-if-ethernet { prefix oc-eth; }

  tailf:annotate "/oc-if:interfaces/oc-if:interface/oc-eth:ethernet/oc-eth:config/oc-eth:duplex-mode" {
    when "../../../oc-if:config/oc-if:name='DataIntf'";
  }
  tailf:annotate "/oc-if:interfaces/oc-if:interface/oc-eth:ethernet/oc-eth:state/oc-eth:enable-flow-control" {
    when "../../../oc-if:config/oc-if:name='DataIntf'";
  }
}

Thanks @cohult for your replies.
Yeah i did the same. I will elaborate more on my query.
Yang:
tailf:annotate “/oc-if:interfaces/oc-if:interface/oc-eth:ethernet/oc-eth:state/oc-eth:port-speed” {
when “…/…/…/oc-if:config/oc-if:name=‘DataIntf’”;
}
tailf:annotate “/oc-if:interfaces/oc-if:interface/oc-eth:ethernet/oc-eth:state/oc-eth:enable-flow-control” {
when “…/…/…/oc-if:config/oc-if:name=‘DataIntf’”;
}
Code:
CONFD_SET_TAG_IDENTITYREF(&tv[i++], oc_eth_port_speed, ps);
if (if_name == “DataIntf”) {
CONFD_SET_TAG_BOOL(&tv[i++], oc_eth_enable_flow_control, true);

}
Curl GET output:
Interface => Non DataIntf
“openconfig-if-ethernet:ethernet”: {
“state”: {
“port-speed”: “openconfig-if-ethernet:SPEED_10GB”,
}
}

Interface => DataIntf
“state”: {
“auto-negotiate”: false,
“duplex-mode”: “FULL”,
“port-speed”: “openconfig-if-ethernet:SPEED_10GB”,
“enable-flow-control”: true,
“hw-mac-address”: “00:94:a1:37:97:02”,
“negotiated-duplex-mode”: “FULL”,
“negotiated-port-speed”: “openconfig-if-ethernet:SPEED_10GB”,
}
I see port-speed parameter in state data for "non DataIntf " also although this parameter is annotated to have “when” condition. The only difference i see is i am setting port-speed state data irrespective of interface name. Rest all parameters i am setting when interface name is DataIntf.