Subject: [netmod] Conditional default values?

From: Reshad Rahman <[email-masked]>
Date: Wed, 23 Feb 2022 22:37:21 +0000 (UTC)

Hi,
My understanding is that we don't have any construct to easily do conditional default values. e.g. let's say I want interface MTU to have default 1500 for all types except 1. I tried by having conditional leaf nodes (using when on type) but I can't have duplicate leaf-nodes in the schema, even if the 2 when statements can never be true at the same time. Suggestions?
Regards,Reshad.

---

From: Andy Bierman <[email-masked]>
Date: Wed, 23 Feb 2022 15:12:11 -0800

On Wed, Feb 23, 2022 at 2:37 PM Reshad Rahman <reshad=
[email-masked]> wrote:

> Hi,
>
> My understanding is that we don't have any construct to easily do
> conditional default values. e.g. let's say I want interface MTU to have
> default 1500 for all types except 1. I tried by having conditional leaf
> nodes (using when on type) but I can't have duplicate leaf-nodes in the
> schema, even if the 2 when statements can never be true at the same time.
> Suggestions?
>
>

You can make clever use of the "union" data type to allow different
defaults.
You cannot really represent the conditions to pick a member type (except
description).

Regards,
> Reshad.

Andy

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

---

From: "Sterne, Jason (Nokia - CA/Ottawa)" <[email-masked]>
Date: Fri, 25 Feb 2022 16:02:52 +0000

Yeah - I don't think there is any way for YANG to really express different defaults (i.e. dynamic defaults that depend on some other condition, e.g. which list item, etc).

The YANG default statement is really only for leafs that have a static default value (i.e. always the same).

In this case the best you can do is have no YANG "default" statement and maybe describe the situation in the description (which won't really be machine readable).

Jason

From: netmod <[email-masked]> On Behalf Of Andy Bierman
Sent: Wednesday, February 23, 2022 6:12 PM
To: Reshad Rahman <[email-masked]>
Cc: NetMod WG <[email-masked]>
Subject: Re: [netmod] Conditional default values?

On Wed, Feb 23, 2022 at 2:37 PM Reshad Rahman <reshad=[email-masked]<mailto:[email-masked]>> wrote:
Hi,

You can make clever use of the "union" data type to allow different defaults.
You cannot really represent the conditions to pick a member type (except description).

Regards,
Reshad.

Andy

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