schemamodelingietf-netmod-yang

Can a container inside a grouping be augmented in YANG?


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 ?


Solution

  • 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.