【问题标题】:How to make some parameter in yang model as read only如何将 yang 模型中的某些参数设为只读
【发布时间】:2020-07-12 03:17:16
【问题描述】:

我有一个 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.";
    }
  }

【问题讨论】:

  • 这个问题是否与 [java] 或 [go] 有任何关系。这甚至是一个编程问题吗?使用 ServerFault 会更好吗?
  • @StephenC 这是 yang 特定的问题,但我无法找到与此相关的标签。请建议
  • 我已经重新标记了您的问题。以后不要随意挑选标签。它会错误地关注您的问题

标签: ietf-netmod-yang


【解决方案1】:

您提供了一个 YANG 通知,它定义了从支持 YANG 的服务器(例如,NETCONF 服务器)发送到已订阅它的支持 YANG 的客户端(NETCONF 客户端)的消息结构。 所以通知并不描述配置数据,而是服务器自己发送给客户端的东西。

我假设您有另一个包含您想要的数据的 yang 模型,它可能与通知数据重叠。

通常,您可以使用 config 关键字使叶子不可配置,该关键字可以具有真值或假值。 这是错误信息叶中的示例:

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

默认情况下,每个数据节点都是config true,表示它们是可写的,所以可以省略。要定义只读数据,请使用 config false

您可以在 YANG RFC https://www.rfc-editor.org/rfc/rfc6020#section-7.19.1 上找到有关此关键字的文档

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-08-22
    • 2012-07-29
    • 2011-05-19
    • 2015-08-10
    • 1970-01-01
    • 1970-01-01
    • 2018-04-28
    • 2014-09-03
    相关资源
    最近更新 更多