删除具有默认值(yang)的叶子
deleting a leaf with default value (yang)
说我有这个
container c {
leaf l1;
leaf l2 (default 'abcd');
}
我这样做 (restconf):
删除/c/l2
服务器的预期行为是什么?
是吗
- 'delete the leaf data' 或
- '不删除但保留叶子
默认值'
发出 delete 后,GET
的预期结果是什么
GET /c
c {
l1 : 100 // for ex
l2 : 'abcd'
}
这在RFC7950, Section 7.6.1中有描述:
The default value of a leaf is the value that the server uses if the
leaf does not exist in the data tree. The usage of the default value
depends on the leaf's closest ancestor node in the schema tree that
is not a non-presence container (see Section 7.5.1):
o If no such ancestor exists in the schema tree, the default value
MUST be used.
o Otherwise, if this ancestor is a case node, the default value MUST
be used if any node from the case exists in the data tree or the
case node is the choice's default case, and if no nodes from any
other case exist in the data tree.
o Otherwise, the default value MUST be used if the ancestor node
exists in the data tree.
In these cases, the default value is said to be in use.
Note that if the leaf or any of its ancestors has a "when" condition
or "if-feature" expression that evaluates to "false", then the
default value is not in use.
When the default value is in use, the server MUST operationally
behave as if the leaf was present in the data tree with the default
value as its value.
If a leaf has a "default" statement, the leaf's default value is the
value of the "default" statement. Otherwise, if the leaf's type has
a default value and the leaf is not mandatory, then the leaf's
default value is the type's default value. In all other cases, the
leaf does not have a default value.
在你的例子中 c
是一个不存在的容器,因此上面的第一个项目符号开始。这意味着如果你从数据树中删除相应的叶子(是的,你可以删除)。因此,服务器必须在操作上表现得好像叶子存在,并且该叶子必须具有指定的默认值。
使用哪种协议执行操作并不重要。
对于 RESTCONF 和 GET,行为在 Section 3.5.4:
中描述
RESTCONF requires that a server report its default handling mode (see
Section 9.1.2 for details). If the optional "with-defaults" query
parameter is supported by the server, a client may use it to control
retrieval of default values (see Section 4.8.9 for details).
If a leaf or leaf-list is missing from the configuration and there is
a YANG-defined default for that data resource, then the server MUST
use the YANG-defined default as the configured value.
If the target of a GET method is a data node that represents a leaf
or leaf-list that has a default value, and the leaf or leaf-list has
not been instantiated yet, the server MUST return the default
value(s) that are in use by the server. In this case, the server
MUST ignore its basic-mode, described in Section 4.8.9, and return
the default value.
If the target of a GET method is a data node that represents a
container or list that has any child resources with default values,
for the child resources that have not been given value yet, the
server MAY return the default values that are in use by the server,
in accordance with its reported default handing mode and query
parameters passed by the client.
所以您的 GET 示例可能正确也可能不正确,具体取决于哪个默认处理模式有效,如上文最后一段所建议的。
说我有这个
container c {
leaf l1;
leaf l2 (default 'abcd');
}
我这样做 (restconf):
删除/c/l2
服务器的预期行为是什么? 是吗
- 'delete the leaf data' 或
- '不删除但保留叶子 默认值'
发出 delete 后,GET
的预期结果是什么GET /c
c {
l1 : 100 // for ex
l2 : 'abcd'
}
这在RFC7950, Section 7.6.1中有描述:
The default value of a leaf is the value that the server uses if the
leaf does not exist in the data tree. The usage of the default value
depends on the leaf's closest ancestor node in the schema tree that
is not a non-presence container (see Section 7.5.1):
o If no such ancestor exists in the schema tree, the default value
MUST be used.
o Otherwise, if this ancestor is a case node, the default value MUST
be used if any node from the case exists in the data tree or the
case node is the choice's default case, and if no nodes from any
other case exist in the data tree.
o Otherwise, the default value MUST be used if the ancestor node
exists in the data tree.
In these cases, the default value is said to be in use.
Note that if the leaf or any of its ancestors has a "when" condition
or "if-feature" expression that evaluates to "false", then the
default value is not in use.
When the default value is in use, the server MUST operationally
behave as if the leaf was present in the data tree with the default
value as its value.
If a leaf has a "default" statement, the leaf's default value is the
value of the "default" statement. Otherwise, if the leaf's type has
a default value and the leaf is not mandatory, then the leaf's
default value is the type's default value. In all other cases, the
leaf does not have a default value.
在你的例子中 c
是一个不存在的容器,因此上面的第一个项目符号开始。这意味着如果你从数据树中删除相应的叶子(是的,你可以删除)。因此,服务器必须在操作上表现得好像叶子存在,并且该叶子必须具有指定的默认值。
使用哪种协议执行操作并不重要。
对于 RESTCONF 和 GET,行为在 Section 3.5.4:
中描述RESTCONF requires that a server report its default handling mode (see
Section 9.1.2 for details). If the optional "with-defaults" query
parameter is supported by the server, a client may use it to control
retrieval of default values (see Section 4.8.9 for details).
If a leaf or leaf-list is missing from the configuration and there is
a YANG-defined default for that data resource, then the server MUST
use the YANG-defined default as the configured value.
If the target of a GET method is a data node that represents a leaf
or leaf-list that has a default value, and the leaf or leaf-list has
not been instantiated yet, the server MUST return the default
value(s) that are in use by the server. In this case, the server
MUST ignore its basic-mode, described in Section 4.8.9, and return
the default value.
If the target of a GET method is a data node that represents a
container or list that has any child resources with default values,
for the child resources that have not been given value yet, the
server MAY return the default values that are in use by the server,
in accordance with its reported default handing mode and query
parameters passed by the client.
所以您的 GET 示例可能正确也可能不正确,具体取决于哪个默认处理模式有效,如上文最后一段所建议的。