0

I have this configuration file where dps can have a list of switches (e.g. sw1, sw2, etc) each switch has db_id and list of interfaces as shown below. I want to write a YANG model for this fils.

dps:
    <sw1>:
        dp_id: <value>
        interfaces:
            1:
                name: <value>
                native_vlan: <value>
            2:
                name: <value>
                native_vlan: <value>
    <sw2>:
        dp_id: <value>
        interfaces:
            1:
                name: <value>
                native_vlan: <value>
            2:
                name: <value>
                native_vlan: <value>

I could not find a way to make the inner list name (i.e. sw1, sw2) configurable (i.e. inserted by users). Is it possible or YANG doesn't support that.

alshaboti
  • 643
  • 8
  • 18

1 Answers1

0

Not possible. All list entries have the same name and are uniquely identified via their keys (in JSON encoding, the list is even represented as a single JSON array of objects). You should name your list sw, and have your users configure their name key leaf.

list sw { key name; leaf name { type string; } }

The list's name is the only way to bind an instance (a list entry) to the model definitions.

predi
  • 5,528
  • 32
  • 60
  • Thank you. Unfortunately the configuration file that I need to make a yang model for it is working as I explain (i.e. user define lists names). – alshaboti Mar 19 '18 at 23:20