<?xml version="1.0" encoding="US-ASCII"?>
<!-- This template is for creating an Internet Draft using xml2rfc,               
    which is available here: http://xml.resource.org. -->
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!-- One method to get references from the online citation libraries.             
    There has to be one entity for each item to be referenced.                    
    An alternate method (rfc include) is described in the references. -->
<!ENTITY RFC2119 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY RFC2697 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2697.xml">
<!ENTITY RFC2698 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2698.xml">
<!ENTITY RFC6020 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6020.xml">
]>
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<?rfc toc="yes" ?>
<?rfc tocompact="yes"?>
<?rfc tocindent="yes"?>
<?rfc symrefs="yes" ?>
<?rfc sortrefs="yes"?>
<?rfc iprnotified="no" ?>
<?rfc strict="yes" ?>
<?rfc compact="yes"?>
<?rfc subcompact="yes"?>
<rfc category="std" docName="draft-wu-netmod-factory-default-00"
     ipr="trust200902">
  <front>
    <title abbrev="Factory Default Setting">Factory default Setting</title>

    <author fullname="Qin Wu" initials="Q." surname="Wu">
      <organization>Huawei</organization>

      <address>
        <postal>
          <street>101 Software Avenue, Yuhua District</street>

          <city>Nanjing</city>

          <region>Jiangsu</region>

          <code>210012</code>

          <country>China</country>
        </postal>

        <email>bill.wu@huawei.com</email>
      </address>
    </author>

    <author fullname="Balazs Lengyel" initials="B." surname="Lengyel">
      <organization abbrev="Ericsson Hungary">Ericsson Hungary</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 fullname="Ye Niu" initials="Y." surname="Niu">
      <organization>Huawei</organization>

      <address>
        <email>niuye@huawei.com</email>
      </address>
    </author>

    <date year="2018"/>

    <area>OPS Area</area>

    <workgroup>NETMOD Working Group</workgroup>

    <abstract>
      <t>This document defines a method to reset a YANG datastore to it's
      factory-default content. The reset operation may be used e.g. during
      initial zero-touch configuration or when the existing configuration got
      major errors, so re-starting the configuration process from scratch is
      the best option.</t>

      <t>A new reset-datastore RPC is defined. Several methods of documenting
      the factory-default content are specified.</t>

      <t>Optionally a new "factory-default-running" read-only datastore is
      defined, that contains the data that will be copied over to the running
      datastore at reset.</t>
    </abstract>
  </front>

  <middle>
    <section anchor="intro" title="Introduction">
      <t>This document defines a method to reset a YANG datastore to it's
      factory-default content. The reset operation may be used e.g. during
      initial zero-touch configuration or when the existing configuration got
      major errors, so re-starting the configuration process from scratch is
      the best option. When resetting a datastore all previous configuration
      settings will be lost and replaced by the factory-default content.</t>

      <t>A new reset-datastore RPC is defined. Several methods of documenting
      the factory-default content are specified.</t>

      <t>Optionally a new "factory-default-running" read-only datastore is
      defined, that contains the data that will be copied over to the running
      datastore at reset. This datastore can be used in &lt;get-data&gt; or
      &lt;copy-config&gt; operations.</t>

      <t>NETCONF defines the &lt;delete&gt; operation that allows resetting
      the &lt;startup&gt; datastore and the &lt;discard-changes&gt; operation
      that copies the content of the &lt;running&gt; datastore into the
      &lt;candidate&gt; datastore. However it is not possible to reset the
      running datastore, to reset the candidate datastore without changing the
      running datastore or to reset any dynamic datastore.</t>

      <t>A RESTCONF server MAY implement the above NETCONF operations, but
      that would still not allow it to reset the running configuration.</t>

      <section title="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 [RFC2119] [RFC8174] when, and only when, they appear in all
        capitals, as shown here.</t>

        <t>The following terms are defined in [RFC8342] and are not redefined
        here:</t>

        <t><list style="symbols">
            <t>startup configuration datastore</t>

            <t>candiate configuration datastore</t>

            <t>running configuration datastore</t>

            <t>intended configuration datastore</t>

            <t>operational state datastore</t>
          </list></t>

        <t>The following terms are defined in this document as follows:</t>

        <t><list style="symbols">
            <t>factory-default datastore: A read-only datastore holding a
            preconfigured minimal initial configuration that can be used to
            initialize the configuration of a server. The content of the
            datastore is usually static, but MAY depend on external factors
            like available HW.</t>
          </list></t>
      </section>
    </section>

    <!-- intro -->

    <section title="Reset-Datastore RPC">
      <t>A new "reset-datastore" RPC is introduced. It will have a target
      datastore as a parameter. Upon receiveing the RPC the YANG server resets
      the content of the target datastore to it's factory-default content.
      Only writable datastores can be specified as a target. Read-only
      datastores receive their content from other datastores (e.g.
      &lt;intended&gt; gets it's content from &lt;running&gt;).</t>

      <t>Factory-default content SHALL be specified by one of the following
      means in order of precedence <list style="numbers">
          <t>For the &lt;running&gt;, &lt;candidate&gt; and &lt;startup&gt;
          datastores as the content of the &lt;factory-default&gt; datastore,
          if it exists</t>

          <t>YANG Instance Data <xref
          target="I-D.lengyel-netmod-yang-instance-data"/></t>

          <t>In some implementation specific manner</t>

          <t>For dynamic datastores unless otherwise specified the
          factory-default content is empty.</t>
        </list></t>
    </section>

    <section anchor="datastore" title="Factory-Default Datastore">
      <t>This document introduces a new datastore resource named
      'Factory-Default' that represents a preconfigured minimal initial
      configuration that can be used to initialize the configuration of a
      server. <list>
          <t>Name: "factory-default"</t>

          <t>YANG modules: all</t>

          <t>YANG nodes: all "config true" data nodes</t>

          <t>Management operations: The content of the datastore is set by the
          YANG server in an implementation dependent manner. The content can
          not be changed by management operations via NETCONF, RESTCONF, the
          CLI etc. unless specialized, dedicated operations are provided. The
          contents of the datastore can be read using NETCONF, RESTCONF
          &lt;get-data&gt; operation. The operations &lt;reset-datastore&gt;
          or &lt;copy-config&gt; can be used to copy the content of the
          datastore to the another datastore.</t>

          <t>Protocols: RESTCONF, NETCONF and other management protocol.</t>

          <t>Defining YANG module: "ietf-factory-reset"</t>
        </list> The datastore content is usually defined by the device vendor.
      It is usually static, but MAY change e.g. depending on external factors
      like HW available or during device upgrade.</t>

      <t>On devices that support non-volatile storage, the contents of
      &lt;factory &gt; MUST persist across restarts</t>
    </section>

    <section title="YANG Module">
      <figure>
        <artwork>&lt;CODE BEGINS&gt; file "ietf-factory-default.yang"
module ietf-factory-default {
  yang-version 1.1;
  namespace urn:ietf:params:xml:ns:yang:ietf-factory-default;
  prefix fdef;
  
  import ietf-netconf { prefix nc ; }
  import ietf-datastores { prefix ds; }
  
  organization
    "IETF NETCONF (Network Configuration) Working Group";
  contact
    "WG Web:   &lt;https://tools.ietf.org/wg/netconf/&gt;
     WG List:  &lt;mailto:netconf@ietf.org&gt;

     WG Chair: Kent Watsen
               &lt;mailto:kwatsen@juniper.net&gt;

     WG Chair: Mahesh Jethanandani
               &lt;mailto:mjethanandani@gmail.com&gt;

     Editor:   Balazs Lengyel
               &lt;mailto:balazs.lengyel@ericsson.com&gt;
               
     Editor:   Qin Wu
               &lt;mailto:bill.wu@huawei.com&gt;";

  description
    "This module defines the 
    - reset-datastore RPC 
    - factory-default datastore 
    - an extension to the Netconf &lt;copy-config&gt; operation to 
    allow it to operate on the factory-default datastore.
    
    It provides functionality to reset a YANG datastore to it's 
    factory-default content. 

     Copyright (c) 2018 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 Simplified 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).

     The key words 'MUST', 'MUST NOT', 'REQUIRED', 'SHALL', 'SHALL
     NOT', 'SHOULD', 'SHOULD NOT', 'RECOMMENDED', 'MAY', and
     'OPTIONAL' in the module text are to be interpreted as described
     in RFC 2119 (https://tools.ietf.org/html/rfc2119).

     This version of this YANG module is part of RFC XXXX
     (https://tools.ietf.org/html/rfcXXXX); see the RFC itself for
     full legal notices.";

  revision 2018-10-09 {
    description
      "Initial revision.";
      reference "RFC XXXX: Factory default Setting Capability for 
      RESTCONF";
  }
     
  feature factory-default-as-datastore {
    description "Indicates that the factory default configuration is 
      also available as a separate datastore"; 
  }
       
  rpc reset-datastore {
    description "The target datastore is reset to it's factory 
      default content. ";
      
    input {
      leaf-list target-datasore {
        type identityref { 
          base "ds:datastore" ; 
        }
        min-elements 1;
        description "The datastore(s) of which's content will be 
          replaced by the factory-default configuration.";
      }  
      // Do we need an extra parameter that may order a restart of 
      // the YANG-server or the whole system? 
    }
  }
  
  identity factory-default {
    if-feature factory-default-as-datastore;
    base ds:datastore;
    description "The read-only datastore contains the configuration that 
      will be copied into e.g. the running datastore by the 
      reset-datastore operation if the target is the running 
      datastore.";
  }
  
  augment /nc:copy-config/nc:input/nc:source/nc:config-source {
    if-feature factory-default-as-datastore;
    description " Allows the copy-config operation to use the 
      factory-default-running-datastore as a source";
    leaf factory-default { 
        type empty ;
        description
          "The factory-default datastore is the source.";    }
  }
}
&lt;CODE ENDS&gt;</artwork>
      </figure>
    </section>

    <section title="IANA Considerations">
      <t>This document registers one URI in the IETF XML Registry [RFC3688].
      The following registration has been made: <list style="none">
          <t>URI: urn:ietf:params:xml:ns:yang:ietf-factory-default</t>

          <t>Registrant Contact: The IESG.</t>

          <t>XML: N/A, the requested URI is an XML namespace.</t>
        </list></t>

      <t>This document registers one YANG module in the YANG Module Names
      Registry [RFC6020]. The following registration has been made: <list
          style="none">
          <t>name: ietf-factory-default</t>

          <t>namespace: urn:ietf:params:xml:ns:yang:ietf-factory-default</t>

          <t>prefix: fdef</t>

          <t>RFC: xxxx</t>
        </list></t>
    </section>

    <section anchor="security" title="Security Considerations">
      <t>The &lt;reset-datastore&gt; RPC can overwrite important and security
      sensitive information in one of the other datastores e.g. running,
      therefore it is important to restrict access to this RPC using the
      standard access control methods<xref target="RFC8341">.</xref></t>

      <t>The content of the factory-default datastore is usually not security
      sensitive as it is the same on any device of a certain type.</t>
    </section>

    <section title="Acknowledgements">
      <t>Thanks to Juergen Schoenwaelder, Ladislav Lhotka to review this draft
      and provide important input to this document.</t>
    </section>

    <section title="Contributors">
      <figure>
        <artwork>   Rohit R Ranade
   Huawei 
   Email: rohitrranade@huawei.com</artwork>
      </figure>
    </section>

    <!---->
  </middle>

  <back>
    <references title="Normative References">
      <?rfc include="reference.RFC.2119.xml"?>

      <?rfc include="reference.RFC.8174.xml"?>

      <?rfc include="reference.RFC.7950.xml"?>

      <?rfc include='reference.RFC.8342.xml'?>

      <?rfc include='reference.RFC.8341.xml'?>
    </references>

    <references title="Informative References">
      <?rfc include='reference.I-D.ietf-netconf-zerotouch'?>

      <?rfc include='reference.I-D.lengyel-netmod-yang-instance-data'?>
    </references>

    <section title="Open Issues">
      <t><list style="symbols">
          <t>Do we need a restart after &lt;reset-datastore&gt; ? What kind of
          restart, just the YANG-Server or the full system?</t>

          <t>Do we need the concept of reboot? How is that different from a
          restart? Does it result in some sort of reset-datastore?</t>
        </list></t>
    </section>

    <section title="Difference between &lt;startup&gt; datastore and &lt;factory-default&gt; datastore">
      <t>When the device first boots up, the content of the &lt;startup&gt;
      and &lt;factory-default&gt; will be identical. The content of
      &lt;startup&gt; can be subsequently changed by using &lt;startup&gt; as
      a target in a &lt;copy-config&gt; operation. The &lt;factory-default&gt;
      is a read-only datastore and it is usually static as described in
      earlier sections. </t>
    </section>

    <section title="Changes between revisions">
      <t>v02 - v03 <list style="symbols">
          <t>Restructured</t>

          <t>Made new datastore optional</t>

          <t>Removed Netconf capability</t>

          <t>Listed Open issues</t>
        </list></t>

      <t>v01 - v02 <list style="symbols">
          <t>-</t>
        </list></t>

      <t>v00 - v01 <list style="symbols">
          <t>-</t>
        </list></t>
    </section>
  </back>
</rfc>
