<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!ENTITY RFC6020 SYSTEM "reference.RFC.6020.xml">
<!ENTITY RFC7895 SYSTEM "reference.RFC.7895.xml">
<!ENTITY RFC7952 SYSTEM "reference.RFC.7952.xml">
<!ENTITY RFC7951 SYSTEM "reference.RFC.7951.xml">
<!ENTITY RFC7950 SYSTEM "reference.RFC.7950.xml">
<!ENTITY RFC8199 SYSTEM "reference.RFC.8199.xml">
<!ENTITY OPENCONFIG-YANG-CATALOG SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.openconfig-netmod-model-catalog.xml">
<!ENTITY CLAISE-SEMVER "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.claise-semver.xml">
<!ENTITY OPENCONFIG-YANG-CATALOG SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.openconfig-netmod-model-catalog.xml">
<!ENTITY CLACLA-NETMOD-MODEL-CATALOG "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.clacla-netmod-model-catalog.xml">
<!ENTITY WU-L3SM-RFC8049 "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.wu-l3sm-rfc8049bis.xml">
]>
<?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
<?rfc toc="yes"?>
<?rfc tocompact="yes"?>
<?rfc tocdepth="4"?>
<?rfc tocindent="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc comments="yes"?>
<?rfc inline="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
<rfc category="std" ipr="trust200902" docName="draft-lengyel-netmod-yang-instance-data-05">
  <front>
    <title abbrev="YANG Based Instance Data">YANG Based Instance Data Files Format</title>
    <author initials="B." surname="Lengyel" fullname="Balazs Lengyel">
      <organization abbrev="Ericsson"> Ericsson </organization>
      <address>
                <postal>
                    <street>Magyar Tudosok korutja 11</street>
                    <city>1117 Budapest</city>
                    <country>Hungary</country>
                </postal>
                <phone>+36-70-330-7909</phone>
                <email>balazs.lengyel@ericsson.com</email>
            </address>
    </author>
    <author initials="B." surname="Claise" fullname="Benoit Claise">
        <organization abbrev="Cisco Systems, Inc.">
            Cisco Systems, Inc.
        </organization>
        <address>
            <postal>
                <street>De Kleetlaan 6a b1</street>
                <city>1831 Diegem</city>
                <country>Belgium</country>
            </postal>
            <phone>+32 2 704 5622</phone>
            <email>bclaise@cisco.com</email>
        </address>
    </author>
    <date/>
    <area>OPS</area>
    <workgroup>Netconf</workgroup>
    <abstract>
      <t> There is a need to document data defined in YANG models without the 
        need to fetch it from a live YANG server. Data is often needed already 
        in design time or needed by groups that do not have a live running YANG 
        server available.
        This document specifies a standard file format for YANG Based Instance data, that is data that
        could be stored in a datastore and whose syntax and semantics is defined by YANG models.
        Most important use cases foreseen include documenting server capabilities, 
        factory-default settings, or vendor provided default configurations.
        </t>
    </abstract>
  </front>

  <middle>
    <section title="Terminology" anchor="terminology">
      <t>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 <xref target="RFC2119">RFC 2119</xref> 
        <xref target="RFC8174">RFC 8174</xref> when, and only when, they
        appear in all capitals, as shown here.</t>
      <t>Design time: A time during which a YANG model and the implementation 
        behind it is created. Sometimes in other documents this period is 
        divided into design and implementation time.</t>
      <t>Instance Data Set:  A named set of data items that can be used as instance data in a YANG data tree.</t>
      <t>Instance Data File:  A file containing an instance data set formatted according to the rules described in this document.</t>
      <t>Target YANG Module: A YANG module for which the instance data set contains instance data, like ietf-yang-library in the examples.</t>
    </section>   
    <section anchor="intro" title="Introduction">
      <t>There is a need to provide instance data defined in YANG models without the 
        need to fetch it from a live YANG server. Data is often needed already 
        in design time before the YANG server is implemented or needed by groups that do not have a live running YANG 
        server available.
        To facilitate this off-line delivery of data this 
        document specifies a standard file format for YANG Based Instance data, that is data that
        could be stored in a datastore and whose syntax and semantics is defined by YANG models.
      </t>
      <section title="Use Cases">
        <t>We present a number of use cases were Yang based instance data is needed.</t>
        <section title="Use Case 1: Early Documentation of Server Capabilites">
          <t> A YANG 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. YANG server capabilities include   
            <list style="symbols">
              <t> data defined in ietf-yang-library: YANG modules, submodules, features, deviations, schema-mounts, datastores supported (<xref target="I-D.ietf-netconf-rfc7895bis"/>)</t>
              <t>alarms supported (<xref target="I-D.ietf-ccamp-alarm-module"/>)</t>
              <t>data nodes, subtrees that support or do not support on-change notifications (<xref target="I-D.ietf-netconf-yang-push"/>)</t>
              <t>netconf-capabilities in ietf-netconf-monitoring</t>
            </list>
            While it is good practice to allow a client to query these capabilites 
            from the live YANG server, that is often not enough. 
          </t>
          <t>
            Often when a network node is released an associated NMS
            (network management system) is also released with it. The NMS depends on the capabilities of the YANG server.          
            During NMS implementation information about server capabilities is needed.
            If the information is not available early in some off-line 
            document, but only as instance data from the live network node, the NMS implementation will be
            delayed, because it has to wait for the network node to be ready. Also assuming
            that all NMS implementors will have a correctly configured network node
            available to retrieve data from, is a very expensive proposition. (An NMS may handle dozens
            of node types.)
          </t>  
            <t>
            Network operators often build their own home-grown NMS systems that 
            needs 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 OAM feature set 
            documented as the Yang server's capabilites.
          </t>  
          <t>
            Beside NMS implementors, system integrators and many others also need the same
            information early.  Examples could be model driven testing, generating documentation, etc.
            </t>
          <t>
            Most server-capabilities are relatively stable and change only during 
            upgrade or due to licensing or addition or removal of HW. They are 
            usually defined by a vendor in design time, before the product is released.
            It feasible and advantageous to define/document them early 
            e.g. in a Yang Based Instance Data File.     
          </t>  
          <t>It is anticipated that a separate IETF document will define in
            detail how and which set of server capabilites should be documented.
          </t>
        </section>
        <section title="Use Case 2: Preloading Data">
          <t>
            There are parts of the configuration that must be fully configurable 
            by the operator, however for which often a simple default 
            configuration will be sufficient. 
          </t><t>
            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.
          </t> <t>
            Defining Access control data is a complex task. To help the device vendor pre-defines a set 
            of default groups (/nacm:nacm/groups) and rules 
            for these groups to access specific parts of common models (/nacm:nacm/rule-list/rule).
          </t>
          <t>
            YANG Based Instance data files are used to document and/or preload the 
            default configurationp.                             
          </t>
        </section>
        <section title="Use Case 3: Dcoumenting Factory Default Settings">
          <t>
            Nearly every YANG 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 this default.
          </t><t>
            In Netconf the &lt;delete-config> operation can already be used to do this 
            for the startup configuration. There are ongoing efforts to introduce 
            a new, more generic reset operation for the same purpose 
            <xref target="I-D.wu-netconf-restconf-factory-restore"></xref>
          </t> <t>
            The operator currently has no way to know what the
            default configuration actually contains. 
            YANG Based Instance data can be used to document the factory default
            configuration.                             
          </t>
        </section>
      </section>
      
      
    </section>

    <section anchor="instance_data_file_format" title="Instance Data File Format">
      <t>
        Two standard formats to represent YANG Based Instance Data are specified based on 
        the XML and JSON encoding. The XML format is based on <xref target="RFC7950"/> 
        while the JSON format is based on <xref target="RFC7951"/>. 
        Later as other YANG encodings (e.g. CBOR) are defined further Instance Data formats may be specified.
      </t>
      <t>
        For both formats data is placed in a top level auxiliary container 
        named "instance-data-set". The purpose of the container, which is not part of 
        the real data itself, is to carry meta-data for the complete instance-data-set.
      </t>
      <t>
        The XML format SHALL follow the format returned for a NETCONF GET operation.
        The &lt;data> anydata (which is not part of the real data itself) 
        SHALL contain all data that would be inside the &lt;data> wrapper element 
        of a reply to the &lt;get> operation. XML attributes SHOULD NOT be present, 
        however if a SW receiving a YANG Based Instance data file encounters 
        XML attributes unknown to it, it MUST ignore them, allowing them to be used 
        later for other purposes.
      </t>
      <t>
        The JSON format SHALL follow the format of the reply returmed for a 
        RESTCONF GET request directed at the datastore resource: {+restconf}/data. 
        ETags and Timestamps SHOULD NOT be included, but if present SHOULD be ignored. 
      </t>
      <t>
        A YANG Based Instance data file MUST contain a single instance data set. 
        Instance data MUST conform to the corresponding target YANG Modules and 
        follow the XML/JSON encoding rules as defined in <xref target="RFC7950"/> 
        and <xref target="RFC7951"/> and use UTF-8 character encoding.
        A single instance data set MAY contain data for any number of target
        YANG modules, if needed it MAY carry the complete configuraton and state
        data set for a YANG server.
        Default values SHOULD NOT but MAY be included.
        Config=true and config=false data MAY be mixed in the instance data file.        
        Instance data files MAY contain partial data sets. This means mandatory, 
        min-elements or require-instance=true constrains MAY be violated.      
      </t>
      <t>The name of the file SHOULD be of the form:
        <list>
          <t>instance-data-set-name ['@' revision-date] ( '.yid' )</t>
          <t>E.g. acme-router-modules@2018-01-25.yid</t>
        </list>
        The revision date is optional. It SHOULD NOT be used if the file is
        stored in a version control system (e.g. git) because the 
        change of file names will break the connection between the different
        revisions of the file. 
      </t>
      <t>Meta data, information about the data set itself  
      SHALL be included in the instance data set. This data will be children 
      of the top level instance-data-set container as defined in the 
      ietf-instance-data YANG module. 
      Meta data SHALL include:
        <list style="symbols">
          <t>Name of the instance data set</t>
        </list>
      Meta data SHOULD include:
        <list style="symbols">
          <t>Revision date of the instance data set</t>
          <t>Description of the instance data set. The description SHOULD contain information whether 
            and how the data can change during the lifetime of the YANG server.</t>
        </list>
     </t>
      <figure align="center" anchor="Xml-Instance-Data-File-example" title="XML Instance Data File example">
        <artwork align="left"><![CDATA[ 
<?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> 
  <revision>2108-01-25</revision>
  <description>Defines the minimal set of modules that any acme-router
       will contain. These modules will always be present.</description> 
  <contact>info@acme.com</contact>
  <data>
    <yang-library xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-library">
      <module-set>
        <name>basic</name>
        <module>
          <name>ietf-system</>
          <revision>2014-08-06</revision>
          <!-- description "A later revision may be used."; -->
          <namespace>urn:ietf:params:xml:ns:yang:ietf-system</namespace>
          <feature>authentication</feature>
          <feature>radius-authentication</feature>
        </module>
      </module-set>
    </yang-library>
  </data>  
</instance-data-set>
          ]]></artwork>
      </figure>
      
      <figure align="center" anchor="Json-Instance-Data-File-example" title="JSON Instance Data File example">
        <artwork align="left"><![CDATA[ 
{
  "ietf-yang-instance-data:instance-data-set": {
    "name": "acme-router-modules", 
    "revision": "2108-01-25", 
    "contact": "info@acme.com", 
    "description":  
      "Defines the set of modules that an acme-router will contain.", 
    "data": {
      "ietf-yang-library:yang-library": {
        "module-set": [
          "name": "basic",
          "module": [
            {
              "name": "ietf-system",
              "revision": "2014-08-06",
              "namespace": "urn:ietf:params:xml:ns:yang:ietf-system",
              "feature": ["authentication", "radius-authentication"]
            }  
          }
        ]
      ]
    }
  }  
}
        ]]></artwork>
      </figure>
    </section>

    <section title="Data Life cycle">
        <t>
            Data defined or documented in YANG Based Instance Data Sets may be used for 
            preloading a YANG server with this data, but the server may populate 
            the data without using the actual file in which case the Instance 
            Data File is only used as documentation.
        </t>
        <t>
            While such data will usually not change, data documented 
            by Instance Data sets MAY be changed by the 
            YANG server itself or by management operations. It is out of scope for this 
            document to specify a method to prevent this. 
            Whether such data changes and if so, when and how,
            SHOULD be described either in the instance data file description
            statement or in some other implementation specific manner.
            </t><t>
            YANG Based Instance data is a snap-shot of information at a specific 
            point of time. If the data changes afterwards this is not
            represented in the instance data set anymore, the valid values can be
            retrieved in run-time via Netconf/Restconf               
        </t>
        <t>
            Notifications about the change of data documented by Instance Data 
            Sets may be supplied by e.g. the Yang-Push mechanism, but it is 
            out of scope for this document. 
        </t>
    </section>
    <section title="Delivery of Instance Data">
      <t>Instance data files SHOULD be available without the need for a live 
      YANG server e.g.  via download from the vendor's website, or any other way 
      together with other product documentation.</t>
    </section>
    
    
    <section title="YANG Model" anchor="yang-model">
        <t>&lt;CODE BEGINS> file "ietf-yang-instance-data.yang"</t>
            <figure>
                <artwork><![CDATA[
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-data-ext { prefix yd; }
  
  import ietf-datastores { prefix ds; }
   
  organization  "IETF NETMOD Working Group";
  contact
   "WG Web:   <https://datatracker.ietf.org/wg/netmodf/>
    WG List:  <mailto:netmod@ietf.org>

    Author:  Balazs Lengyel
       <mailto:balazs.lengyel@ericsson.com>";
            
  description "The module defines the structure and content of YANG 
       Instance Data Sets.";
   
  revision 2018-06-30 {
    description  "Initial revision.";
    reference "RFC XXXX: YANG Based Instance Data";
  }
       
  yd:yang-data instance-data-format {
    container instance-data-set {               
      description "Auxiliary container to carry meta-data for 
        the complete instance data set.";
             
      leaf name {
        type string;
        mandatory true;
        description "Name of a YANG Based Instance data set.";
      }
            
      leaf description { type string; }
            
      leaf contact {
        type string;
        description "Contains the same information the contact 
            statement carries for a YANG module.";
      }
            
      leaf organization {
        type string;
        description "Contains the same information the 
            organization statement carries for a YANG module.";                    
      }
            
      leaf datastore {
        type ds:datastore-ref;
        description  "The identity of the datastore for which 
          the instance data is documented for config=true data nodes. 
          The leaf MAY be absent in which case the running dtastore or
          if thats not writable, the candidate datastore is implied.
          
          For config=false data nodes always the operational 
          data store is implied.";
      }
      
      list revision {
        key date;
        description "An instance-data-set SHOULD have at least 
            one revision entry.  For every published 
            editorial change, a new one SHOULD be added in front 
            of the revisions sequence so that all revisions are 
            in reverse chronological order.";
                    
        leaf date { 
          type string {
            pattern '\d{4}-\d{2}-\d{2}';
          }
          description "Specifies the data the revision 
              was last modified. Formated as YYYY-MM-DD";
        }
                
        leaf description { type  string; }  
      }
                                            
      anydata data {
        mandatory true;
        description "Contains the real instance data.
            The data MUST conform to the relevant YANG Modules.";
      }
    }
  }
}     
               ]]></artwork>
            </figure>
        <t>&lt;CODE ENDS></t>
    </section>
                    
    <section anchor="security" title="Security Considerations">
      <t> Depending on the nature of the instance data, instance data 
      files MAY need to be handled in a secure way. The same type of 
      handling should be applied, that would be needed for the result 
      of a &lt;get> operation returning the same data.</t>
    </section>
    <section anchor="iana" title="IANA Considerations">
      <t> To be completed, all the usual requests for a new YANG module </t>
    </section>
  </middle>
  <?rfc needLines="20"?>
  <back>
    <references title="Normative References">
      <?rfc include='reference.RFC.7950'?>
      <?rfc include='reference.RFC.7951'?>
      <?rfc include='reference.I-D.ietf-netmod-yang-data-ext'?>
    </references>
    <references title="Informative References">
      <?rfc include='reference.RFC.2119'?>
      <?rfc include='reference.RFC.8174'?>
      <?rfc include='reference.I-D.ietf-netconf-rfc7895bis'?>
      <?rfc include='reference.I-D.ietf-netconf-yang-push'?>
      <?rfc include='reference.I-D.ietf-ccamp-alarm-module'?>      
      <?rfc include='reference.I-D.wu-netconf-restconf-factory-restore'?>      
    </references>
    <?rfc needLines="100"?>

    <section title="Open Issues">
      <t>
        <list style="symbols">
          <t>If we define metadata per target module, a list of target YAM could 
            be included in the metadata. This depends on what additional metadata 
            we will include.
          </t>
          <t>How do we know for which version of the target Yang Module is a 
            data set valid? Proposal: One possibility would be to just indicate for which 
            module version(s) was the data set last updated. This would be a hint 
            about compatibility, but nothing more. Maybe we should wait till the YANG versioning work is 
            complete/stable. Identifying just one version is way to strict, so 
            something enforcing that shall not be used. 
          </t>
          <t>Should we document what YANG features does the instance data set 
            implicitly require? Proposal: that is already a use case, documenting 
            data from the YANG library.
          </t>
          <t>Augmenting metadata must be possible. As of now it looks like 
            yang-data-ext will solve that. If not, define instance data as regular 
            YANG instead of yd:yang-data.
          </t>
        </list>
      </t>
    </section>
    <section title="Changes between revisions">
      <t>v04 - v05
        <list style="symbols">
          <t>Changed title and introduction to clarify that this draft is only 
          about the file format and documenting server capabilities is just a use case.</t>
          <t>Added reference to draft-wu-netconf-restconf-factory-restore</t>
          <t>Added new open issues.</t>
        </list>
      </t>
      <t>v03 - v04
        <list style="symbols">
          <t>Updated changelog for v02-v03</t>
        </list>
      </t>
      <t>v02 - v03
        <list style="symbols">
          <t>Updated the document according to comments received at IETF102</t>
          <t>Added parameter to specify datastore</t>
          <t>Rearranged chapters</t>
          <t>Added new use case: Documenting Factory Default Settings</t>
          <t>Added "Target YANG Module" to terminology</t>
          <t>Clarified that instance data is a snapshot valid at the time of creation, so it does not contain any later changes.</t>
          <t>Removed topics from Open Issues according to comments received at IETF102</t>
        </list>
      </t>
      <t>v01 - v02
        <list style="symbols">
          <t>The recommendation to document server capabilities was changed to 
            be just the primary use-case. (Merged chapter 4 into the use case chapter.)</t>
          <t>Stated that RFC7950/7951 encoding must be followed which also 
          defines (dis)allowed whitespace rules.</t>
          <t>Added UTF-8 encoding as it is not specified in t950 for instance data</t>
          <t>added XML declaration</t>
        </list>
      </t>
      <t>v00 - v01
        <list style="symbols">
          <t>Redefined using yang-data-ext</t>
          <t>Moved meta data into ordinary leafs/leaf-lists</t>
        </list>
      </t>
    </section>    
    
  </back>
</rfc>
<!-- Local Variables: -->
<!-- fill-column:72 -->
<!-- End: -->
