Re: [netmod] Questions about how to assign default values with YANG

Ladislav Lhotka <ladislav.lhotka@nic.cz> Tue, 09 March 2021 16:46 UTC

Return-Path: <ladislav.lhotka@nic.cz>
X-Original-To: netmod@ietfa.amsl.com
Delivered-To: netmod@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 5A80D3A137B for <netmod@ietfa.amsl.com>; Tue, 9 Mar 2021 08:46:49 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.119
X-Spam-Level:
X-Spam-Status: No, score=-2.119 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=nic.cz
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id E3DVKuT-HRjO for <netmod@ietfa.amsl.com>; Tue, 9 Mar 2021 08:46:47 -0800 (PST)
Received: from mail.nic.cz (mail.nic.cz [217.31.204.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id D6F103A0F09 for <netmod@ietf.org>; Tue, 9 Mar 2021 08:46:46 -0800 (PST)
Received: from localhost (unknown [IPv6:2001:1488:fffe:6:a88f:7eff:fed2:45f8]) by mail.nic.cz (Postfix) with ESMTPSA id 004F114098F; Tue, 9 Mar 2021 17:46:43 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1615308404; bh=J/T4u8DszKzGUtwkft+m42l6Hiz8fokUiAreYfDCz4Q=; h=From:To:Date; b=kDsGoh3Ir8Mw0BwZCw5YlwOOeZv9oKk+BeNtc8BpJeYn4xMBWaKZqWdpKi+DMsjGP YisIwiW2rkoHyk6OQS/8MbyPfXZiovDAughw1hW+RE+pFhkn8pgaZV8kbOzsYWxFO9 No+88mNI06O4oElrCOaHo2/YEgeDHuQmLlFEMsPY=
From: Ladislav Lhotka <ladislav.lhotka@nic.cz>
To: Italo Busi <Italo.Busi@huawei.com>, 'Juergen Schoenwaelder' <j.schoenwaelder@jacobs-university.de>
Cc: "'netmod@ietf.org'" <netmod@ietf.org>
In-Reply-To: <521a9ccd02e14d178a6e62971b4809ea@huawei.com>
References: <a0c43ab5c3c1463a97a1aa594a80ceee@huawei.com> <20210120094737.g5l5pvfzligahrj6@anna.jacobs.jacobs-university.de> <2384a8f549c94ea0ac46d6c772fbca43@huawei.com> <20210120114446.ovih63db7vmv7c7s@anna.jacobs.jacobs-university.de> <0ed5638881af42148720dd7f4843c3e6@huawei.com> <20210120160517.hsg5dnpidvrprtso@anna.jacobs.jacobs-university.de> <521a9ccd02e14d178a6e62971b4809ea@huawei.com>
Mail-Followup-To: Italo Busi <Italo.Busi@huawei.com>, 'Juergen Schoenwaelder' <j.schoenwaelder@jacobs-university.de>, "'netmod@ietf.org'" <netmod@ietf.org>
Date: Tue, 09 Mar 2021 17:46:43 +0100
Message-ID: <87sg54cm18.fsf@nic.cz>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
X-Virus-Scanned: clamav-milter 0.102.2 at mail
X-Virus-Status: Clean
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/q3x2lA7jsntNBuJ7SSTXVsZS-Rc>
Subject: Re: [netmod] Questions about how to assign default values with YANG
X-BeenThere: netmod@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: NETMOD WG list <netmod.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/netmod>, <mailto:netmod-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/netmod/>
List-Post: <mailto:netmod@ietf.org>
List-Help: <mailto:netmod-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/netmod>, <mailto:netmod-request@ietf.org?subject=subscribe>
X-List-Received-Date: Tue, 09 Mar 2021 16:46:49 -0000

Italo Busi <Italo.Busi@huawei.com> writes:

> Hi Juergen,
>
> Thanks again for your clear explanation on this topic
>
> I have found a similar but slightly different issue. In this case, a YANG default statement exists in the base module but the intention with the augmentation is to "overwrite" the default value on the basis of another attribute, defined in the module which augments the base module.
>
> For example, I am wondering whether such a code is valid:

Yes, this is valid, I'd just suggest:

- remove the default statement for "foo", as it may be confusing to both humans and tools

- specify the default (both cases) in the description of "foo"

A similar example is in the module ietf-ipv6-router-advertisements, e.g. leaf "min-rtr-adv-interval":

https://www.rfc-editor.org/rfc/rfc8349.html#section-9.1

Lada

>
> module example-base {
>   container example {
>     leaf foo {
>       type uint8;
>       default 0;
>     }
>   }
> }
>
> module example-augment {
>   import example {
>     prefix ex;
>   }
>
>   augment "ex:example" {
>     leaf bar {
>       type empty;
>       description
>         "When present, the default value for foo is 10.";
>     }
>   }
> }
>
>
> In this case, when the leaf foo is not configured but the leaf bar is present, the value of foo in the operational datastore should be 10 (rather than 0).
>
> In this case, I think that it would be better/cleaner if the origin is marked as system.
>
> Maybe a better YANG description for bar could be: "When present, the system overrides the default value of foo to 10."
>
> What is your and/or WG opinion?
>
> Thanks again
>
> Italo
>
>> -----Original Message-----
>> From: Juergen Schoenwaelder [mailto:j.schoenwaelder@jacobs-university.de]
>> Sent: mercoledì 20 gennaio 2021 17:05
>> To: Italo Busi <Italo.Busi@huawei.com>
>> Cc: 'netmod@ietf.org' <netmod@ietf.org>
>> Subject: Re: [netmod] Questions about how to assign default values with
>> YANG
>>
>> On Wed, Jan 20, 2021 at 02:41:39PM +0000, Italo Busi wrote:
>> >
>> > What about the case the leaf is not conditional (but still mandatory false
>> since a YANG default statement is defined)?
>> >
>> > May the server still decide not to use/implement this leaf in the operational
>> datastore?
>> >
>> > For example, in appendix C.1 of RFC8342, auto-negotiation is enabled by
>> default.
>> > What should be the behavior of a system which does not implement auto-
>> negotiation?
>> > Return the value false or no value (in the operational datastore)?
>> >
>>
>> Here are some of the rules I personally like:
>>
>>  - <operational> is the ground truth about what a system has and does
>>  - do not implement leafs that do not apply
>>
>> Hence, interfaces supporting auto-negotiation have either auto-
>> negotiation/enabled = true or auto-negotiation/enabled = false in
>> <operational>. And interfaces not supporting auto-negotiation have nothing
>> to report about auto-negotiation. Yes, I do not want to see auto-
>> negotiation/enabled = false on a loopback interface.
>>
>> My historic Ethernet interface from the last century would also not report
>> auto-negotiation/enabled in <operational>. You may hit applications that love
>> to have auto-negotiation/enabled available on all Ethernet interfaces and then
>> you end in a debate where the application developers tell you that no
>> information in <operational> may have many reasons (instrumentation not
>> implemented, access control rules, whatever and by reporting enabled=false
>> you do them a favor) but the true answer in such a debate is often that
>> modeling things as a boolean is simplistic since there are often more than
>> exactly two states (in this case, enabled, disabled, failed, not-available, ...).
>> So you settle on blaming the model writer. ;-)
>>
>> /js
>>
>> --
>> Juergen Schoenwaelder           Jacobs University Bremen gGmbH
>> Phone: +49 421 200 3587         Campus Ring 1 | 28759 Bremen | Germany
>> Fax:   +49 421 200 3103         <https://www.jacobs-university.de/>
>
> _______________________________________________
> netmod mailing list
> netmod@ietf.org
> https://www.ietf.org/mailman/listinfo/netmod

-- 
Ladislav Lhotka
Head, CZ.NIC Labs
PGP Key ID: 0xB8F92B08A9F76C67