mbj4668 / pyang

An extensible YANG validator and converter in python
ISC License
530 stars 342 forks source link

Mandatory leaf in augmented container #840

Open ahuangfeng opened 1 year ago

ahuangfeng commented 1 year ago

I am trying to augment a notification container with a grouping having a mandatory leaf in it. From the spec in rfc7950#section-7.17 I understand that it is valid if the container is not a configuration container but I am having an error out of pyang:

ahuangfeng@Alex-book [~/yang-examples] % pyang issue-yang2.yang -f tree -p .
issue-yang2.yang:21 (at issue-yang2.yang:16): error: cannot augment with mandatory node "new-leaf"
module: issue-yang2

  augment /iy:first-container:
    +--ro new-leaf    string

I also checked with NETMOD WG that mandatory leaves were allowed in augmented YANG modules unless they are config containers : https://mailarchive.ietf.org/arch/msg/netmod/kH-zwf7rA5pLcMA3mLLsobM1ZfU/

Therefore I understand that this is a bug on augmented notification containers.

Here the two YANGs I used:

module issue-yang {
  yang-version 1.1;
  namespace "urn:ietf:params:xml:ns:yang:issue-yang";
  prefix iy;

  container first-container {
    config false;

    leaf address {
      type string;
    }
    leaf port {
      type uint8;
    }
  }
}

And the second YANG module

module issue-yang2 {
  yang-version 1.1;
  namespace "urn:ietf:params:xml:ns:yang:issue-yang2";
  prefix iyy;

  import issue-yang {
    prefix iy;
    reference
      "RFC XXXX: YYYY";
  }

  grouping second-container {
    leaf new-leaf {
      type string;
      config false;
      mandatory true;
    }
  }

  augment "/iy:first-container" {
    uses iyy:second-container;
  }
}

Validating:

$ pyang issue-yang2.yang -f tree -p .