Subject: [netmod] Using an empty type in a list key

From: "Sterne, Jason (Nokia - CA)" <[email-masked]>
Date: Tue, 30 Aug 2016 22:17:10 +0000

Hi all,

I saw the addition of empty types in list keys in YANG 1.1 but had troubles finding more details in the NETMOD list.  Is it discussed in the YANG 1.1 issues page (and if so, where is that now ?  I tried an old link and it didn't work) ?

If I take this example where I have a set of a apartments 1,2,3 but there may also be occasional 'bis' apartments (e.g. 7bis).

list apartment {
    key "number bis";
    leaf number {
        type int16;
    }
    leaf bis {
        type empty;
    }
    leaf description {
         type string;
    }
}

Can I create list entries like this ?

<apartment>
    <number>5</number>
    <description>apartment 5</description>
<apartment>
<apartment>
    <number>8</number>
    <bis/>
    <description>apartment 8bis</description>
<apartment>
<apartment>
    <number>8</number>
    <description>apartment 8</description>
<apartment>

Doesn't the empty type have two states and the absence/presence of the leaf/tag indicates those states ?

I realize that a Boolean type could be used for bis but the use case (a question of preference/style) is that 'bis' is unusual and so it becomes noisy to have to set <bis>false</bis> all the time when creating apartment entries.  It may be useful to only have to specify <bis/> in the rare cases that it is needed.

Regards,
Jason

---

From: [email-masked] (Dale R. Worley)
Date: Wed, 31 Aug 2016 11:44:26 -0400

"Sterne, Jason (Nokia - CA)" <[email-masked]> writes:
> I saw the addition of empty types in list keys in YANG 1.1 but had
> troubles finding more details in the NETMOD list.  Is it discussed in
> the YANG 1.1 issues page (and if so, where is that now ?  I tried an
> old link and it didn't work) ?

> leaf/tag indicates those states ?

The empty type has two states in the fullest sense, but remember that
missing values are not treated as first-class values.  In particular, if
a leaf is a key for a list, the leaf element must be present in all list
elements:

   7.8.2.  The list's key Statement

   The combined values of all the leafs specified in the key are used to
   uniquely identify a list entry.  All key leafs MUST be given values
   when a list entry is created.  Thus, any default values in the key
   leafs or their types are ignored.  It also implies that any mandatory
   statement in the key leafs are ignored.

So a leaf with empty type can be included in the key, but since it
always has the same value, it has no effect.

Dale