ConfD User Community

Error while trying to annotate "must" statement

I am trying to annotate below “must” statement under leaf “port-name” in container port-reference

augment “/if:interfaces/if:interface” {
when “(if:type = ‘ianaift:ethernetCsmacd’) or
(if:type = ‘ianaift:l2vlan’)” {
description “Applies to ethernetCsmacd and l2vlan interfaces”;
}
description
“Augment the interface model with parameters for all
both ethernetCsmacd and l2vlan interfaces.”;
leaf mac-address {
type yang:mac-address;

  description
    "The MAC address of the interface.";
}

container port-reference {
  description
    "a port reference used by other O-RAN modules";
  leaf port-name {
    type leafref {
      path '/hw:hardware/hw:component/hw:name';
    }

    **must "derived-from-or-self(deref(current())/../hw:class, 'ianahw:port')";**

}
}
]

Using the below annotate model

o-ran-interfaces-ann.yang
module o-ran-interfaces-ann {
namespace “urn:o-ran-interfaces-ann:1.0”;
prefix ointa;
import tailf-common {
prefix tailf;
}
import o-ran-interfaces {
prefix oint;
}
import iana-hardware {
prefix “ianahw”;
}
import ietf-interfaces {
prefix “if”;
}
import ietf-hardware {
prefix “hw”;
}
description
“Annotate model for o-ran-interfaces adds the callpoints necessary for using this module with ConfD.”;

 tailf:annotate-module 'oint'{
   tailf:annotate-statement augment[7]{
   tailf:annotate-statement container[name=‘port-reference’]{
    tailf:annotate-statement leaf[name=‘port-name’] {
      tailf:annotate-statement must {
       tailf:dependency 'hw:hardware/hw:component/hw:class';

            }        }      }    }  }

}

now facing below error when trying to build fxs using below command

/root/confd/bin/confdc --fail-on-warnings -a o-ran-interfaces-ann.yang -c o-ran-interfaces.yang -o o-ran-interfaces.fxs --yangpath …/…/imported_models/ --verbose
Generating .fxs file “o-ran-interfaces.fxs”
o-ran-interfaces.yang:399: error: The ‘must’ expression should have a tailf:dependency. If is doesn’t, it will be checked for every commit.

when I add the tailf:dependency into the main yang itself, it is working fine.
what am i missing?

There are two issues in your annotate statements:

  • The module name is most likely not oint, I assume it should be o-ran-interfaces. This should be reported by the compiler, but the ConfD compiler prior to the release 7.5 does not report this kind of mistake. As a result, it appears as if the annotation was accepted, but it is actually silently ignored.

  • The dependency should be /hw:hardware/..., note that you are using a relative path. The compile would complain about that if the annotate-module was correct.

module o-ran-interfaces-ann {
namespace “urn:o-ran-interfaces-ann:1.0”;
prefix ointa;
import tailf-common {
prefix tailf;
}
//import o-ran-interfaces {
// prefix oint;
// }
import iana-hardware {
prefix “ianahw”;
}
import ietf-interfaces {
prefix “if”;
}
import ietf-hardware {
prefix “hw”;
}

description
    "Annotate model for o-ran-interfaces adds the callpoints necessary for using this module with ConfD.";

 tailf:annotate-module "o-ran-interface"{
   tailf:annotate-statement augment[7]{
   tailf:annotate-statement container[name=‘port-reference’]{
    tailf:annotate-statement leaf[name=‘port-name’] {
      tailf:annotate-statement must {
       tailf:dependency '/hw:hardware/hw:component/hw:class';

            }
    }
  }
}

}
}

tried with the suggested “o-ran-interface” but still the same ERROR

[root@C7LabMachine interfaces]# /root/confd/bin/confdc --fail-on-warnings -a o-ran-interfaces-ann.yang -c o-ran-interfaces.yang -o o-ran-interfaces.fxs --yangpath …/…/imported_models/
o-ran-interfaces.yang:399: error: The ‘must’ expression should have a tailf:dependency. If is doesn’t, it will be checked for every commit.

NOte: using 7.3 version

should be

tailf:annotate-statement "must[condition=\"derived-from-or-self(deref(current())/../hw:class, 'ianahw:port')\"]" {
  tailf:dependency "/hw:hardware/hw:component/hw:class";
}

thanks @cohult , working fine now.