简体   繁体   English

如何将阳模型中的某些参数设为只读

[英]How to make some parameter in yang model as read only

I have one yang model, which is use to change run time parameter of my application.how i can make some parameter read only because some parameter when get change it impact on my code.I want user cannot change that parameter on run time.我有一个 yang 模型,它用于更改我的应用程序的运行时参数。我如何使某些参数只读,因为某些参数在更改时会影响我的代码。我希望用户不能在运行时更改该参数。

    notification bind-lne-name-failed {
    description
      "Indicates an error in the association of an interface to an
       LNE. Only generated after success is initially returned when
       bind-lne-name is set.";
    leaf name {
      type leafref {
        path "/if:interfaces/if:interface/if:name";
      }
      mandatory true;
      description
        "Contains the interface name associated with the
         failure.";
    }
    leaf bind-lne-name {
      type leafref {
        path "/if:interfaces/if:interface/lne:bind-lne-name";
      }
      mandatory true;
      description
        "Contains the bind-lne-name associated with the
         failure.";
    }
    leaf error-info {
      type string;
      description
        "Optionally, indicates the source of the assignment
         failure.";
    }
  }

You've provided a YANG notification, which defines the structure of messages being sent from a YANG-capable server (for example, a NETCONF server) to a YANG-capable client (a NETCONF client) that has subscribed to it.您提供了一个 YANG 通知,它定义了从支持 YANG 的服务器(例如,NETCONF 服务器)发送到订阅它的支持 YANG 的客户端(NETCONF 客户端)的消息结构。 So notifications doesn't describe configuration data, but something the server sends to the client on its own.所以通知不描述配置数据,而是服务器自己发送给客户端的东西。

I assume you have another yang model that does contain the data you want, which might overlap with the notification data.我假设您有另一个包含所需数据的 yang 模型,这些数据可能与通知数据重叠。

Generically, you make leafs non-configurable by using the config keyword, which can have true or false values.通常,您可以使用config关键字使叶子不可配置,该关键字可以具有 true 或 false 值。 Here's an example on how that would look like in the error-info leaf:下面是一个示例,说明它在 error-info 叶中的样子:

    leaf error-info {
      type string;
      config false;
      description
        "Optionally, indicates the source of the assignment
         failure.";
    }

By default, every data nodes are config true , meaning that they are writable, so that can be ommitted.默认情况下,每个数据节点都是config true ,这意味着它们是可写的,因此可以省略。 For defining read-only data, you use config false .要定义只读数据,请使用config false

You can find documentation on this keyword on the YANG RFC at https://tools.ietf.org/html/rfc6020#section-7.19.1您可以在位于https://tools.ietf.org/html/rfc6020#section-7.19.1的 YANG RFC 上找到有关此关键字的文档

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

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