Re: [yang-doctors] conditional default?

Christian Hopps <chopps@chopps.org> Sun, 23 May 2021 19:42 UTC

Return-Path: <chopps@chopps.org>
X-Original-To: yang-doctors@ietfa.amsl.com
Delivered-To: yang-doctors@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 8AB6F3A23C2 for <yang-doctors@ietfa.amsl.com>; Sun, 23 May 2021 12:42:30 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.897
X-Spam-Level:
X-Spam-Status: No, score=-1.897 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_NONE=0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
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 qVZXzuPCxDEu for <yang-doctors@ietfa.amsl.com>; Sun, 23 May 2021 12:42:24 -0700 (PDT)
Received: from smtp.chopps.org (smtp.chopps.org [54.88.81.56]) by ietfa.amsl.com (Postfix) with ESMTP id C269D3A23C0 for <yang-doctors@ietf.org>; Sun, 23 May 2021 12:42:24 -0700 (PDT)
Received: from ja.int.chopps.org.chopps.org (047-026-251-217.res.spectrum.com [47.26.251.217]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) by smtp.chopps.org (Postfix) with ESMTPSA id D5B8580E04; Sun, 23 May 2021 19:42:23 +0000 (UTC)
References: <m2mtsm9j3a.fsf@ja.int.chopps.org> <20210523.201707.196010256021596677.id@4668.se>
User-agent: mu4e 1.5.13; emacs 27.2
From: Christian Hopps <chopps@chopps.org>
To: Martin Björklund <mbj+ietf@4668.se>
Cc: chopps@chopps.org, yang-doctors@ietf.org
Date: Sun, 23 May 2021 15:08:32 -0400
In-reply-to: <20210523.201707.196010256021596677.id@4668.se>
Message-ID: <m2h7it9qzl.fsf@ja.int.chopps.org>
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="=-=-="; micalg="pgp-sha512"; protocol="application/pgp-signature"
Archived-At: <https://mailarchive.ietf.org/arch/msg/yang-doctors/xcLoLuxZHyIul3P7XNKkBGfUMdw>
Subject: Re: [yang-doctors] conditional default?
X-BeenThere: yang-doctors@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Email list of the yang-doctors directorate <yang-doctors.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/yang-doctors>, <mailto:yang-doctors-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/yang-doctors/>
List-Post: <mailto:yang-doctors@ietf.org>
List-Help: <mailto:yang-doctors-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/yang-doctors>, <mailto:yang-doctors-request@ietf.org?subject=subscribe>
X-List-Received-Date: Sun, 23 May 2021 19:42:31 -0000

Martin Björklund <mbj+ietf@4668.se> writes:

> Hi,
>
> Christian Hopps <chopps@chopps.org> wrote:
>>
>> I received this good question during the IESG review of geo location
>> module:
>>
>> > * Is WGS-84 still the default for geodetic-datum when astronomical-body
>> > * != "earth"?
>> > ...
>> > I don't know enough YANG to know if the "when" statement is usable in
>> > this case to constrain the applicability of this default or not.
>>
>> Is there a way to specify a conditional default in YANG?
>
> No.  But you can explain in the description statement what happens if
> the leaf doesn't have a value configured.

I figured I might could do this. It's a shame that it can't be specified though b/c once you start using a support library (e.g., libyang) default leaf values get auto created which is nice.

>> A separate but related issue I ran into the other day is that I have a
>> Boolean in a grouping that can default to true or false (in the actual
>> software) depending on where it is included... Also curious if that's
>> solvable.
>
> Yes, by using refine:
>
>   uses the-grouping {
>     refine the-leaf {
>       default "true";
>     }
>   }

In my case it's a grouping that uses another grouping so hopefully the refine in the final uses will reach into the inner grouping.

pyang is really not happy with the FRR BGP model so can't easily verify with that. (https://github.com/FRRouting/frr/tree/master/yang) probably has to do with the use of sub-modules, augments, groupings, etc.. its a great module for finding bugs. :)

Thanks,
Chris.

>
>
> /martin
>
>
>
>
>>
>> Thanks,
>> Chris.
>>
>> _______________________________________________
>> yang-doctors mailing list
>> yang-doctors@ietf.org
>> https://www.ietf.org/mailman/listinfo/yang-doctors