2

私はこれを持っていると言う

container c {
  leaf l1;
  leaf l2 (default 'abcd');
}

そして私はこれを行います(restconf):

削除 /c/l2

サーバーで予想される動作は何ですか? それは...ですか

  • 「葉のデータを削除する」または
  • 「リーフを削除せずにデフォルト値で保持する」

delete を発行した後、GET の期待される結果は何ですか

GET /c
c {
  l1 : 100 // for ex
  l2 : 'abcd'
}
4

1 に答える 1

2

これは、RFC7950 のセクション 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 の場合、動作はセクション 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 の例が正しい場合と正しくない場合があります。

于 2017-01-10T08:00:50.863 に答える