gpt4 book ai didi

ietf-netmod-yang - yang 中默认值的条件赋值

转载 作者:行者123 更新时间:2023-12-01 12:29:16 28 4
gpt4 key购买 nike

我在一个模型中有两个属性:

  • 叶协议(protocol),
  • 离开港口。

我想说明:

  • 如果 protocol = 'ssh' 则默认端口值为 22,
  • 如果 protocol = 'http' 则默认端口值为 80,
  • 等等

如何用阳来表达?

最佳答案

YANG 中没有条件 default 值 - 您需要两个 default 语句来表示两个具有不同值的 defaults 和一个 leaf 可能只有一个 default 子语句。不过,您可以解决这个问题。也许通过使用 presence container 而不是你的协议(protocol) leaf:

module conditional-default {
namespace "http://example.com/conditional-default";
prefix "excd";

grouping common {
leaf port {
type int32;
}
}

container config {

container ssh {
presence "If this container is present, ssh is configured.";
uses common {
refine port {
default 22;
}
}
}
container http {
presence "If this container is present, http is configured.";
uses common {
refine port {
default 80;
}
}
}

}

}

来自 RFC6020,7.5.5.:

The "presence" statement assigns a meaning to the presence of a container in the data tree. It takes as an argument a string that contains a textual description of what the node's presence means.

关于ietf-netmod-yang - yang 中默认值的条件赋值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35907872/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com