Subject: [Rtg-yang-coord] Restrictions on list keys

From: Mahesh Jethanandani <[email-masked]>
Date: Sun, 1 Mar 2015 07:59:53 -0500

Pardon if these questions have already been asked.

Are there restrictions on the following use of keys in lists

- a combination of rw and ro leafs
- a ro leaf
- a union of of leafs

Mahesh Jethanandani
[email-masked]

---

From: Juergen Schoenwaelder <[email-masked]>
Date: Sun, 1 Mar 2015 22:43:45 +0100

RFC 6020 section 7.8.2:

   All key leafs in a list MUST have the same value for their "config"
   as the list itself.

/js

On Sun, Mar 01, 2015 at 07:59:53AM -0500, Mahesh Jethanandani wrote:
> _______________________________________________
> Rtg-yang-coord mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/rtg-yang-coord

-- 
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: Mahesh Jethanandani <[email-masked]>
Date: Sun, 1 Mar 2015 20:32:11 -0800

Juergen,

I did read that section but it was not clear to me. So here are some examples.

list foo {
      // Assuming one of these forms the key ...
      key “x y”; // is this valid?
      key “x z”;  // is this valid?
      key  “mode”; // is this valid? If not, how would I define a key for a choice statement?

      leaf x {
           type uint16;
      }

      leaf y {
          type uint8;
      }

      leaf z {
           type uint8;
           config false;
      }

      choice mode {
            case a {
                   leaf p {
                        type uint16;
                   }
           }
 
           case b {
                   leaf q {
                         type uint8;
                  }
           }
      }
}

> On Mar 1, 2015, at 1:43 PM, Juergen Schoenwaelder <[email-masked]> wrote:
> 
> RFC 6020 section 7.8.2:
> 

Mahesh Jethanandani
[email-masked]

---

From: Juergen Schoenwaelder <[email-masked]>
Date: Mon, 2 Mar 2015 06:56:49 +0100

>       key “x y”; // is this valid?

yes

>       key “x z”;  // is this valid?

if the list is config true, no

>       key  “mode”; // is this valid? If not, how would I define a key for a choice statement?

YANG 1.0 does not allow to have optional elements in a key.

---

From: Mahesh Jethanandani <[email-masked]>
Date: Mon, 02 Mar 2015 20:56:29 +0000

Juergen,

Thanks for the responses. One additional followup question. What happens in
case of a list, with a choice statement that is mandatory (see changed
below in the module). How would (or could one) one define a key using the
parameters in the 'choice mode' statement?

> <snip>

> YANG 1.0 does not allow to have optional elements in a key.
                  mandatory "true";

> >             case a {
> >                    leaf p {
> >                         type uint16;
> >                    }
> >            }
> >
> >            case b {
> >                    leaf q {
> >                          type uint8;
> >                   }
> >            }
> >       }
> > }
> >
> > > On Mar 1, 2015, at 1:43 PM, Juergen Schoenwaelder <
> [email-masked]> wrote:
> > >
> > > RFC 6020 section 7.8.2:
> > >

---

From: Juergen Schoenwaelder <[email-masked]>
Date: Mon, 2 Mar 2015 23:09:28 +0100

> parameters in the 'choice mode' statement?

The leafs listed in a key statement must exist for all elements of a
list. Hence, a branch in a choice cannot be a key even if the choice
itself is mandatory.

/js