Subject: [yang-doctors] conditional default?

From: Christian Hopps <[email-masked]>
Date: Sun, 23 May 2021 00:14:08 -0400

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?

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.

Thanks,
Chris.

---

From: Martin Björklund <[email-masked]>
Date: Sun, 23 May 2021 20:17:07 +0200 (CEST)

Hi,

Christian Hopps <[email-masked]> wrote:
> > * 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.
> 

No.  But you can explain in the description statement what happens if
the leaf doesn't have a value configured.

> 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";
    }
  }

/martin

> 
> Thanks,
> Chris.
> 
> _______________________________________________
> yang-doctors mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/yang-doctors

---

From: Christian Hopps <[email-masked]>
Date: Sun, 23 May 2021 15:08:32 -0400

> 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.

>> software) depending on where it is included... Also curious if that's

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.