Subject: [netmod] Interaction of 'when' and 'default' statements

From: William Ivory <[email-masked]>
Date: Wed, 22 Mar 2017 17:35:28 +0000

Hi,

I'm looking for clarification of the 'when' and 'default' statements on a leaf.  For example, if a leaf has a 'default', can it also have a 'when' statement that could cause it to disappear if the 'when' condition evaluates to false?  Section 8.3 or RFC 6020 isn't clear on how evaluation of constraints should be done here, and neither the section on the 'when' statement nor the 'default' section have any cross-references.

Thanks,

William

---

From: Martin Bjorklund <[email-masked]>
Date: Wed, 22 Mar 2017 18:52:42 +0100 (CET)

William Ivory <[email-masked]> wrote:
> Hi,
> 
> I'm looking for clarification of the 'when' and 'default' statements
> on a leaf.  For example, if a leaf has a 'default', can it also have a
> 'when' statement that could cause it to disappear if the 'when'
> condition evaluates to false?

Yes, and in that case the default doesn't apply.

> Section 8.3 or RFC 6020 isn't clear on
> how evaluation of constraints should be done here, and neither the
> section on the 'when' statement nor the 'default' section have any
> cross-references.

If the "when" expression evaluates to false, it's like if the whole
node doesn't exist.  A client can't set it etc.

/martin

---

From: William Ivory <[email-masked]>
Date: Wed, 22 Mar 2017 17:55:31 +0000

Hi Martin,

Thanks.  Can you point me at the part of RFC 6020 that explicitly states that 'when' wins over 'default'?

William

-----Original Message-----
From: Martin Bjorklund [mailto:[email-masked]] 
Sent: 22 March 2017 17:53
To: William Ivory <[email-masked]>
Cc: [email-masked]; Nick Brown <[email-masked]>
Subject: Re: [netmod] Interaction of 'when' and 'default' statements

> Section 8.3 or RFC 6020 isn't clear on how evaluation of constraints 
> should be done here, and neither the section on the 'when' statement 
> nor the 'default' section have any cross-references.

If the "when" expression evaluates to false, it's like if the whole node doesn't exist.  A client can't set it etc.

/martin

---

From: "Bogaert, Bart (Nokia - BE/Antwerp)" <[email-masked]>
Date: Wed, 22 Mar 2017 17:59:01 +0000

William,

The when clause determines whether the node will be instantiated or not.
Only when it is instantiated (when condition evaluates to true), the default
property comes into the picture.  At least, that is how I interpret it.

Best regards - Vriendelijke groeten,
Bart Bogaert

-----Original Message-----
From: netmod [mailto:[email-masked]] On Behalf Of William Ivory
Sent: 22 March 2017 18:56
To: Martin Bjorklund <[email-masked]>
Cc: Nick Brown <[email-masked]>; [email-masked]
Subject: Re: [netmod] Interaction of 'when' and 'default' statements

Hi Martin,

Thanks.  Can you point me at the part of RFC 6020 that explicitly states
that 'when' wins over 'default'?

William

-----Original Message-----
From: Martin Bjorklund [mailto:[email-masked]]
Sent: 22 March 2017 17:53
To: William Ivory <[email-masked]>
Cc: [email-masked]; Nick Brown <[email-masked]>
Subject: Re: [netmod] Interaction of 'when' and 'default' statements

> nor the 'default' section have any cross-references.

If the "when" expression evaluates to false, it's like if the whole node
doesn't exist.  A client can't set it etc.

/martin

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

---

From: Martin Bjorklund <[email-masked]>
Date: Wed, 22 Mar 2017 19:23:00 +0100 (CET)

> states that 'when' wins over 'default'?

Section 7.6.1 of RFC 7950 says:

   Note that if the leaf or any of its ancestors has a "when" condition
   or "if-feature" expression that evaluates to "false", then the
   default value is not in use.

/martin

---

From: [email-masked] (Dale R. Worley)
Date: Thu, 23 Mar 2017 10:43:54 -0400

>    default value is not in use.

Or perhaps more to the point, beware that RFC 6020 does *not* have that
paragraph.

Dale

---

From: William Ivory <[email-masked]>
Date: Thu, 23 Mar 2017 14:47:12 +0000

Yes, I'd noticed that.  Does this make the behaviour 'undefined' in YANG 1.0?

William

-----Original Message-----
From: Dale R. Worley [mailto:[email-masked]] 
Sent: 23 March 2017 14:44
To: Martin Bjorklund <[email-masked]>
Cc: William Ivory <[email-masked]>; Nick Brown <[email-masked]>; [email-masked]
Subject: Re: [netmod] Interaction of 'when' and 'default' statements

>    default value is not in use.

Or perhaps more to the point, beware that RFC 6020 does *not* have that paragraph.

Dale

---

From: Phil Shafer <[email-masked]>
Date: Thu, 23 Mar 2017 16:24:04 -0400

>Yes, I'd noticed that.  Does this make the behaviour 'undefined' in YANG 1.0?

No, this was a clarification.  The text in 6020 was reasonably clear:

   The "when" statement makes its parent data definition statement
   conditional.  The node defined by the parent data definition
   statement is only valid when the condition specified by the "when"
   statement is satisfied.

And no default should be provided for any invalid node.  If the node
can't exist, the default can't either.

Thanks,
 Phil

---

From: t.petch <[email-masked]>
Date: Fri, 24 Mar 2017 17:30:54 +0000

----- Original Message -----
From: "Phil Shafer" <[email-masked]>
Sent: Thursday, March 23, 2017 8:24 PM

William

Having tracked the discussions that led to RFC7950, the sense I got was
that if you can avoid using 'when' then avoid using it.  If you cannot
avoid using 'when' avoid using it.  Not something that is ever likely to
appear in an I-D but the 'when' statement does have complex interactions
that may not be intuitive and although RFC7950 does spell them out, yet
they may not be apparent; which this thread also spells out to me:-)

I would not say this of any other YANG statement.

Tom Petch