Subject: Re: [netmod] 2 YANG 1.1 questions

From: Martin Bjorklund <[email-masked]>
Date: Mon, 01 Feb 2016 10:44:57 +0100 (CET)

Andy Bierman <[email-masked]> wrote:
> Hi,
> 
> 
> 1) leafref with a default-stmt
> 
>   list int {
>     key "name type";
>     leaf name { type string; }
>     leaf type { type string; }
>     leaf enabled { type boolean; }
>   }
> 
>   typedef lref1 {
>     type leafref { path "/int/name"; }
>     default "t0";
>   }
> 
> This has the save effect as top-level mandatory nodes.
> The require-instance is 'true' so the YANG validation will fail
> at boot-time unless a list 'int' entry name is 't0'.
> 
> I plan to add a YANG usage guide not to give configuration
> leafref nodes a default value. Any objections or another plan?

I think this is a good idea.  I suggest the same recommendation for
instance-identifiers.

> 2) instance-identifier encoding for key type 'empty'.
> 
>   list int2 {
>     key "test test2";
>     leaf test { type empty; }
>     leaf test2 { type empty; }
>     leaf type { type string; }
>   }
> 
> Now that the empty type is allowed for a key leaf,
> the <error-path> and any instance-identifier type needs to
> have encoding rules defined. (e.g. an instance of /int2/type)

Good catch, this needs to be clarified.  Since the i-i is a XPath, and
we don't want to change the underlying syntax of an i-i, we need to do:

   /x:int2[x:test=""][x:test2=""]

This can be used directly in e.g. an XPath filter to return the
correct node, if it exists.

I suggest we do this change to the second paragraph of 9.13, and add
an example to 9.13.4:

OLD:

   For
   identifying list entries with keys, each predicate consists of one
   equality test per key, and each key MUST have a corresponding
   predicate.

NEW:

   For
   identifying list entries with keys, each predicate consists of one
   equality test per key, and each key MUST have a corresponding
   predicate.  If a key is of type "empty", it is represented as a
   zero-length string ("").

New example:

  /* instance-identifier for a list entry where the second
     key ("enabled") is of type empty */
  /ex:system/ex:service[ex:name='foo'][ex:enabled='']

/martin