Search code examples
ietf-netmod-yang

how is this yang notification valid?


yang 1.1 spec has this example, The following example defines a notification in a data node:

 module example-interface-module {
   yang-version 1.1;
   namespace "urn:example:interface-module";
   prefix "if";

   container interfaces {
     list interface {
       key "name";
       leaf name {
         type string;
       }
       notification interface-enabled {
         leaf by-user {
           type string;
         }
       }
     }
   }
 }

A corresponding XML instance example of the complete notification:

 <notification
   xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
   <eventTime>2008-07-08T00:01:00Z</eventTime>
   <interfaces xmlns="urn:example:interface-module">
     <interface>
       <name>eth1</name>
       <interface-enabled>
         <by-user>fred</by-user>
       </interface-enabled>
     </interface>
   </interfaces>
 </notification>

My question is, when I raise a notification from server, I thought the notification content would be this :

<notification
   xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
   <eventTime>2008-07-08T00:01:00Z</eventTime>
   <interface-enabled xmlns="urn:example:interface-module">
      <by-user>fred</by-user>
   </interface-enabled>
 </notification>

But, such a notification will be useless without identifying the data node for which the notification is relevant.

I guess my question is, what rule/text in the spec tells me how to form the payload correctly


Solution

  • https://www.rfc-editor.org/rfc/rfc7950#section-7.16.2

    When a notification node is defined as a child to a data node, the element defined in [RFC5277] contains a hierarchy of nodes that identifies the node in the datastore. It MUST contain all containers and list nodes from the top level down to the list or container containing the notification.

    The notification payload must include all ancestor container/lists up to the module root. Only then it is always possible to identify the exact node to which the notification is referring.