ConfD User Community

Yang module namespace during running time


#1

Each yang module needs to have an unique namespace. After the yang files be compiled and load in confd, I found each node defined in yang schema will have its own namespace which can be different from the namespace defined in yang file if the keyword “grouping” and “uses” be used.

Assuming I have two modules

module b
{
   namespace : http://ns/b
   grouping g-b {
        container b
   }
}

module a
{
   namespace : http://ns/a
   prefix: prefix-a;
   uses g-b;
   container a1;
}

module c
{
  namespace :http://ns/c
  augment prefix-a:a1
  {
    uses g-b;
  }
}

Durning running time:

  1. “container b” directly under module a will have the namespace “http://ns/a
  2. “container b” inside the container “prefix-a:a1” will have the namespace “http://ns/c

So my conclusion is
The nodes namespace depend on where the nodes be instantiated.
Case 1: “container b” is instantiated in module a using keyword “uses”. So it has the namespace “http://ns/a
Case 2: “container b” is instantiated in module c using keyword “augment” and “uses”. So it has the namespace “http://ns/c”.

I can’t find the reference which explain how the namespace be determined during running time. I wonder whether my conclusion is correct? Any other exception ?

Thanks in advance!


#2

Yes - the behavior you observe is specified in https://tools.ietf.org/html/rfc7950#section-7.13 - The “uses” Statement:

   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.

No.


#3

Thank you for the reference.