简体   繁体   English

Yang 建模语言 - 在位类型中选择/取消选择一个或多个选项

[英]Yang modeling language - select / deselect one or multiple options within bits type

Is there possibility in YANG language to select one option in bit type leaf, which will deselect all other bits ? YANG语言是否有可能在位类型叶中选择一个选项,这将取消选择所有其他位? What I would like to do is, by default Whole-Platform is selected, but when user selects some other option, the Whole-Platform will be deselected.我想要做的是,默认情况下选择了整个平台,但是当用户选择其他选项时,将取消选择整个平台。 And otherwise when user selects Whole-Platform, all other options should be deselected.否则,当用户选择 Whole-Platform 时,应取消选择所有其他选项。

leaf check-type {
            type bits {
              bit Whole-platform;
              bit NSO-checks;
              bit ESC-checks;
            }
            default "Whole-platform";
 }

位

No, YANG bits type will not let you do that, since no relation between individual bits ever exists by default - other than the notion of all of them belonging to the same set of "configurable flags".不,YANG 位类型不会让您这样做,因为默认情况下各个位之间不存在任何关系 - 除了所有这些都属于同一组“可配置标志”的概念。

This is where a union type would be a viable modeling decision.这是联合类型将成为可行的建模决策的地方。

leaf check-type {
  type union {
    type enumeration {
      enum Whole-platform;
    }
    type bits {
      bit NSO-checks;
      bit ESC-checks;
    }
  }
  default Whole-platform;
}

Doing this implies an XOR (mutual exclusivity) between value Whole-platform and the set of remaining bit values to the reader.这样做意味着值Whole-platform和读者的剩余位值集之间的 XOR(互斥)。

Valid values:有效值:

<check-type>Whole-platform</check-type>
<check-type>NSO-checks</check-type>
<check-type>NSO-checks ESC-checks</check-type>

Invalid:无效的:

<check-type>Whole-platform ESC-checks</check-type>

You could leave your type as is and handle the one bit to rule them all in a description, since that is just human readable normative text.您可以保留您的类型并处理其中的一位以在描述中将它们全部规则,因为那只是人类可读的规范文本。

description "Implementations must ensure an XOR relationship between
             'Whole-platform' bit value and the other bit values of this
             leaf. When the former is used it means that 
             ...";

Note: what you are trying to achieve is an implementation detail.注意:您要实现的是实现细节。

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

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