yang - 如何将 "when"条件语句增强到 Yang 模型中的叶子?

标签 yang

我有一个基本模型:

model base {
  namespace "urn:base";
  prefix b;
  container c {
    leaf id {
      type uint8;
    }
    leaf temp {
      type uint8;
    }
  }
}

如何向 /base:c/base:temp 添加/增强条件语句,使其在某些特定条件下可用?

我的第一个方法是在第二个模型中使用augment,但这对于leaf来说是不可能的。来自 https://datatracker.ietf.org/doc/html/rfc6020 :

This node is called the augment's target node. The target node MUST be either a container, list, choice, case, input, output, or notification node. It is augmented with the nodes defined in the substatements that follow the "augment" statement.

最佳答案

如果基本模型不是您可以创作并因此更改的模型,并且您确实(确实)需要更改叶子的定义,则偏差可能是另一种可行的选择。

您将无法以这种方式使现有叶成为条件,但您可以向其添加条件,以便如果条件计算结果为 false,则叶在实例文档中变为无效。请参阅this answer举个例子。

“when”语句无法扩充到现有架构节点。扩充用于将架构节点子节点添加到现有架构节点目标。它也不能通过偏差添加。

关于yang - 如何将 "when"条件语句增强到 Yang 模型中的叶子?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73606870/

相关文章:

python - 无法从 Windows 命令行运行 pyang 命令,但可以从 Git Bash 运行

model - YANG 和 Choice - XML 是什么样子的?