Subject: [netmod] Is this leafref path example valid in YANG 1?

From: "Jernej Tuljak" <[email-masked]>
Date: Tue, 23 Aug 2016 16:13:23 +0200

Hi,

this is a YANG 1, not 1.1 question. 

For the following example:

module main {

    namespace "uri:main";

    prefix "m";

    include a;

    include b;

}

submodule a {

    belongs-to main {

        prefix "a";

    }

    include b;

    container top {

        leaf top-leaf {

            type string;

        }

        uses foo;

    }    

}

submodule b {

    belongs-to main {

        prefix "b";

    }

    grouping foo {

        leaf some-leaf {

            type leafref {

                path "/top/top-leaf";

            }

        }

    }

}

Note the "path" expression that is referencing names that do not seem to be in b's scope. Is this a valid "path" expression (names resolved upon usage) or should all names inside the "grouping" be resolved where the "grouping" is defined? 

Jernej

---

From: Juergen Schoenwaelder <[email-masked]>
Date: Fri, 26 Aug 2016 14:50:16 +0200

> this is a YANG 1, not 1.1 question. 

[...]
 
> Note the "path" expression that is referencing names that do not
> seem to be in b's scope. Is this a valid "path" expression (names
> resolved upon usage) or should all names inside the "grouping" be
> resolved where the "grouping" is defined?

RFC 6020 says in section 7.12:

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

This makes me believe that the uses statement should resolve things
to this:

submodule a {

    belongs-to main {
        prefix "a";
    }
    include b;

    container top {
        leaf top-leaf {
            type string;
        }
        leaf some-leaf {
            type leafref {
                path "/top/top-leaf";
            }
        }
    }
}

Other opinions? The text quoted from RFC 6020 only talks specifically
about identifiers but I would assume that the same late binding applies
to path statement arguments.

/js

-- 
Juergen Schoenwaelder           Jacobs University Bremen gGmbH
Phone: +49 421 200 3587         Campus Ring 1 | 28759 Bremen | Germany
Fax:   +49 421 200 3103         <http://www.jacobs-university.de/>

---

From: Martin Bjorklund <[email-masked]>
Date: Fri, 26 Aug 2016 16:08:29 +0200 (CEST)

> to path statement arguments.

This is issue #Y05.  The problem is that is not clear from RFC 6020
what the right answer is.

SO, the question was "is this legal YANG 1?", and the answer is
"unclear".  With the follow-up answer "if you need this, use YANG
1.1".

/martin