1

The first module contains this:

module a
{
    namespace "my:namespace";
    prefix a;

    grouping mygrouping
    {
        container firstcontainer {
            list modules {
                leaf firstmodule;
                leaf secondmodule;
            }    
        }
    }
}

Now I want to augment it in the second module as follows:

module b
{
    namespace "my:namespace";
    prefix a;
    import b {
        prefix b;
    }
    augment "/b:mygrouping/b:firstcontainer/b:modules"{
        leaf thirdmodule;
    }
}

This does not work, apparently because a grouping cannot be augmented. But there must be a way, since what I really want to extend is the list, not the grouping itself.

Is there another way to have the intended result using another way ?

fatiha.kafou
  • 71
  • 1
  • 13

2 Answers2

3

Augmenting a grouping is only possible when 'using' that grouping.

For example:

uses a:mygrouping {
    augment firstcontainer/modules {
        leaf thirdmodule {...}
    }
}

So this would need to be done every time the grouping is 'used'. YANG doesn't provide a way to augment a grouping abstractly, you can only do it on a per 'uses' basis.

Paulo Gomes
  • 156
  • 3
  • What if I have an enumeration inside that grouping ? Can I augment it ? – fatiha.kafou May 05 '20 at 14:41
  • 1
    No, enumerations cannot be augmented. For that, consider using identityrefs. Here's a good chapter on the YANG Guidelines RFC: https://tools.ietf.org/html/rfc8407#section-4.11.1 – Paulo Gomes May 09 '20 at 00:39
0
https://datatracker.ietf.org/doc/html/rfc7950#section-7.12




7.13.  The "uses" Statement

   The **"uses" statement is used to reference a "grouping" definition**.
   It takes one argument, which is the name of the grouping.

   The **effect of a "uses" reference to a grouping is that the nodes
   defined by the grouping are copied into the current schema tree and
   are then updated according to the "refine" and "augment" statements**.

   The identifiers defined in the grouping are not bound to a namespace
   until the contents of the grouping are added to the schema tree via a
   "uses" statement that does not appear inside a "grouping" statement,
   at which point they are bound to the namespace of the current module.
Deb
  • 587
  • 4
  • 12