杨建模语言 - select / deselect 位类型中的一个或多个选项

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

在 YANG 语言中是否有可能 select 位类型叶中的一个选项,这将 deselect 所有其他位? 我想做的是,默认情况下,Whole-Platform 是 selected,但是当用户 selects 一些其他选项时,Whole-Platform 将被 deselected。 否则,当用户 selects Whole-Platform 时,所有其他选项都应取消selected。

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

不,YANG 位类型不会让你这样做,因为默认情况下各个位之间不存在任何关系 - 除了所有它们都属于同一组“可配置标志”的概念之外。

这就是联合类型是可行的建模决策的地方。

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

这样做意味着在值 Whole-platform 和 reader.

的剩余位值集之间进行异或(互斥)

有效值:

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

无效:

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

您可以让您的类型保持原样并处理一个位以在描述中将它们全部统治,因为那只是人类可读的规范文本。

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 
             ...";

注意:您要实现的是实现细节。