RFC 9195 | YANG Instance Data | February 2022 |
Lengyel & Claise | Standards Track | [Page] |
There is a need to document data defined in YANG models at design time, implementation time, or when a live server is unavailable. This document specifies a standard file format for YANG instance data, which follows the syntax and semantics of existing YANG models and annotates it with metadata.¶
This is an Internet Standards Track document.¶
This document is a product of the Internet Engineering Task Force (IETF). It represents the consensus of the IETF community. It has received public review and has been approved for publication by the Internet Engineering Steering Group (IESG). Further information on Internet Standards is available in Section 2 of RFC 7841.¶
Information about the current status of this document, any errata, and how to provide feedback on it may be obtained at https://www.rfc-editor.org/info/rfc9195.¶
Copyright (c) 2022 IETF Trust and the persons identified as the document authors. All rights reserved.¶
This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Revised BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Revised BSD License.¶
There is a need to document data defined in YANG models when a live server is unavailable. Data is often needed at design time, implementation time, or even later when a live running server is unavailable. To facilitate this offline delivery of data, this document specifies a standard format for YANG instance data sets and YANG instance data files. The format of the instance data set is defined by the "ietf-yang-instance-data" YANG module; see Section 3. The YANG data model in this document conforms to the Network Management Datastore Architecture (NMDA) defined in [RFC8342].¶
The following is a list of already-implemented and potential use cases.¶
Appendix B describes the first three use cases in detail.¶
There are many and varied use cases where YANG instance data could be used. This document does not limit future uses of instance data sets, so specifying how and when to use YANG instance data is out of scope for this document. It is anticipated that other documents will define specific use cases. Use cases are listed only as examples.¶
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.¶
The following is a list of the basic principles of the instance data format:¶
Instance data sets that are produced as a result of some sort of specification or design effort may be available without the need for a live server, e.g., via download from the vendor's website or in any other way that product documentation is distributed.¶
Other instance data sets may be read from or produced by the YANG server itself, e.g., UC5 documenting diagnostic data.¶
A YANG instance data set is created at a specific point of time. If the data changes afterwards, the instance data set will no longer represent the current data unless it is updated. The current values may be retrieved at runtime via NETCONF/RESTCONF or received, e.g., in YANG-Push notifications.¶
Whether the instance data changes and, if so, when and how should be described either in the instance data set's description statement or in some other implementation-specific manner.¶
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 [RFC7950] for XML and [RFC7951] for JSON and MUST use UTF-8 character encoding. Content-data MAY include:¶
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 [RFC5234]):¶
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:¶
Metadata SHOULD include:¶
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:¶
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") [RFC8525] 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 [RFC8792].¶
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.¶
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.¶
The following tree diagram [RFC8340] provides an overview of the data model.¶
module: ietf-yang-instance-data structure instance-data-set: +--name? string +--format-version? string +--includes-defaults? enumeration +--content-schema | +--(content-schema-spec)? | +--:(simplified-inline) | | +--module* module-with-revision-date | +--:(inline) | | +--inline-yang-library <anydata> | +--:(uri) | +--same-schema-as-file? inet:uri +--description* string +--contact? string +--organization? string +--datastore? ds:datastore-ref +--revision* [date] | +--date string | +--description? string +--timestamp? yang:date-and-time +--content-data? <anydata>¶
This YANG module imports typedefs from [RFC6991], [RFC6243], identities from [RFC8342], and the "structure" extension from [RFC8791]. It also references [RFC8525].¶
<CODE BEGINS> file "ietf-yang-instance-data@2022-01-20.yang" module ietf-yang-instance-data { yang-version 1.1; namespace "urn:ietf:params:xml:ns:yang:ietf-yang-instance-data"; prefix yid; import ietf-yang-structure-ext { prefix sx; reference "RFC 8791: YANG Data Structure Extensions"; } import ietf-datastores { prefix ds; reference "RFC 8342: Network Management Datastore Architecture (NMDA)"; } import ietf-inet-types { prefix inet; reference "RFC 6991: Common YANG Data Types"; } import ietf-yang-types { prefix yang; reference "RFC 6991: Common YANG Data Types"; } import ietf-netconf-with-defaults { prefix ncwd; reference "RFC 6243: With-defaults Capability for NETCONF"; } organization "IETF NETMOD Working Group"; contact "WG Web: <https://datatracker.ietf.org/wg/netmod/> WG List: <mailto:netmod@ietf.org> Author: Balazs Lengyel <mailto:balazs.lengyel@ericsson.com> Author: Benoit Claise <mailto:benoit.claise@huawei.com>"; description "The module defines the structure and content of YANG instance data sets. The key words 'MUST', 'MUST NOT', 'REQUIRED', 'SHALL', 'SHALL NOT', 'SHOULD', 'SHOULD NOT', 'RECOMMENDED', 'NOT RECOMMENDED', 'MAY', and 'OPTIONAL' in this document are to be interpreted as described in BCP 14 (RFC 2119) (RFC 8174) when, and only when, they appear in all capitals, as shown here. Copyright (c) 2022 IETF Trust and the persons identified as authors of the code. All rights reserved. Redistribution and use in source and binary forms, with or without modification, is permitted pursuant to, and subject to the license terms contained in, the Revised BSD License set forth in Section 4.c of the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info). This version of this YANG module is part of RFC 9195 (https://www.rfc-editor.org/info/rfc9195); see the RFC itself for full legal notices."; revision 2022-01-20 { description "Initial revision."; reference "RFC 9195: YANG Instance Data File Format"; } typedef module-with-revision-date { type string { pattern '[a-zA-Z_][a-zA-Z0-9\-_.]*' + '(@\d{4}-(1[0-2]|0[1-9])-(0[1-9]|[1|2][0-9]|3[0-1]))?'; pattern '.|..|[^xX].*|.[^mM].*|..[^lL].*'; } description "A type defining a module name and an optional revision date, e.g., ietf-yang-library@2019-01-04."; } sx:structure instance-data-set { description "A data structure to define a format for YANG instance data. The majority of the YANG nodes provides metadata about the instance data; the instance data itself is contained only in the 'content-data' node."; leaf name { type string; description "An arbitrary name for the YANG instance data set. This value is primarily used for descriptive purposes. However, when the instance data set is saved to a file, then the filename MUST encode the name's value per Section 2 of RFC 9195."; } leaf format-version { type string { pattern '\d{4}-(1[0-2]|0[1-9])-(0[1-9]|[1|2][0-9]|3[0-1])'; } default "2022-01-20"; description "The 'revision' of the 'ietf-yang-instance-data' module used to encode this 'instance-data-set'."; } leaf includes-defaults { type ncwd:with-defaults-mode; default "report-all"; description "Indicates how data nodes with default values are represented for all data nodes contained in the instance-data-set. It uses the same definitions as per Section 3 of RFC 6243 but applied in the context of an instance data file rather than a NETCONF request using the <with-defaults> parameter. For JSON files, the encoding of the 'report-all-tagged' option is as defined in Section 4.8.9 of RFC 8040."; reference "RFC 6243: With-defaults Capability for NETCONF"; } container content-schema { description "The content schema (i.e., YANG modules) used to create the instance data set. If not present, the user needs to obtain the information through external documents."; choice content-schema-spec { description "Specification of the content-schema."; case simplified-inline { leaf-list module { type module-with-revision-date; min-elements 1; description "The list of content-defining YANG modules. The value SHALL start with the module name. If the module contains a revision statement, the revision date SHALL be included in the leaf-list entry, e.g., ietf-yang-library@2019-01-04. Usage of this leaf-list implies the modules are used without any deviations and with all features supported. Multiple revisions of the same module MUST NOT be specified."; } } case inline { anydata inline-yang-library { mandatory true; description "Instance data corresponding to the ietf-yang-library@2019-01-04 defining the set of content-defining YANG modules for this instance-data-set."; } } case uri { leaf same-schema-as-file { type inet:uri; description "A reference to another YANG instance data file. This instance data file uses the same content schema as the referenced file. Referenced files using the 'inline' or the 'simplified-inline' methods MUST be supported. Referenced files using the 'URI method' MAY be supported. The URL schemes 'file://' and 'https://' MUST be supported; other schemes MAY also be supported."; } } } } leaf-list description { type string; description "Description of the instance data set."; } leaf contact { type string; description "Contact information for the person or organization to whom queries concerning this instance data set should be sent."; } leaf organization { type string; description "Organization responsible for the instance data set."; } leaf datastore { type ds:datastore-ref; description "The identity of the datastore with which the instance data set is associated, e.g., the datastore from where the data was read, the datastore into which the data may be loaded, or the datastore that is being documented. If a single specific datastore cannot be specified, the leaf MUST be absent. If this leaf is absent, then the datastore to which the instance data belongs is unspecified."; } list revision { key "date"; description "Instance data sets that are produced as a result of some sort of specification or design effort SHOULD have at least one revision entry. For every published editorial change, a new unique revision SHOULD be added in front of the revisions sequence so that all revisions are in reverse chronological order. In cases of instance data sets that are read from or produced by a server or otherwise subject to frequent updates or changes, revision SHOULD NOT be present."; leaf date { type string { pattern '\d{4}-(1[0-2]|0[1-9])-(0[1-9]|[1|2][0-9]|3[0-1])'; } description "Specifies the date the instance data set was last modified. Formatted as YYYY-MM-DD."; } leaf description { type string; description "Description of this revision of the instance data set."; } } leaf timestamp { type yang:date-and-time; description "The date and time when the instance data set was last modified. In cases of instance data sets that are read from or produced by a server or otherwise subject to frequent updates or changes, the timestamp SHOULD be present. If both a revision list entry and timestamp are present, the timestamp SHOULD contain the same date as the latest revision statement."; } anydata content-data { description "Contains the real instance data. The data MUST conform to the relevant YANG modules specified either in the content-schema or in some other implementation-specific manner."; } } } <CODE ENDS>¶
The YANG module defined in this document only defines a wrapper structure specifying a format and a metadata header for YANG instance data defined by the content-schema. Because of this, the security considerations template for YANG models in Section 3.7.1 of [RFC8407] is not followed. The instance data is designed to be accessed as a stored file or over any file access method or protocol.¶
The document does not specify any method to influence the behavior of a server.¶
The header part is usually not security sensitive; however, sensitive information may be included, in which case it needs to be handled securely, as mentioned below. Information to consider includes:¶
The content part may contain sensitive data. The security sensitivity of this data is completely dependent on the content-schema. Depending on the nature of the instance data, instance data files MAY need to be handled securely. The same kind of handling should be applied to this file at rest and in transit that would be needed for the result of a read operation returning the same data. These in-transit protection mechanisms will also mitigate integrity issues when transporting the file.¶
Instance data files should be protected against modification or unauthorized access using normal file-handling mechanisms. When copying the original files or providing file access for additional users, care should be taken not to reveal information unintentionally.¶
If the URI method is used for specification of the content-schema, there is a risk that the config schema section in the referenced YANG instance data file may be altered maliciously or even as part of its normal handling. In this case, the content-schema might differ from the one expected. Protecting the integrity and stability of the referenced file should be ensured.¶
This document registers one URI and one YANG module.¶
This document registers the following URI in the "IETF XML Registry" [RFC3688]:¶
This document registers the following YANG module in the "YANG Module Names" registry [RFC6020]:¶
The concept of "backwards compatibility" and what changes are backwards compatible are not defined for instance data sets as they are highly dependent on the specific use case and the content-schema.¶
In case of "instance data sets" that are the result of design or specification activity, some changes that may be good to avoid are listed below.¶
YANG uses the concept of managed entities identified by key values; if the connection between the represented entity and the key value is not preserved during an update, this may lead to the following problems.¶
This section is non-normative.¶
A server has a number of server capabilities that are defined in YANG modules and can be retrieved from the server using protocols like NETCONF or RESTCONF. Server capabilities include:¶
While it is good practice to allow a client to query these capabilities from the live server, that is often not possible.¶
Often when a network node is released, an associated Network Management System (NMS) is also released with it. The NMS depends on the capabilities of the server. During NMS implementation, information about server capabilities is needed. If the information is unavailable early in some offline document but only as instance data from the live network node, the NMS implementation will be delayed because it has to wait until the network node is ready. Also, assuming that all NMS implementors will have correctly configured network nodes from which data can be retrieved is a very expensive proposition. (An NMS may handle dozens of node types.)¶
Network operators often build their own homegrown NMS systems that need to be integrated with a vendor's network node. The operator needs to know the network node's server capabilities in order to do this. Moreover, the network operator's decision to buy a vendor's product may even be influenced by the network node's Operations, Administration, and Maintenance (OAM) feature set documented as the server's capabilities.¶
Beside NMS implementors, system integrators and many others also need the same information early. Examples could be model-driven testing, generating documentation, etc.¶
Most server capabilities are relatively stable and change only during upgrade or due to licensing or the addition or removal of hardware. They are usually defined by a vendor at design time, before the product is released. It is feasible and advantageous to define and document them early, e.g., in a YANG instance data file.¶
It is anticipated that a separate IETF document will define in detail how and which set of server capabilities should be documented.¶
There are parts of the configuration that must be fully configurable by the operator. However, a simple default configuration often will be sufficient.¶
One example is access control groups/roles and related rules. While a sophisticated operator may define dozens of different groups, often a basic (read-only operator, read-write system administrator, security-administrator) triplet will be enough. Vendors will often provide such default configuration data to make device configuration easier for an operator.¶
The device vendor may define a set of default groups (/nacm:nacm/groups) and rules for these groups to access specific parts of the common models (/nacm:nacm/rule-list/rule).¶
YANG instance data files can be used to document and/or preload the default configuration.¶
Nearly every server has a factory default configuration. If the system is really badly misconfigured or if the current configuration is to be abandoned, the system can be reset to the default factory configuration.¶
YANG instance data can be used to document the factory default configuration. See [RFC8808].¶
For their valuable comments, discussions, and feedback, we wish to acknowledge Andy Bierman, Juergen Schoenwaelder, Rob Wilton, Joe Clarke, Kent Watsen, Martin Bjorklund, Ladislav Lhotka, Qin Wu, and other members of the Netmod Working Group.¶