Subject: [yang-doctors] YANG Augmentation Complexities

From: "Acee Lindem (acee)" <[email-masked]>
Date: Mon, 30 Apr 2018 20:13:31 +0000

Hi Lada, Martin,

Both of you provided YANG doctor comments and proposed usage of identity references for OSPF(v3) LSA types. However, I can’t seem to provide constraints in augmentations using these. Here is the snippet I’m trying to augment in a new model:

       |           |              +--:(ospfv3)
       |           |                 +--ro ospfv3
       |           |                    +--ro header
       |           |                    |  +--ro lsa-id        uint32
       |           |                    |  +--ro age           uint16
       |           |                    |  +--ro type          identityref
       |           |                    |  +--ro adv-router    yang:dotted-quad
       |           |                    |  +--ro seq-num       uint32
       |           |                    |  +--ro checksum      fletcher-checksum16-type
       |           |                    |  +--ro length        uint16
       |           |                    +--ro body
       |           |                       +--ro router
       |           |                       |  +--ro flags      bits
       |           |                       |  +--ro options    bits
       |           |                       |  +--ro links
       |           |                       |     +--ro link*
       |           |                       |        +--ro interface-id?            uint32
       |           |                       |        +--ro neighbor-interface-id?   uint32
       |           |                       |        +--ro neighbor-router-id?      rt-types:router-id
       |           |                       |        +--ro type?                    uint8
       |           |                       |        +--ro metric?                  uint16

If I try to augment the body, I get an error using the YANG when statement and the derived-from-or-self() function.

  grouping ospfv3-e-lsa-body {
    description "OSPFv3 Extended LSA body.";
    container e-router {
      when  "derived-from-or-self(../header/type, "
        + "'ospfv3-e-router-lsa')" {
        description "Only valid for OSPFv3 Extended-Router LSAs";
      }
      description "OSPv3 Extended Router LSA.";

augment "/rt:routing/"
    + "rt:control-plane-protocols/rt:control-plane-protocol/"
    + "ospf:ospf/ospf:areas/ospf:area/ospf:database/"
    + "ospf:area-scope-lsa-type/ospf:area-scope-lsas/"
    + "ospf:area-scope-lsa/ospf:version/ospf:ospfv3/"
    + "ospf:ospfv3/ospf:body" {
    when "../../../../../../../../../"
      + "rt:type = 'ospf:ospfv3'" {
      description
        "This augmentation is only valid for OSPFv3
         E-Router LSAs";
    }
    uses ospfv3-e-lsa-body;
    description
      "OSPFv3 Area-Scoped Extended LSAs";
  }

I get the error:

ACEE-M-G2HR:ospf-extended-lsa-yang acee$ pyang ietf-ospfv3-extended-lsa.yang
ietf-ospfv3-extended-lsa.yang:131: error: XPath function "derived-from-or-self" is not defined in the XPath context
ietf-ospfv3-extended-lsa.yang:285 (at /Users/acee/yang/modules/ietf-ospf.yang:1196): error: cannot augment with mandatory node options

If I try and augment one level up and put both constraints on the augmentation, I get the same error.

  + "rt:control-plane-protocols/rt:control-plane-protocol/"
    + "ospf:ospf/ospf:areas/ospf:area/ospf:database/"
    + "ospf:area-scope-lsa-type/ospf:area-scope-lsas/"
    + "ospf:area-scope-lsa/ospf:version/ospf:ospfv3/"
    + "ospf:ospfv3" {
    when "../../../../../../../../../"
       + "rt:type = 'ospf:ospfv3' and "
       + "derived-from-or-self(header/type, "
       + "'ospfv3-e-router-lsa')" {
      description
        "This augmentation is only valid for OSPFv3
         E-Router LSAs";
    }
    uses ospfv3-e-lsa-body;
    description
      "OSPFv3 Area-Scoped Extended LSAs";
  }

Thanks,
Acee