Subject: [netmod] some questions about leaf

From: [email-masked]
Date: Wed, 14 May 2014 09:39:47 +0800

Hi all,
   I have some questions about usage of leaf.
   1. Non-mandatory leaf must have default value? or non-mandatory leaf 
with config true must have default value?
      for example:
      If a list contains a optional leaf node, if this leaf node has no 
default value, 
      when a list instance is created ,what this leaf'value will be?

   2. can leaf node support create operation?
      If a leaf node must have default value, obviously create operation 
can not be supported.

   3. How to resolve the problem that a leaf node can not be defined a 
static default value, but it has a uncertain default value when it is 
created?
      For example:
      list foo {
           key name;
      leaf name {...}
      leaf type {
           type enumeration {
                enum foo1 {...}
                enum foo2 {...}
           }
      }
      leaf value {...}

      }

      If list 'foo' is created, if leaf named 'type''s value is foo1, the 
default value of leaf named 'value' is 10,
      if leaf named 'type''s value is foo2, the default value of leaf 
named  'value' is 20.

      Solution:
      1. Add when statement as default's substatement.
      2. Leaf supports multi default statement.
 
      For example:
      leaf value {
           default 10 {
              when "type == foo1";
           }
           default 20 {
              when "type == foo2";
           }
           type int32;
      } 

      Martin, can this issue can be added to YANG1.1 issues? 
/frank
--------------------------------------------------------
ZTE Information Security Notice: The information contained in this mail (and any attachment transmitted herewith) is privileged and confidential and is intended for the exclusive use of the addressee(s).  If you are not an intended recipient, any disclosure, reproduction, distribution or other dissemination or use of the information contained is strictly prohibited.  If you have received this mail in error, please delete it and notify us immediately.

---

From: Ladislav Lhotka <[email-masked]>
Date: Wed, 14 May 2014 08:39:13 +0200

On 14 May 2014, at 03:39, [email-masked] wrote:

>    1. Non-mandatory leaf must have default value? or non-mandatory leaf with config true must have default value?

No to both questions.

>  
>       for example: 
>       If a list contains a optional leaf node, if this leaf node has no default value, 

It depends:

- either the value doesn’t exist (e.g. if you don’t define an alias to a user name, there is none),
- or the server chooses some value for *operational* use.

>       If a leaf node must have default value, obviously create operation can not be supported. 
> 
>    3. How to resolve the problem that a leaf node can not be defined a static default value, but it has a uncertain default value when it is created? 
>       For example: 
>       list foo { 
>            key name; 
>       leaf name {...} 
>       leaf type { 
>            type enumeration { 
>                 enum foo1 {...} 
>                 enum foo2 {...} 
>            } 
>       } 
>       leaf value {...} 
> 
>       } 
> 
>       If list 'foo' is created, if leaf named 'type''s value is foo1, the default value of leaf named 'value' is 10, 
>       if leaf named 'type''s value is foo2, the default value of leaf named  'value' is 20.

The solution is to specify this in a description.

>       2. Leaf supports multi default statement. 

I am against doing this. Such a use of ‘when’ would suffer from the same problem as in Y18 (missing context node), and it could also lead to race conditions, for example if defaults of two leafs depend on each other.

Moreover, there are other ways how dynamic defaults may be derived. For example, if default-lifetime is not configured for IPv6 router advertisements, the value of 3*max-rtr-adv-interval should be used (operationally).

>       Martin, can this issue can be added to YANG1.1 issues?

Note that the issue list was closed on May 7.

Lada

> _______________________________________________
> netmod mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/netmod

--
Ladislav Lhotka, CZ.NIC Labs
PGP Key ID: E74E8C0C

---

From: [email-masked]
Date: Wed, 14 May 2014 14:59:08 +0800

/frank

Ladislav Lhotka <[email-masked]> 写于 2014-05-14 14:39:13:

> Ladislav Lhotka <[email-masked]> 
> 2014-05-14 14:39
> 
> 收件人
> 
> [email-masked], 
> 
> 抄送
> 
> [email-masked], [email-masked]
> 
> 主题
> 
> Re: [netmod] some questions about leaf
> 
> 
> >    1. Non-mandatory leaf must have default value? or non-mandatory
> leaf with config true must have default value?
> 
> No to both questions.
> 
> > 
> >       for example: 
> >    3. How to resolve the problem that a leaf node can not be 
> defined a static default value, but it has a uncertain default value
> when it is created? 
> >       For example: 
> >       list foo { 
> >            key name; 
> >       leaf name {...} 
> >       leaf type { 
> >            type enumeration { 
> >                 enum foo1 {...} 
> >                 enum foo2 {...} 
> >            } 
> >       } 
> >       leaf value {...} 
> > 
> >       } 
> > 
> >       If list 'foo' is created, if leaf named 'type''s value is 
> foo1, the default value of leaf named 'value' is 10, 
> I am against doing this. Such a use of ‘when’ would suffer from the 
> same problem as in Y18 (missing context node), and it could also 
> lead to race conditions, for example if defaults of two leafs depend
> on each other.
> 

I do know it, but dynamic defaults needs to be defined in my practice.
Network manager wants to know it. I think a valid model have no problem 
you mentioned.
It only adds some difficulty to YANG parser. 

> Moreover, there are other ways how dynamic defaults may be derived. 
> For example, if default-lifetime is not configured for IPv6 router 
> advertisements, the value of 3*max-rtr-adv-interval should be used 
> (operationally).

I don't understand it. Can YANG express this using exist syntax?
> > ZTE Information Security Notice: The information contained in this
> mail (and any attachment transmitted herewith) is privileged and 
> confidential and is intended for the exclusive use of the addressee
> (s).  If you are not an intended recipient, any disclosure, 
> reproduction, distribution or other dissemination or use of the 
> information contained is strictly prohibited.  If you have received 
> this mail in error, please delete it and notify us immediately.
> > 
> > 
> >

---

From: Ladislav Lhotka <[email-masked]>
Date: Wed, 14 May 2014 09:14:00 +0200

On 14 May 2014, at 08:59, [email-masked] wrote:

> Network manager wants to know it. I think a valid model have no problem you mentioned. 

No, as you can see in the module ietf-ipv6-unicast-routing, this is stated in that leaf’s description. See also the description of 'min-rtr-adv-interval’ where the procedure for choosing the default is even more complicated.

It is not only here that descriptions are used for specifying semantics of server operation, and it is intentional.

Lada

---

From: Andy Bierman <[email-masked]>
Date: Wed, 14 May 2014 07:30:13 -0700

> > It only adds some difficulty to YANG parser.

There is a difference between a default value that is
dynamically selected by the server, and a dynamic default
that keeps changing, based on evaluation of arbitrary when-stmts.
Perhaps the intent here is to evaluate the when-stmts only once?

What happens if when-stmts overlap and multiple true conditions exist?
What happens if the when-stmts from different leafs affect
each other, preventing both leafs from setting a stable default?

The description-stmt is good enough for complex defaults.
If the NMS developer cares enough they can read the YANG module.
The point of defaults are to allow the server to pick reasonable
initial values so the client can ignore those nodes.

> No, as you can see in the module ietf-ipv6-unicast-routing, this is stated
> in that leaf’s description. See also the description of
> 'min-rtr-adv-interval’ where the procedure for choosing the default is even
> more complicated.
>

Andy

> > ZTE Information Security Notice: The information contained in this mail
> (and any attachment transmitted herewith) is privileged and confidential
> and is intended for the exclusive use of the addressee(s).  If you are not
> an intended recipient, any disclosure, reproduction, distribution or other
> dissemination or use of the information contained is strictly prohibited.
>  If you have received this mail in error, please delete it and notify us
> immediately.
> >
> >
> >
>
> --