简体   繁体   English

是否可以使YANG列表名称可配置?

[英]is it possible to make YANG list name configurable?

I have this configuration file where dps can have a list of switches (eg sw1, sw2, etc) each switch has db_id and list of interfaces as shown below. 我有此配置文件,其中dps可以具有交换机列表(例如sw1,sw2等),每个交换机都有db_id和接口列表,如下所示。 I want to write a YANG model for this fils. 我想为此文件编写一个YANG模型。

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 (ie sw1, sw2) configurable (ie inserted by users). 我找不到使内部列表名称(即sw1,sw2)可配置(即由用户插入)的方法。 Is it possible or YANG doesn't support that. 是可能的还是YANG不支持。

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). 所有列表条目具有相同的名称,并通过其键进行唯一标识(在JSON编码中,列表甚至表示为单个JSON对象数组)。 You should name your list sw , and have your users configure their name key leaf. 您应该为列表sw命名,并让用户配置其name密钥叶。

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. 列表的名称是将实例(列表条目)绑定到模型定义的唯一方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM