Subject: [netmod] Recursive modeling in Yang?

From: Jeffrey Haas <[email-masked]>
Date: Thu, 11 Dec 2014 11:16:41 -0500

In http://tools.ietf.org/html/draft-wang-i2rs-rib-data-model-00, please
consider "container tunnel-encap":

        container tunnel-encap {
          uses tunnel-encap;
          choice nexthop-second-encap-or-not{
            case nexthop-second-encap{
              container nexthop-second-encap{
                description
                  "the two encapsulating nexthop.One example is a Pseudowire - which is MPLS over
                   some transport (MPLS or GRE for instance).  Another example is VxLAN
                   over IP.  ";
                uses tunnel-encap;
                choice nexthop-third-encap-or-not{
                  case nexthop-third-encap {
                    container nexthop-third-encap{
                      description
                        "the three encapsulating nexthop.One exampl is Option A -L3VPN OVER MPLS tunnel and MPLS over TE tunnel";
                      uses tunnel-encap;
[...]

My question to the yang experts are whether there's been any discussion
about generally recursive modeling?  In the data model above, five levels
are accommodated - thankfully using groupings.  This precludes a sixth or
later level of recursion.

Please note that I'm not looking to specifically discuss the contents of
this specific modeling, just its impact on the language.  Such constructs
may be common in certain types of routing modeling.

-- Jeff

---

From: Ladislav Lhotka <[email-masked]>
Date: Thu, 11 Dec 2014 17:26:58 +0100

Hi Jeff,

> On 11 Dec 2014, at 17:16, Jeffrey Haas <[email-masked]> wrote:
> 

Yes, this has already been discussed several times. It was a deliberate design decision to avoid recursive structures in YANG. They can be emulated via leafrefs though. For example, recursive next-hop-list is implemented this way in draft-ietf-netmod-routing-cfg-16.

Lada 

> _______________________________________________
> Rtg-yang-coord mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/rtg-yang-coord

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

---

From: t.petch <[email-masked]>
Date: Fri, 12 Dec 2014 09:36:45 +0000

netmod WG list 12apr2013

>> Recursive schemas are not allowed in YANG, and I believe it was a
>>design feature.
>>
>> Lada

15sep2014

Hello Vladimir,
I have been arguing to have recursive containment for quite some time.
Have a good number of use-cases to support.
regards Balazs

etc etc

Tom Petch

----- Original Message -----
From: "Jeffrey Haas" <[email-masked]>
To: <[email-masked]>; <[email-masked]>
Sent: Thursday, December 11, 2014 4:16 PM

>                         "the three encapsulating nexthop.One exampl is
Option A -L3VPN OVER MPLS tunnel and MPLS over TE tunnel";

---

From: Kent Watsen <[email-masked]>
Date: Fri, 12 Dec 2014 15:43:55 +0000

>Yes, this has already been discussed several times. It was a deliberate
>design decision to avoid recursive structures in YANG.

As I understand it, the decision was made was to enable parsers to be
deterministic.  Is that right?  - how is it then that other MLs (XSD) can
support recursion?

My hope is that YANG can support recursion by requiring a "max-depth" or
similar attribute.  Most of my use-cases only need a handful number of
recursions.  Could something like a max-depth attribute be used to enable
recursion in YANG?

Thanks,
Kent

---

From: Andy Bierman <[email-masked]>
Date: Fri, 12 Dec 2014 11:14:51 -0800

> recursions.  Could something like a max-depth attribute be used to enable

IMO the use of groupings and grouping expansion is not the right model
for schema recursion.  Automatic expansion to some arbitrary depth
is a hack.   Complex types that are not automatically expanded at all
are a better fit.  (YANG 2.0 discussions already?)

> Kent

Andy

---

From: Balazs Lengyel <[email-masked]>
Date: Thu, 18 Dec 2014 13:19:54 +0100

Hello,
I would still love to have recursive containment in YANG. I have a number of
  use cases where recursion is the natural, the" easy to understand" way 
to model.
E.g. we model HW parts as replaceable units (chassis, shelves, cabinets, 
cards, daughter cards, interfaces, etc).
There can be such a variety of containments, relationships, that the
easiest way is to use some global holding structure "replaceable unit" 
and let it contain itself.

And yes all this can be done by a simple list with references, but that 
has a number of disadvantages.

Just by allowing a grouping to contain itself, most of my use cases
would be solved. And maxdepth is a good idea.
Balazs

On 2014-12-12 16:43, Kent Watsen wrote:
> netmod mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/netmod
>
>

-- 
Balazs Lengyel                       Ericsson Hungary Ltd.
Senior Specialist
ECN: 831 7320                        Tel: +36-1-437-7320
Mobile: +36-70-330-7909              email: [email-masked]