A YANG instance data file
MUST contain a single instance data set and no additional data.
The format of the instance data set is defined by the "ietf-yang-instance-data" YANG module. It is made up of a header part and content-data. The header part carries metadata for the instance data set. The content-data, defined as an anydata data node, carries the instance data that the user wants to document and/or provide. The syntax and semantics of content-data are defined by the content-schema.
Two formats are specified based on the XML and JSON YANG encodings. The file formats are achieved by applying the respective XML and JSON encoding rules for the YANG structure included in this document. Later, as other YANG encodings (e.g., CBOR) are defined, further instance data formats may be specified.
The content-data part
MUST conform to the content-schema while allowing for the exceptions listed below. The content-data part
SHALL follow the encoding rules defined in [
RFC 7950] for XML and [
RFC 7951] for JSON and
MUST use UTF-8 character encoding. Content-data
MAY include:
-
metadata, as defined by [RFC 7952].
-
origin metadata, as specified in [RFC 8526] and [RFC 8527].
-
implementation-specific metadata relevant to individual data nodes. Unknown metadata MUST be ignored by users of instance data, allowing it to be used later for other purposes.
An instance data set
MAY contain data for any number of YANG modules; if needed, it
MAY carry the complete configuration and state data for a server. Default values should be excluded where they do not provide additional useful data.
Configuration ("config true") and operational state data ("config false")
MAY be mixed in the instance data file.
Instance data files
MAY contain partial data sets. This means "mandatory", "min-elements", "require-instance true", "must", and "when" constraints
MAY be violated.
The name of the instance data file
SHOULD be of the following form (using ABNF notation [
RFC 5234]):
instance-data-set-name ["@" ( revision-date / timestamp ) ]
( ".xml" / ".json" )
Examples include:
acme-router-modules.xml
acme-router-modules@2018-01-25.xml
acme-router-modules@2018-01-25T15_06_34_3+01_00.json
If the leaf "name" is present in the instance data header, its value
SHOULD be used for the "instance-data-set-name" in the filename. If the "revision-date" is present in the filename, it
MUST conform to the format of the revision-date leaf in the YANG model. If the "revision-date" is present in both the filename and the instance data header, the revision date in the filename
MUST be set to the latest revision date inside the instance data set. If the "timestamp" is present in the filename, it
MUST conform to the format of the timestamp leaf in the YANG model except for replacing colons as described below. If the "timestamp" is present in both the filename and the instance data header, the timestamp in the filename
SHOULD be set to the timestamp inside the instance data set; any colons, if present, shall be replaced by underscores.
Metadata, information about the data set itself,
MUST be included. Some metadata items are defined in the YANG module "ietf-yang-instance-data", but other items
MAY be used.
Metadata
MUST include:
-
-
Version of the YANG instance data format (if not explicitly present, the default value is used).
Metadata
SHOULD include:
-
-
Name of the data set.
-
Content-schema specification (i.e., the "content-schema" node).
-
Description of the instance data set. The description SHOULD contain information on whether and how the data can change during the lifetime of the server.
-
An indication of whether default values are included. The default handling uses the concepts defined in [RFC 6243]; however, as only concepts are re-used, users of instance data sets do not need to support [RFC 6243].
To properly understand and use an instance data set, the user needs to know the content-schema. The content-schema can be specified either in external documents or within the instance data set. In the latter case, one of the following methods
MUST be used:
-
Inline method:
-
Include the needed information as part of the instance data set.
-
Simplified-inline method:
-
Include the needed information as part of the instance data set; only the modules' name and revision-date are used.
-
URI method:
-
Include a URI that references another YANG instance data file. This instance data file will use the same content-schema as the referenced YANG instance data file (if you don't want to repeat the info again and again).
Additional methods, e.g., a YANG-package-based solution may be added later.
Note that the specified content-schema only indicates the set of modules that were used to define this YANG instance data set. Sometimes instance data may be used for a server supporting a different YANG module set (e.g., for the "Preloading default configuration data" use case,
UC2 in
Section 1, the instance data set may not be updated every time the YANG modules on the server are updated). Whether an instance data set originally defined using a specific content-schema is usable with another schema depends on many factors, including the number of differences and the compatibility between the original and the other schema when considering modules, revisions, features, deviations, the scope of the instance data, etc.
The "inline-yang-library" anydata data node carries instance data (conforming to "ietf-yang-library@2019-01-04") [
RFC 8525] that specifies the content-defining YANG modules, including revision, supported features, deviations, and any additional relevant data. An example of the inline method is provided in
Section 2.2.1.
The instance data set contains a list of content-defining YANG modules, including the revision date for each. Usage of this method implies that the modules are used without any deviations and with all features supported. YANG modules that are only required to satisfy import-only dependencies
MAY be excluded from the leaf-list. If they are excluded, then the consumer of the instance data set has to apply the YANG language rules to resolve the imports. An example of the simplified-inline method is provided in
Section 2.2.2.
The "same-schema-as-file" leaf
SHALL contain a URI that references another YANG instance data file. The current instance data file will use the same content-schema as the referenced file.
The referenced instance data file
MAY have no content-data if it is used solely for specifying the content-schema.
If a referenced instance data file is unavailable, the content-schema is unknown.
The URI method is advantageous when the user wants to avoid the overhead of specifying the content-schema in each instance data file -- for example, in
UC6, when the system creates a diagnostic file every minute to document the state of the server.
An example of the URI method is provided in
Section 2.2.3.
The example file acme-router-modules@2022-01-20.xml reflects
UC1 in
Section 1. It provides a list of supported YANG modules and NETCONF capabilities for a server. It uses the inline method to specify the content-schema.
The example uses artwork folding [
RFC 8792].
========== NOTE: '\' line wrapping per RFC 8792 ===========
<?xml version="1.0" encoding="UTF-8"?>
<instance-data-set xmlns=\
"urn:ietf:params:xml:ns:yang:ietf-yang-instance-data">
<name>acme-router-modules</name>
<content-schema>
<inline-yang-library>
<modules-state \
xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-library">
<module>
<name>ietf-yang-library</name>
<revision>2019-01-04</revision>
</module>
<module>
<name>ietf-netconf-monitoring</name>
<revision>2010-10-04</revision>
</module>
</modules-state>
</inline-yang-library>
</content-schema>
<revision>
<date>2020-10-23</date>
<description>Initial version</description>
</revision>
<description>Defines the minimal set of modules that any \
acme-router will contain. This minimal set will \
only change when a new software release is \
introduced.</description>
<contact>info@acme.example.com</contact>
<content-data>
<modules-state \
xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-library">
<module>
<name>ietf-yang-library</name>
<revision>2019-01-04</revision>
<namespace>\
urn:ietf:params:xml:ns:yang:ietf-yang-library\
</namespace>
<conformance-type>implement</conformance-type>
</module>
<module>
<name>ietf-system</name>
<revision>2014-08-06</revision>
<namespace>urn:ietf:params:xml:ns:yang:ietf-system</namespace>
<feature>sys:authentication</feature>
<feature>sys:local-users</feature>
<deviation>
<name>acme-system-ext</name>
<revision>2018-08-06</revision>
</deviation>
<conformance-type>implement</conformance-type>
</module>
<module>
<name>ietf-netconf-monitoring</name>
<revision>2010-10-04</revision>
<namespace>\
urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\
</namespace>
<conformance-type>implement</conformance-type>
</module>
<module>
<name>ietf-yang-types</name>
<revision>2013-07-15</revision>
<namespace>urn:ietf:params:xml:ns:yang:ietf-yang-types\
</namespace>
<conformance-type>import</conformance-type>
</module>
<module>
<name>acme-system-ext</name>
<revision>2018-08-06</revision>
<namespace>\
urn:rdns:acme.example.com:oammodel:acme-system-ext\
</namespace>
<conformance-type>implement</conformance-type>
</module>
</modules-state>
<netconf-state \
xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring">
<capabilities>
<capability>\
urn:ietf:params:netconf:capability:validate:1.1\
</capability>
</capabilities>
</netconf-state>
</content-data>
</instance-data-set>
The example file read-only-acm-rules@2022-01-20.xml reflects
UC2 in
Section 1. It provides a default rule set for a read-only operator role. It uses the simplified-inline method for specifying the content-schema.
========== NOTE: '\' line wrapping per RFC 8792 ===========
<?xml version="1.0" encoding="UTF-8"?>
<instance-data-set
xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-instance-data">
<name>read-only-acm-rules</name>
<content-schema>
<module>ietf-netconf-acm@2018-02-14</module>
</content-schema>
<revision>
<date>2018-07-04</date>
<description>Initial version</description>
</revision>
<description>Default access control rules for a read-only \
role. This set of rules will only change when a new \
software release is introduced.</description>
<content-data>
<nacm xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-acm">
<enable-nacm>true</enable-nacm>
<read-default>deny</read-default>
<exec-default>deny</exec-default>
<rule-list>
<name>read-only-role</name>
<group>read-only-group</group>
<rule>
<name>read-all</name>
<module-name>*</module-name>
<access-operation>read</access-operation>
<action>permit</action>
</rule>
</rule-list>
</nacm>
</content-data>
</instance-data-set>
The example file acme-router-netconf-diagnostics@2018-01-25T17_00_38Z.json reflects
UC5 in
Section 1. An instance data set that contains statistics about the NETCONF server is produced by the server every 15 minutes. As a new set is produced periodically many times a day, a revision-date would be useless; instead, a timestamp is included.
========== NOTE: '\' line wrapping per RFC 8792 ===========
{
"ietf-yang-instance-data:instance-data-set": {
"name": "acme-router-netconf-diagnostics",
"content-schema": {
"same-schema-as-file": "file:///acme-diagnostics-schema.json"
},
"timestamp": "2018-01-25T17:00:38Z",
"description": ["NETCONF statistics, \
The data may change at any time."],
"content-data": {
"ietf-netconf-monitoring:netconf-state": {
"statistics": {
"netconf-start-time ": "2018-12-05T17:45:00Z",
"in-bad-hellos ": "32",
"in-sessions ": "397",
"dropped-sessions ": "87",
"in-rpcs ": "8711",
"in-bad-rpcs ": "408",
"out-rpc-errors ": "408",
"out-notifications": "39007"
}
}
}
}
}