Subject: [netmod] How to model a leafref in union conforming to RFC6020?

From: "GUBALLA, JENS (JENS)" <[email-masked]>
Date: Fri, 11 Dec 2015 09:29:58 +0000

Hi,

According to RFC6020 a leafref within a union is not allowed. This issue is
captured by Y30 of the yang1.1 issue list.

My question: how can such a construct as show below be modeled conforming to
RFC6020?

    leaf the_reference {type uint8;}
    leaf something {
        type union {
            type leafref {
                path "../the_reference";
            }
            type enumeration {
                enum "none";
                enum "something-else";
            }
        }
    }

Has anyone any ideas or can someone provide me a pointer if this has been
discussed already?

Thanks,
Jens

---

From: Ladislav Lhotka <[email-masked]>
Date: Fri, 11 Dec 2015 11:51:00 +0100

> On 11 Dec 2015, at 10:29, GUBALLA, JENS (JENS) <[email-masked]> wrote:
> 
> Hi,
> 

You can define the first union member simply as uint8, without being formally coupled with "the_reference". I'd suggest to use YANG 1.1 though where that CLR was removed.

Lada

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

--
Ladislav Lhotka, CZ.NIC Labs
PGP Key ID: E74E8C0C

---

From: "GUBALLA, JENS (JENS)" <[email-masked]>
Date: Fri, 11 Dec 2015 13:40:50 +0000

Hi Lada,

> -----Original Message-----
> From: Ladislav Lhotka [mailto:[email-masked]]
> Sent: Freitag, 11. Dezember 2015 11:51
> To: GUBALLA, JENS (JENS)
> Cc: [email-masked]
> Subject: Re: [netmod] How to model a leafref in union conforming to
> RFC6020?
> 
> 
> > According to RFC6020 a leafref within a union is not allowed. This
> > issue is captured by Y30 of the yang1.1 issue list.
> >
> > My question: how can such a construct as show below be modeled
> > conforming to RFC6020?
> >
> > Has anyone any ideas or can someone provide me a pointer if this has
> > been discussed already?
> 
> You can define the first union member simply as uint8, without being
> formally coupled with "the_reference". I'd suggest to use YANG 1.1
> though where that CLR was removed.
[JG] Thanks a lot for your suggestions. Replacing "type leafref" by "type
unit8" would mean to lose the semantic of the leafref type. Thus

    <the_reference>5</the_reference>
    <something>4</something>

would unfortunately be regarded as compliant to the model.

On the other hand the data model should be Yang1.0 compliant. So I want to
check if there is any other solution to the issue.

Best regards,
Jens

---

From: Martin Bjorklund <[email-masked]>
Date: Fri, 11 Dec 2015 14:50:20 +0100 (CET)

> check if there is any other solution to the issue.

Another common way to handle this is to do a choice of two leafs:

   choice s {
     leaf something-as-leafreaf { type leafreaf ... }
     leaf something-as-enum { ... }
   }

/martin

---

From: Jernej Tuljak <[email-masked]>
Date: Fri, 11 Dec 2015 14:58:07 +0100

> check if there is any other solution to the issue.

Add a (very specific) must constraint to the "something" leaf? Something 
along the lines of:

leaf the_reference {type uint8;}
   leaf something {
     must "(not(number()) and not(. = 0)) or . = /the_reference";
     type union {
       type uint8;
       type enumeration {
         enum "none";
         enum "something-else";
       }
     }
   }

for this particular example. Ugly, yes, but (probably) works. The above 
requires "not a number or same as 'the_reference'".

Jernej