У меня есть эта простая модель Ян
leaf type {
type string;
description "some description";
}
Это не работает. Может кто-нибудь объяснить, недействительна ли строка «тип» для имени листа в ян?
Попробуйте заключить аргумент в кавычки в качестве возможного обходного пути. Инструмент, который предотвращает использование такого аргумента, не соответствует RFC7950/RFC6020.
Аргумент оператора leaf
должен быть идентификатором, и нет ограничений, запрещающих использование ключевых слов YANG там, где ожидается идентификатор (все встроенные ключевые слова также являются идентификаторами). И leaf type {...}
, и leaf leaf {...}
являются допустимыми операторами YANG.
The "leaf" statement is used to define a leaf node in the schema tree. It takes one argument, which is an identifier, followed by a block of substatements that holds detailed leaf information.
Вот что говорится в спецификации об идентификаторах:
Identifiers are used to identify different kinds of YANG items by name. Each identifier starts with an uppercase or lowercase ASCII letter or an underscore character, followed by zero or more ASCII letters, digits, underscore characters, hyphens, and dots. Implementations MUST support identifiers up to 64 characters in length and MAY support longer identifiers. Identifiers are case sensitive. The identifier syntax is formally defined by the rule "identifier" in Section 14. Identifiers can be specified as quoted or unquoted strings.
Упомянутое выше грамматическое правило:
identifier = (ALPHA / "_")
*(ALPHA / DIGIT / "_" / "-" / ".")
Вот что он говорит о пространстве имен операторов leaf
(пространство имен налагает требование уникальности имени в пределах своей области действия с целью предотвращения конфликтов имен):
o All leafs, leaf-lists, lists, containers, choices, rpcs, actions, notifications, anydatas, and anyxmls defined (directly or through a "uses" statement) within a parent node or at the top level of the module or its submodules share the same identifier namespace. This namespace is scoped to the parent node or module, unless the parent node is a case node. In that case, the namespace is scoped to the closest ancestor node that is not a case or choice node.
pyang считает его допустимым конечным значением.