Subject: [netmod] Modeling recursive containment

From: Balazs Lengyel <[email-masked]>
Date: Fri, 12 Apr 2013 16:34:14 +0200

Hello,
How is it possible to model recursive containment in YANG?
- I want a list representing some managed object e.g. a directory in a 
file system, that can contain a directory in the file system, that can 
contain a directory in a file system ...
- I have a HW module (which can be a slot, a subrack a card, a chassis, 
etc.) which can contain a HW module, ...

What is the best way to do this?
- Using references does not seem to be the best solution. Many tools 
follow containment easily while following references is much more limited.
- Grouping explicitly forbids this kind of construct.

regards Balazs

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

---

From: Ladislav Lhotka <[email-masked]>
Date: Fri, 12 Apr 2013 16:39:55 +0200

Hi Balazs,

On Apr 12, 2013, at 4:34 PM, Balazs Lengyel <[email-masked]> wrote:

> - I want a list representing some managed object e.g. a directory in a file system, that can contain a directory in the file system, that can contain a directory in a file system ...
> - I have a HW module (which can be a slot, a subrack a card, a chassis, etc.) which can contain a HW module, ...
> 
> - Using references does not seem to be the best solution. Many tools follow containment easily while following references is much more limited.

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

Lada

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

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

---

From: Balazs Lengyel <[email-masked]>
Date: Fri, 12 Apr 2013 18:12:10 +0200

> Recursive schemas are not allowed in YANG, and I believe it was a design feature.
Sadly the real world does not seem to agree with this design decision, 
which I hated originally as well.
So is there anything better then anyXml?
Balazs

---

From: Ladislav Lhotka <[email-masked]>
Date: Fri, 12 Apr 2013 19:01:16 +0200

On Apr 12, 2013, at 6:12 PM, Balazs Lengyel <[email-masked]> wrote:

> Sadly the real world does not seem to agree with this design decision, which I hated originally as well.

Leafrefs, as you wrote. Actually, this is how interface stacks are supposed to be implemented.

Lada

---

From: Kent Watsen <[email-masked]>
Date: Mon, 15 Apr 2013 20:25:46 +0000

Hey Balazs,

I asked the same question, and for the same reason, 2-3 years agoŠ

I wound up modeling a "worst-case" containment depth:

<SNIP>
    grouping component-type {
        leaf model-number {
           type string;
           description "The component's model-number";
        }
        leaf part-number {
           type string;
           description "The component's part-number";
        }
        leaf part-version {
           type string;
           description "The component's part-version";
        }
        leaf serial-number {
           type string;
           description "The component's serial-number";
        }
        description
           "this type is used by both the top-level chassis element
            as well as \"recursively\" by its subcomponents";
    }

    grouping subcomponent-type {
        uses component-type;
        leaf location-id {
            type string;
            mandatory true;
        }
    }

    rpc get-hardware-inventory {
        description
            "Provides the hardware inventory on the device as a
             hierarchy of components rooted by a special component
             called \"chassis\".
        output {
            container hardware-inventory {
                container chassis {
                    uses component-type;
                    list subcomponent {
                        uses subcomponent-type;
                        list subcomponent {
                            uses subcomponent-type;
                            list subcomponent {
                                uses subcomponent-type;
                                list subcomponent {
                                    uses subcomponent-type;
                                    list subcomponent {
                                        uses subcomponent-type;
                                        list subcomponent {
                                            uses subcomponent-type;
                                            list subcomponent {
                                                uses subcomponent-type;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
</SNIP>

Kent

On 4/12/13 12:12 PM, "Balazs Lengyel" <[email-masked]> wrote:

>>> - I have a HW module (which can be a slot, a subrack a card, a
>>>chassis, etc.) which can contain a HW module, ...
>>>

---

From: Balazs Lengyel <[email-masked]>
Date: Fri, 19 Apr 2013 12:12:32 +0200

Hello Kent,
I had similar thoughts, but if you have possible containment like:
A might contain A
A might contain B
B might contain A
it becomes impossible to do the worst case.
regards Balazs