Subject: [netmod] Augmentation with a mandatory leaf in a submodule - Is the following legal?

From: "Beauville, Yves (Nokia - BE/Antwerp)" <[email-masked]>
Date: Fri, 15 Feb 2019 09:12:25 +0000

Hi,

We are working with a submodule in which we are augmenting a container of the same module with a mandatory node. There is a small catch though.

Our YANG modules are actually supporting two augmentations - I have copied a trimmed down version of our modules at the end of this mail -:

* From container 'top' in 'module-a' to container 'first-augment' in 'module-b' (sub-module-1) => This augmentation is made conditional with a 'when' statement.

* From container 'first-augment' to leaf 'mandatory-leaf'. This is done within two submodules of the same module 'module-b' => This augmentation is NOT conditional.

The Open Daylight parser rejects our YANG modules with the following error:

   Failed to add augmentation sub-module-1b.yang defined at sub-module-2b.yang org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException: An augment cannot add node 'mandatory-leaf' because it is mandatory and in module different than target [at sub-module-2b.yang]

As per https://tools.ietf.org/html/rfc7950#section-7.17, we believe these augmentations are both legal'.

We have raised a ticket YANGTOOLS-956 at Open Daylight but folks at ODL are asking us to check with experts in this mailing list.

Can one assess if these models are making a 'legal' use of augmentations or not?

Yves

================================

module module-a {
  yang-version 1.1;
    namespace "http://www.example.com/anothermodule"<http://www.example.com/anothermodule>;
    prefix am;
    container top {
      leaf type {
        type string;
        mandatory true;
      }
  }
}
module module-b {
  yang-version 1.1;
    namespace "http://www.example.com/module-b"<http://www.example.com/module-b>;
   prefix mm;
   include sub-module-1;
   include sub-module-2;
}
submodule sub-module-1 {
   yang-version 1.1;
   belongs-to module-b {
    prefix mm;
  }
    import module-a {
    prefix am;
  }
  augment '/am:top' {
    when "am:type = 'test'";
    container first-augment {
    }
  }
}
submodule sub-module-2 {
  yang-version 1.1;
  belongs-to module-b {
    prefix mm;
  }
    import module-a {
    prefix am;
  }
  include sub-module-1;
  grouping dummygrouping {
    leaf mandatory-leaf {
      type string;
      mandatory true;
     }
  }
  augment '/am:top/mm:first-augment' {
    uses dummygrouping;
  }
}

---

From: Robert Wilton <[email-masked]>
Date: Fri, 15 Feb 2019 10:08:20 +0000

Hi Yves,

My interpretation of the spirit of the RFC is that this should be 
allowed, and I don't think that any text in 7.17 specifically prevents this.

However, this seems like a corner case, and I am also not surprised that 
a YANG compiler would fail on this.  This issue could perhaps be easily 
mitigated by making the second augmentation also conditional on the same 
when statement.

Note that the use of sub-modules doesn't really matter, in that a 
compiler can treat them as one module.  So, I think that the problem is 
equivalent to:

module module-a {
   yang-version 1.1;
   namespace "http://www.example.com/anothermodule";
   prefix am;

   container top {
     leaf type {
       type string;
       mandatory true;
     }
   }
}

module module-b {
   yang-version 1.1;
   namespace "http://www.example.com/module-b";
   prefix mm;

   augment '/am:top' {
     when "am:type = 'test'";

Thanks,
Rob

On 15/02/2019 09:12, Beauville, Yves (Nokia - BE/Antwerp) wrote:
> Hi,
>
> We are working with a submodule in which we are augmenting a container 
> of the same module with a mandatory node. There is a small catch though.
>
> Our YANG modules are actually supporting two augmentations - I have 
> copied a trimmed down version of our modules at the end of this mail -:
>
> * From container 'top' in 'module-a' to container 'first-augment' in 
> 'module-b' (sub-module-1) => This augmentation is made conditional 
> with a 'when' statement.
>
> * From container 'first-augment' to leaf 'mandatory-leaf'. This is 
> done within two submodules of the same module 'module-b' => This 
> augmentation is NOT conditional.
>
>    Failed to add augmentation sub-module-1b.yang defined at 
> sub-module-2b.yang 
> org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException: An 
> augment cannot add node 'mandatory-leaf' because it is mandatory and 
> in module different than target [at sub-module-2b.yang]
>
> As per https://tools.ietf.org/html/rfc7950#section-7.17 
> <https://tools.ietf.org/html/rfc7950#section-7.17>, we believe these 
> augmentations are both legal'.
>
> We have raised a ticket YANGTOOLS-956 at Open Daylight but folks at 
> ODL are asking us to check with experts in this mailing list.
>
>     namespace "http://www.example.com/anothermodule";
>     prefix am;
>     container top {
>       leaf type {
>         type string;
>         mandatory true;
>       }
>   }
> }
> module module-b {
>   yang-version 1.1;
>     namespace "http://www.example.com/module-b";
>    prefix mm;
>    include sub-module-1;
>    include sub-module-2;
> }
> submodule sub-module-1 {
>    yang-version 1.1;
>    belongs-to module-b {
>     prefix mm;
>   }
>     import module-a {
>     prefix am;
>   }
>   augment '/am:top' {
>     when "am:type = 'test'";
> _______________________________________________
> netmod mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/netmod

---

From: "Beauville, Yves (Nokia - BE/Antwerp)" <[email-masked]>
Date: Fri, 15 Feb 2019 11:51:38 +0000

Hi Rob,

Thank you very much for your fast reply, for proposing a mitigation, and for 'reducing' our set of YANG modules to pin-point the cause of the issue.

I am aligned with you. It is indeed a corner case. We will forward your feedback to OpenDaylight as well.

Thank you,

Yves

On 15-02-19 11:08, Robert Wilton wrote:

Hi Yves,

My interpretation of the spirit of the RFC is that this should be allowed, and I don't think that any text in 7.17 specifically prevents this.

However, this seems like a corner case, and I am also not surprised that a YANG compiler would fail on this.  This issue could perhaps be easily mitigated by making the second augmentation also conditional on the same when statement.

Note that the use of sub-modules doesn't really matter, in that a compiler can treat them as one module.  So, I think that the problem is equivalent to:

module module-a {
  yang-version 1.1;

  container top {
    leaf type {
      type string;
      mandatory true;
    }
  }
}

module module-b {
  yang-version 1.1;

  augment '/am:top' {
    when "am:type = 'test'";

Thanks,
Rob

Yves

module module-a {
  yang-version 1.1;

_______________________________________________
netmod mailing list
[email-masked]<mailto:[email-masked]>
https://www.ietf.org/mailman/listinfo/netmod