<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!ENTITY RFC2119 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY RFC7950 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7950.xml">
<!ENTITY RFC7952 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7952.xml">
<!ENTITY RFC6536 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6536.xml">
<!ENTITY I-D.ietf-netconf-yang-push SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.ietf-netconf-yang-push.xml">
<!ENTITY I-D.ietf-netmod-schema-mount SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.ietf-netmod-schema-mount.xml">
]>
<?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?> <!-- used by XSLT processors -->
<!-- OPTIONS, known as processing instructions (PIs) go here. -->
<!-- For a complete list and description of PIs,
     please see http://xml.resource.org/authoring/README.html. -->
<!-- Below are generally applicable PIs that most I-Ds might want to use. -->
<?rfc strict="yes" ?> <!-- give errors regarding ID-nits and DTD validation -->
<!-- control the table of contents (ToC): -->
<?rfc toc="yes"?> <!-- generate a ToC -->
<?rfc tocdepth="2"?> <!-- the number of levels of subsections in ToC. default: 3 -->
<!-- control references: -->
<?rfc symrefs="yes"?> <!-- use symbolic references tags, i.e, [RFC2119] instead of [1] -->
<?rfc sortrefs="yes" ?> <!-- sort the reference entries alphabetically -->
<!-- control vertical white space: 
     (using these PIs as follows is recommended by the RFC Editor) -->
<?rfc compact="yes" ?> <!-- do not start each main section on a new page -->
<?rfc subcompact="no" ?> <!-- keep one blank line between list items -->
<!-- end of popular PIs -->
<rfc  category="std" docName="draft-lengyel-netmod-schema-annotation-00" ipr="trust200902">
  <front>
    <title abbrev="Yang Schema Annotation">Schema Annotation for YANG Models</title>
    <author fullname="Balazs Lengyel" initials="B L" surname="Lengyel">
      <organization>Ericsson</organization>
      <address>
        <!-- postal><street/><city/><region/><code/><country/></postal -->
<!-- <phone/> -->
<!-- <facsimile/> -->
      <email>balazs.lengyel@ericsson.com</email>
<!-- <uri/> -->
      </address>
    </author>
    <date year="2017" />
      <area>OPS</area>
      <workgroup>Netmod</workgroup>
      <keyword>yang</keyword>
      <keyword>schema</keyword>
      <keyword>annotation</keyword>
<!-- <keyword/> -->
    <abstract>
      <t>
          In some cases there is a need to qualify other YANG models or some schema 
          nodes in other models with additional properties (a.k.a. annotations). 
          This document defines a method to add annotations in the form of 
          YANG extension statements to YANG modules. The annotations are defined 
          in separate files without modifying the text of the original YANG module.
      </t>
    </abstract>
  </front>
  <middle>
    <section title="Introduction">
      <t>
        The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
        "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in
        this document are to be interpreted as described in
        <xref target="RFC2119"/>.
     </t>    
      <t>
        In some cases there is a need to qualify other YANG models or some schema 
        nodes in other models with additional properties (a.k.a. annotations). 
        This document defines a method to add annotations in the form of 
        YANG <xref target="RFC7950"/> extension statements to YANG modules. The annotations are defined 
        in separate files without modifying the text of the original YANG module.
      </t>      
      <t>
        Annotations are often specific to the model and/or implementation so they 
        are possible to define in design time. System integrators, people 
        defining configuration ahead of time and others need this 
        information (without reading any data from a live node).
      </t>      
      <t>
        Often the basic YANG model and the extra properties are defined separately,  
        possibly by different organizations. Vendors may qualify standard models 
        with extra properties, or even a vendor defined base model, may need 
        different annotations depending on the specific implementation.
        Vendors are reluctant to modify the standard models (messing up the original 
        file, too many variants of the base model), so it must be possible to define such 
        annotations in a separate file/module.          
      </t>
      <section title="Use Case - Yangpush"><t>
        In YangPush <xref target="I-D.ietf-netconf-yang-push"/> we need to 
        specify for data nodes whether the Yang server 
        supports sending on-change data change notifications for the specific data node 
        or not. Some servers may not support such notifications for specific data nodes 
        because they are meaningless or would result in too many notifications or 
        the server might simply not have implemented them. The support for 
        on-change notifications will be defined using a YANG extension statement.
      </t>
      <t>
          In some cases there is a need to specify the minimum acceptable interval 
          for a periodic subscription for a specific data node or schema branch. 
      </t></section>
      <section title="Use Case - Vendor Annotation of a Standard Model"><t>
        Vendors sometimes want to add extra information to the standard YANG models. 
        Examples include instructions for automatic code generation or formal 
        description of side-effects of manipulating a data node. It would be 
        good for standard SW tools to be at least aware of the vendor extensions, 
        allowing vendor specific plugins to handle these extensions. 
        By providing a standard mechanism to annotate modules generic SW tools 
        might provide somevisibility to vendor specific extensions 
        e.g. providing APIs to fetch the extension, displaying the extension as is.
      </t></section>
    </section>
    <section title="Possible solutions">
        <t>
            All solution alternatives use an Absolute schema node identifier to 
            identify which part of the YANG schema is annotated. Absolute 
            schema node identifier is defined in <xref target="RFC7950"/>.
         </t>
         <t>
            All alternatives will have the same effect as if the YANG extension 
            statement in the annotation was placed in the base model itself. 
         </t>
         <t>
            The process of annotation will consist of the following steps. 
            A base model will be defined. E.g. IETF defined a standard base 
            model like ietf-system. A vendor will define extra data like
            instance data or annotation/deviation YANG modules 
            (e.g. ericsson-system-ann-router1230-release3.yang). Annotation 
            information MAY be defined once per vendor or for every 
            product/product release separately. 
            Annotation information will be available both in design-time as a 
            document and in run-time. 
        </t>
        
        <section title="Instance Data based Solution">
            <t>
                A new YANG module containing information about schema-annotations 
                is defined and a standard way of loading initial instance data 
                in to that module is specified.
                (Note the module is only an example to demonstrate the concept. 
                If the solution is selected, further work on the module is needed.)
            </t>
            <figure><artwork><![CDATA[
    module ietf-schema-annotations {
        list schema-annotations {
            key target;
            config false;
            leaf target  { 
                type schema-node-id; 
                description "identifies the node in the schema tree 
                that is annotated."; 
            }
            
            list annotation {
                key statement;
                min-elements 1;
                leaf statement {
                    type yang:yang-identifier; 
                    description "The statement to be conceptually 
                    added to the target schema node.";               
                }
                leaf argument {
                    type string;
                    description "Argument to the annotation 
                        statement if any.";
                }
            }  
        }
    }
            ]]></artwork></figure>
            <t>
                A standard format to specify initial instance data for a YANG 
                module in a file is defined. The format SHALL be the same as 
                the XML content of the &lt;edit-config&gt; operation 
                inside the &lt;config&gt; element. The &lt;edit-config&gt; format was 
                chosen as that will allow specifying the operation attribute. 
                Both the merge and the replace values might be needed and/or useful.
            </t>
            <t>
                If the instance data represents configuration data it SHALL be 
                loaded by the YANG server at startup into the running datastore 
                of the server before any management interface like CLI, Netconf, 
                Restconf is started. Note this MAY result in overwriting data 
                previously stored in the datastore. If the instance data 
                represents state data it SHALL be 
                loaded by the YANG server at startup into the operation-state datastore 
                before any management interface like CLI, Netconf, 
                Restconf is started.
            </t>
            <t>Example:</t>
            <figure><artwork><![CDATA[
    <model-annotations xmlns:...>
        <target xmlns:sys=...>/sys:system/sys:system-time</target>
        <annotation>
            <statement xmlns:yp=...>yp:notifiable-on-change</statement>
            <argument>false</argument>
        </annotation>
    </model-annotations>
            ]]></artwork></figure>
        <t>
            Instance data for the module ietf-schema-annotations SHOULD become 
            a design time artifact provided by the model designer just as the 
            YANG modules themselves.
        </t>
             <t>
                The XML instance data defining the annotations would be 
                available in design-time as an XML  
                document and in run-time using the &lt;get&gt; operation. 
            </t>
        </section>
        <section title="Extension based Solution">
            <t>
                A new YANG extension "schema-annotation" is defined, that allows 
                adding statement to another module.
            </t>
            <figure><artwork><![CDATA[
    extension schema-annotation {
        description
            "Annotates an existing statement with a YANG extension 
            statement defined in some module. Useful for 
            adding extension statements to a module without touching the 
            module source.      

            Substatements to this statements are conceptually added 
            to the target statement.

            The argument is a 'absolute schema node identifier'. 
            It identifies a target node in the schema tree to 
            annotate with new statements.";

        argument target;
    }            
    
    
    Example:
    
    sann:schema-annotation /sys:system/sys:system-time {
        yp:notifiable-on-change false;
    }

            ]]></artwork></figure>
             <t>               
                The annotating module would be available in design-time as a 
                document and in run-time using the &lt;get-schema&gt; operation. 
            </t>
        </section>
        <section title="Deviation based Solution">
            <t>
                Deviations already allow adding/modifying model information for 
                another module. If IETF would allow the "deviate" statement to 
                handle YANG extension statements this would allow us to 
                add/remove/modify annotations.
            </t>
        </section>
        <section title="Pros and Cons">
            <t>The Instance Data based Solution is the proposed solution.
                <list style="symbols">
                    <t>It could be usable for other purposes as well including 
                        but not restricted to defining default security rules for access control <xref target="RFC6536"/>
                        or defining yang-schema-mounts 
                        <xref target="I-D.ietf-netmod-schema-mount"/> in design time.
                    </t>
                    <t>
                        It is more simple to read in runtime for management systems (MS).
                    </t>    
                    <t>
                        If annotation data was ever changed the MS could get 
                        notifications about that.
                    </t>
                    <t>It could easily be linked with references to the ietf-yang-library</t>
                    <t>
                        It introduces a bigger new concept (instance data) although 
                        a number of vendors are already using it.
                    </t>
                </list>                                 
            </t>
            <t>
                The Extension Based Solution works.
            </t>                
            <t>
                We do not recommend using the Deviation based Solution as 
                deviations are for documenting unwelcome implementation 
                limitations and are highly discouraged. Adding our extra 
                information is not just acceptable, it is the recommended thing 
                to do. Extending the allowed substatements for the deviate 
                statement can also be considered changing <xref target="RFC7950"/>.
            </t>
        </section>
    </section>
    <section title="How is this different from RFC7952 &quot;Defining and Using Metadata with YANG?&quot;">
        <t><xref target="RFC7952"/> defines metadata on the instance data level, 
            here we need metadata on the model/schema level.</t>
        <t><xref target="RFC7952"/> metadata is transferred in Netconf/Restconf 
            RPCs, here we usually do not need that.</t>
        <t><xref target="RFC7952"/> metadata is only available in runtime, here 
        we need it to be available in design time.</t>
    </section>
    <section title="Open Issues">
        <t>
            <list style="symbols">
                <t>Set of statements that can be the target. The initial proposal 
                    is to allow the same set of schema nodes as "deviation" statement. 
                    Is that OK?
                </t>
                <t>Set of statements that can be added. 
                    The initial proposal allows only YANG extension statements. 
                    Do we want to allow anything else like additional "must" statements 
                    or restrictions? Probably not as that would allow redefining 
                    the base model, which we don't want. We only want to add 
                    information to it.
                </t>
                <t>Exact data model for module ietf-schema-annotations.</t>
                <t>
                    Do we need replace and delete operations beside the add? The 
                    initial proposal only allows adding annotations. Do we need to 
                    be able to replace and remove them as well?
                </t>
            </list>
        </t>
    </section>
    <section anchor="Acknowledgements" title="Acknowledgements">
        <t>The author wishes to thank Eric Voit, Einar Nilsen-Nygaard and Alexander Clemm for their helpful comments contributing to this draft.</t>
    </section>
    <section anchor="IANA" title="IANA Considerations">
        <t>No IANA considerations</t>
    </section>
    <section anchor="Security" title="Security Considerations">
        <t>
            This document introduces a mechanism for attaching metadata defined 
            in the form of YANG extensions to the YANG schema of another YANG module.
            By itself, this mechanism represents no security threat.
            Security implications of a particular extension and attaching it to a 
            particular YANG module shall be considered in 
            the document defining/attaching the extension.
        </t>
    </section>
  </middle>
  <back>
    <references title="Normative References">
      &RFC2119;
      &RFC7950;
      &RFC7952;
      &RFC6536;
    </references>
    <references title="Informative References">
      &I-D.ietf-netconf-yang-push;
      &I-D.ietf-netmod-schema-mount;
    </references>
  </back>
</rfc>
