Bug 5679 - implement ietf-restconf-monitoring - capabilities 26/49026/6
authorJakub Toth <jatoth@cisco.com>
Tue, 6 Dec 2016 11:45:53 +0000 (12:45 +0100)
committerJakub Toth <jatoth@cisco.com>
Tue, 20 Dec 2016 10:39:57 +0000 (10:39 +0000)
  * make constants in QueryParams full (with BASE_URI path)
  * mapping capabilities
  * put mapped capabilities to operational DS in provider
  * added + fixed tests

Change-Id: Ibf1cdb2d07d3172fd21558095307962767ea32ff
Signed-off-by: Jakub Toth <jatoth@cisco.com>
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/Draft18.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/RestConnectorProvider.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/handlers/SchemaContextHandler.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/utils/mapping/RestconfMappingNodeUtil.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/utils/mapping/RestconfMappingNodeUtilTest.java
restconf/sal-rest-connector/src/test/resources/invoke-rpc/ietf-restconf-monitoring@2016-08-15.yang [new file with mode: 0644]
restconf/sal-rest-connector/src/test/resources/jukebox/ietf-restconf-monitoring@2016-08-15.yang [new file with mode: 0644]
restconf/sal-rest-connector/src/test/resources/modules/ietf-restconf-monitoring@2016-08-15.yang [new file with mode: 0644]
restconf/sal-rest-connector/src/test/resources/modules/modules-behind-mount-point/ietf-restconf-monitoring@2016-08-15.yang [new file with mode: 0644]
restconf/sal-rest-connector/src/test/resources/notifications/ietf-restconf-monitoring@2016-08-15.yang [new file with mode: 0644]

index a9b691d5212e3cc46d007af34bbe72206dcba8e7..d2321dadef7367e4a71c199d7a3e097575a2afec 100644 (file)
@@ -266,11 +266,11 @@ public final class Draft18 {
 
             public static final String URI_BASE = "urn:ietf:params:restconf:capability:";
 
-            public static final String DEPTH = "depth:1.0";
-            public static final String FIELDS = "fields:1.0";
-            public static final String FILTER = "filter:1.0";
-            public static final String REPLAY = "replay:1.0";
-            public static final String WITH_DEFAULTS = "with-defaults:1.0";
+            public static final String DEPTH = URI_BASE + "depth:1.0";
+            public static final String FIELDS = URI_BASE + "fields:1.0";
+            public static final String FILTER = URI_BASE + "filter:1.0";
+            public static final String REPLAY = URI_BASE + "replay:1.0";
+            public static final String WITH_DEFAULTS = URI_BASE + "with-defaults:1.0";
         }
     }
 }
index 37eac281989533265848efcc819ad77f44ff7283..07da9e9c000a9ecf378ebeab688e461d58241f3e 100644 (file)
@@ -59,6 +59,8 @@ public class RestConnectorProvider implements Provider, RestConnector, AutoClose
     };
 
     private ListenerRegistration<SchemaContextListener> listenerRegistration;
+
+    private SchemaContextHandler schemaCtxHandler;
     private static TransactionChainHandler transactionChainHandler;
     private static DOMDataBroker dataBroker;
     private static DOMMountPointServiceHandler mountPointServiceHandler;
@@ -78,8 +80,8 @@ public class RestConnectorProvider implements Provider, RestConnector, AutoClose
         RestConnectorProvider.transactionChainHandler = new TransactionChainHandler(RestConnectorProvider.dataBroker
                 .createTransactionChain(RestConnectorProvider.transactionListener));
 
-        final SchemaContextHandler schemaCtxHandler = new SchemaContextHandler(transactionChainHandler);
-        this.listenerRegistration = schemaService.registerSchemaContextListener(schemaCtxHandler);
+        this.schemaCtxHandler = new SchemaContextHandler(transactionChainHandler);
+        this.listenerRegistration = schemaService.registerSchemaContextListener(this.schemaCtxHandler);
 
         final DOMRpcService rpcService = session.getService(DOMRpcService.class);
         final RpcServiceHandler rpcServiceHandler = new RpcServiceHandler(rpcService);
@@ -88,7 +90,7 @@ public class RestConnectorProvider implements Provider, RestConnector, AutoClose
         final NotificationServiceHandler notificationServiceHandler =
                 new NotificationServiceHandler(notificationService);
 
-        wrapperServices.setHandlers(schemaCtxHandler, RestConnectorProvider.mountPointServiceHandler,
+        wrapperServices.setHandlers(this.schemaCtxHandler, RestConnectorProvider.mountPointServiceHandler,
                 RestConnectorProvider.transactionChainHandler, brokerHandler, rpcServiceHandler,
                 notificationServiceHandler);
     }
index 70f1b72618258b2e6c79f3f905ac03fcf6c34ae3..c9f849bc4eb007ba2184454cb6c9fbdef21f3e91 100644 (file)
@@ -14,6 +14,7 @@ import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFaile
 import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException;
 import org.opendaylight.restconf.Draft18.IetfYangLibrary;
+import org.opendaylight.restconf.Draft18.MonitoringModule;
 import org.opendaylight.restconf.utils.mapping.RestconfMappingNodeUtil;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
@@ -52,9 +53,24 @@ public class SchemaContextHandler implements SchemaContextListenerHandler {
         this.moduleSetId++;
         final Module ietfYangLibraryModule =
                 context.findModuleByNamespaceAndRevision(IetfYangLibrary.URI_MODULE, IetfYangLibrary.DATE);
-        final NormalizedNode<NodeIdentifier, Collection<DataContainerChild<? extends PathArgument, ?>>> normNode =
+        NormalizedNode<NodeIdentifier, Collection<DataContainerChild<? extends PathArgument, ?>>> normNode =
                 RestconfMappingNodeUtil.mapModulesByIetfYangLibraryYang(context.getModules(), ietfYangLibraryModule,
                         context, String.valueOf(this.moduleSetId));
+        putData(normNode);
+
+        final Module monitoringModule =
+                this.context.findModuleByNamespaceAndRevision(MonitoringModule.URI_MODULE, MonitoringModule.DATE);
+        normNode = RestconfMappingNodeUtil.mapCapabilites(monitoringModule);
+        putData(normNode);
+    }
+
+    @Override
+    public SchemaContext get() {
+        return this.context;
+    }
+
+    private void putData(
+            final NormalizedNode<NodeIdentifier, Collection<DataContainerChild<? extends PathArgument, ?>>> normNode) {
         final DOMDataWriteTransaction wTx = this.transactionChainHandler.get().newWriteOnlyTransaction();
         wTx.put(LogicalDatastoreType.OPERATIONAL,
                 YangInstanceIdentifier.create(NodeIdentifier.create(normNode.getNodeType())), normNode);
@@ -64,9 +80,4 @@ public class SchemaContextHandler implements SchemaContextListenerHandler {
             throw new RestconfDocumentedException("Problem occured while putting data to DS.", e);
         }
     }
-
-    @Override
-    public SchemaContext get() {
-        return this.context;
-    }
 }
index e8d05f94bb5bfcad6bda92c29561e403c963bf2d..4b92d5549d9cad4f09f1f45fd3a0ef579b84df81 100644 (file)
@@ -13,6 +13,8 @@ import java.util.Collection;
 import java.util.Set;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException;
 import org.opendaylight.restconf.Draft18.IetfYangLibrary;
+import org.opendaylight.restconf.Draft18.MonitoringModule;
+import org.opendaylight.restconf.Draft18.MonitoringModule.QueryParams;
 import org.opendaylight.restconf.utils.schema.context.RestconfSchemaUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.Module.ConformanceType;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -422,4 +424,80 @@ public final class RestconfMappingNodeUtil {
         Preconditions.checkState(schemaNode instanceof LeafSchemaNode);
         streamNodeValues.withChild(Builders.leafBuilder((LeafSchemaNode) schemaNode).withValue(value).build());
     }
+
+    /**
+     * Map capabilites by ietf-restconf-monitoring
+     *
+     * @param monitoringModule
+     *            - ietf-restconf-monitoring module
+     * @return mapped capabilites
+     */
+    public static NormalizedNode<NodeIdentifier, Collection<DataContainerChild<? extends PathArgument, ?>>>
+            mapCapabilites(final Module monitoringModule) {
+        final DataSchemaNode restconfState =
+                monitoringModule.getDataChildByName(MonitoringModule.CONT_RESTCONF_STATE_QNAME);
+        final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> restStateContBuilder =
+                Builders.containerBuilder((ContainerSchemaNode) restconfState);
+        final DataSchemaNode capabilitesContSchema =
+                getChildOfCont((ContainerSchemaNode) restconfState, MonitoringModule.CONT_CAPABILITES_QNAME);
+        final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> capabilitesContBuilder =
+                Builders.containerBuilder((ContainerSchemaNode) capabilitesContSchema);
+        final DataSchemaNode leafListCapa = getChildOfCont((ContainerSchemaNode) capabilitesContSchema,
+                MonitoringModule.LEAF_LIST_CAPABILITY_QNAME);
+        final ListNodeBuilder<Object, LeafSetEntryNode<Object>> leafListCapaBuilder =
+                Builders.orderedLeafSetBuilder((LeafListSchemaNode) leafListCapa);
+        fillLeafListCapa(leafListCapaBuilder, (LeafListSchemaNode) leafListCapa);
+
+        return restStateContBuilder.withChild(capabilitesContBuilder.withChild(leafListCapaBuilder.build()).build())
+                .build();
+    }
+
+    /**
+     * Map data to leaf-list
+     *
+     * @param builder
+     *            - builder of parent for children
+     * @param leafListSchema
+     */
+    @SuppressWarnings("unchecked")
+    private static void fillLeafListCapa(final ListNodeBuilder builder, final LeafListSchemaNode leafListSchema) {
+        builder.withChild(leafListEntryBuild(leafListSchema, QueryParams.DEPTH));
+        builder.withChild(leafListEntryBuild(leafListSchema, QueryParams.FIELDS));
+        builder.withChild(leafListEntryBuild(leafListSchema, QueryParams.FILTER));
+        builder.withChild(leafListEntryBuild(leafListSchema, QueryParams.REPLAY));
+        builder.withChild(leafListEntryBuild(leafListSchema, QueryParams.WITH_DEFAULTS));
+    }
+
+    /**
+     * Map value to leaf list entry node
+     *
+     * @param leafListSchema
+     *            - leaf list schema of leaf list entry
+     * @param value
+     *            - value of leaf entry
+     * @return entry node
+     */
+    @SuppressWarnings("rawtypes")
+    private static LeafSetEntryNode leafListEntryBuild(final LeafListSchemaNode leafListSchema, final String value) {
+        return Builders.leafSetEntryBuilder(leafListSchema).withValue(value).build();
+    }
+
+    /**
+     * Find specific schema node by qname in parent {@link ContainerSchemaNode}
+     *
+     * @param parent
+     *            - schemaNode
+     * @param childQName
+     *            - specific qname of child
+     * @return schema node of child by qname
+     */
+    private static DataSchemaNode getChildOfCont(final ContainerSchemaNode parent, final QName childQName) {
+        for (final DataSchemaNode child : parent.getChildNodes()) {
+            if (child.getQName().equals(childQName)) {
+                return child;
+            }
+        }
+        throw new RestconfDocumentedException(
+                childQName.getLocalName() + " doesn't exist in container " + MonitoringModule.CONT_RESTCONF_STATE_NAME);
+    }
 }
index 3a3b33ba9b3c9d69171eeb28d0eed9e0d676093c..c078a8468fb44a948007c4e1057fcc1be9e41ace 100644 (file)
@@ -15,14 +15,17 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import com.google.common.collect.Sets;
 import java.util.AbstractMap;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
+import org.junit.Assert;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Rule;
@@ -37,6 +40,7 @@ import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorType;
 import org.opendaylight.restconf.Draft18;
 import org.opendaylight.restconf.Draft18.IetfYangLibrary;
 import org.opendaylight.restconf.Draft18.MonitoringModule;
+import org.opendaylight.restconf.Draft18.MonitoringModule.QueryParams;
 import org.opendaylight.restconf.Draft18.RestconfModule;
 import org.opendaylight.restconf.utils.schema.context.RestconfSchemaUtil;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -47,6 +51,8 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgum
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
+import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
+import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@@ -74,15 +80,18 @@ public class RestconfMappingNodeUtilTest {
 
     private static Set<Module> modules;
     private static SchemaContext schemaContext;
+    private static SchemaContext schemaContextCapabilites;
 
     private static Set<Module> modulesRest;
+
     private Set<DataSchemaNode> allStreamChildNodes;
 
     @BeforeClass
     public static void loadTestSchemaContextAndModules() throws Exception {
         RestconfMappingNodeUtilTest.schemaContext = TestRestconfUtils.loadSchemaContext(
                 "/modules/restconf-module-testing");
-        RestconfMappingNodeUtilTest.modules = TestRestconfUtils.loadSchemaContext("/modules").getModules();
+        RestconfMappingNodeUtilTest.schemaContextCapabilites = TestRestconfUtils.loadSchemaContext("/modules");
+        RestconfMappingNodeUtilTest.modules = schemaContextCapabilites.getModules();
         RestconfMappingNodeUtilTest.modulesRest =
                 TestRestconfUtils.loadSchemaContext("/modules/restconf-module-testing").getModules();
     }
@@ -119,6 +128,32 @@ public class RestconfMappingNodeUtilTest {
         verifyLoadedModules((ContainerNode) modules);
     }
 
+    @Test
+    public void restconfStateCapabilitesTest() {
+        final Module monitoringModule = schemaContextCapabilites
+                .findModuleByNamespaceAndRevision(MonitoringModule.URI_MODULE, MonitoringModule.DATE);
+        final NormalizedNode<NodeIdentifier, Collection<DataContainerChild<? extends PathArgument, ?>>> normNode =
+                RestconfMappingNodeUtil.mapCapabilites(monitoringModule);
+        assertNotNull(normNode);
+        final List<Object> listOfValues = new ArrayList<>();
+
+        for (final DataContainerChild<? extends PathArgument, ?> child : ((ContainerNode) normNode).getValue()) {
+            if (child.getNodeType().equals(MonitoringModule.CONT_CAPABILITES_QNAME)) {
+                for (final DataContainerChild<? extends PathArgument, ?> dataContainerChild : ((ContainerNode) child)
+                        .getValue()) {
+                    for (final Object entry : ((LeafSetNode) dataContainerChild).getValue()) {
+                        listOfValues.add(((LeafSetEntryNode) entry).getValue());
+                    }
+                }
+            }
+        }
+        Assert.assertTrue(listOfValues.contains(QueryParams.DEPTH));
+        Assert.assertTrue(listOfValues.contains(QueryParams.FIELDS));
+        Assert.assertTrue(listOfValues.contains(QueryParams.FILTER));
+        Assert.assertTrue(listOfValues.contains(QueryParams.REPLAY));
+        Assert.assertTrue(listOfValues.contains(QueryParams.WITH_DEFAULTS));
+    }
+
     /**
      * Positive test of writing one stream to {@link MonitoringModule#STREAM_LIST_SCHEMA_NODE} and checking if stream
      * was correctly written.
diff --git a/restconf/sal-rest-connector/src/test/resources/invoke-rpc/ietf-restconf-monitoring@2016-08-15.yang b/restconf/sal-rest-connector/src/test/resources/invoke-rpc/ietf-restconf-monitoring@2016-08-15.yang
new file mode 100644 (file)
index 0000000..8204141
--- /dev/null
@@ -0,0 +1,148 @@
+module ietf-restconf-monitoring {
+  namespace "urn:ietf:params:xml:ns:yang:ietf-restconf-monitoring";
+  prefix "rcmon";
+
+  import ietf-yang-types { prefix yang; }
+  import ietf-inet-types { prefix inet; }
+
+  organization
+    "IETF NETCONF (Network Configuration) Working Group";
+
+  contact
+    "WG Web:   <http://tools.ietf.org/wg/netconf/>
+     WG List:  <mailto:netconf@ietf.org>
+     Author:   Andy Bierman
+               <mailto:andy@yumaworks.com>
+     Author:   Martin Bjorklund
+               <mailto:mbj@tail-f.com>
+     Author:   Kent Watsen
+               <mailto:kwatsen@juniper.net>";
+
+  description
+    "This module contains monitoring information for the
+     RESTCONF protocol.
+     Copyright (c) 2016 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
+     (http://trustee.ietf.org/license-info).
+     This version of this YANG module is part of RFC XXXX; see
+     the RFC itself for full legal notices.";
+
+  // RFC Ed.: replace XXXX with actual RFC number and remove this
+  // note.
+
+  // RFC Ed.: remove this note
+  // Note: extracted from draft-ietf-netconf-restconf-17.txt
+
+  // RFC Ed.: update the date below with the date of RFC publication
+  // and remove this note.
+  revision 2016-08-15 {
+    description
+      "Initial revision.";
+    reference
+      "RFC XXXX: RESTCONF Protocol.";
+  }
+
+  container restconf-state {
+    config false;
+    description
+      "Contains RESTCONF protocol monitoring information.";
+
+    container capabilities {
+      description
+        "Contains a list of protocol capability URIs";
+
+      leaf-list capability {
+        type inet:uri;
+        description "A RESTCONF protocol capability URI.";
+      }
+    }
+
+    container streams {
+      description
+        "Container representing the notification event streams
+         supported by the server.";
+       reference
+         "RFC 5277, Section 3.4, <streams> element.";
+
+      list stream {
+        key name;
+        description
+          "Each entry describes an event stream supported by
+           the server.";
+
+        leaf name {
+          type string;
+          description "The stream name";
+          reference "RFC 5277, Section 3.4, <name> element.";
+        }
+
+        leaf description {
+          type string;
+          description "Description of stream content";
+          reference
+            "RFC 5277, Section 3.4, <description> element.";
+        }
+
+        leaf replay-support {
+          type boolean;
+          default false;
+          description
+            "Indicates if replay buffer supported for this stream.
+             If 'true', then the server MUST support the 'start-time'
+             and 'stop-time' query parameters for this stream.";
+          reference
+            "RFC 5277, Section 3.4, <replaySupport> element.";
+        }
+
+        leaf replay-log-creation-time {
+          when "../replay-support" {
+            description
+              "Only present if notification replay is supported";
+          }
+          type yang:date-and-time;
+          description
+            "Indicates the time the replay log for this stream
+             was created.";
+          reference
+            "RFC 5277, Section 3.4, <replayLogCreationTime>
+             element.";
+        }
+
+        list access {
+          key encoding;
+          min-elements 1;
+          description
+            "The server will create an entry in this list for each
+             encoding format that is supported for this stream.
+             The media type 'text/event-stream' is expected
+             for all event streams. This list identifies the
+             sub-types supported for this stream.";
+
+          leaf encoding {
+            type string;
+            description
+              "This is the secondary encoding format within the
+               'text/event-stream' encoding used by all streams.
+               The type 'xml' is supported for XML encoding.
+               The type 'json' is supported for JSON encoding.";
+          }
+
+          leaf location {
+            type inet:uri;
+            mandatory true;
+            description
+              "Contains a URL that represents the entry point
+               for establishing notification delivery via server
+               sent events.";
+          }
+        }
+      }
+    }
+  }
+
+}
diff --git a/restconf/sal-rest-connector/src/test/resources/jukebox/ietf-restconf-monitoring@2016-08-15.yang b/restconf/sal-rest-connector/src/test/resources/jukebox/ietf-restconf-monitoring@2016-08-15.yang
new file mode 100644 (file)
index 0000000..8204141
--- /dev/null
@@ -0,0 +1,148 @@
+module ietf-restconf-monitoring {
+  namespace "urn:ietf:params:xml:ns:yang:ietf-restconf-monitoring";
+  prefix "rcmon";
+
+  import ietf-yang-types { prefix yang; }
+  import ietf-inet-types { prefix inet; }
+
+  organization
+    "IETF NETCONF (Network Configuration) Working Group";
+
+  contact
+    "WG Web:   <http://tools.ietf.org/wg/netconf/>
+     WG List:  <mailto:netconf@ietf.org>
+     Author:   Andy Bierman
+               <mailto:andy@yumaworks.com>
+     Author:   Martin Bjorklund
+               <mailto:mbj@tail-f.com>
+     Author:   Kent Watsen
+               <mailto:kwatsen@juniper.net>";
+
+  description
+    "This module contains monitoring information for the
+     RESTCONF protocol.
+     Copyright (c) 2016 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
+     (http://trustee.ietf.org/license-info).
+     This version of this YANG module is part of RFC XXXX; see
+     the RFC itself for full legal notices.";
+
+  // RFC Ed.: replace XXXX with actual RFC number and remove this
+  // note.
+
+  // RFC Ed.: remove this note
+  // Note: extracted from draft-ietf-netconf-restconf-17.txt
+
+  // RFC Ed.: update the date below with the date of RFC publication
+  // and remove this note.
+  revision 2016-08-15 {
+    description
+      "Initial revision.";
+    reference
+      "RFC XXXX: RESTCONF Protocol.";
+  }
+
+  container restconf-state {
+    config false;
+    description
+      "Contains RESTCONF protocol monitoring information.";
+
+    container capabilities {
+      description
+        "Contains a list of protocol capability URIs";
+
+      leaf-list capability {
+        type inet:uri;
+        description "A RESTCONF protocol capability URI.";
+      }
+    }
+
+    container streams {
+      description
+        "Container representing the notification event streams
+         supported by the server.";
+       reference
+         "RFC 5277, Section 3.4, <streams> element.";
+
+      list stream {
+        key name;
+        description
+          "Each entry describes an event stream supported by
+           the server.";
+
+        leaf name {
+          type string;
+          description "The stream name";
+          reference "RFC 5277, Section 3.4, <name> element.";
+        }
+
+        leaf description {
+          type string;
+          description "Description of stream content";
+          reference
+            "RFC 5277, Section 3.4, <description> element.";
+        }
+
+        leaf replay-support {
+          type boolean;
+          default false;
+          description
+            "Indicates if replay buffer supported for this stream.
+             If 'true', then the server MUST support the 'start-time'
+             and 'stop-time' query parameters for this stream.";
+          reference
+            "RFC 5277, Section 3.4, <replaySupport> element.";
+        }
+
+        leaf replay-log-creation-time {
+          when "../replay-support" {
+            description
+              "Only present if notification replay is supported";
+          }
+          type yang:date-and-time;
+          description
+            "Indicates the time the replay log for this stream
+             was created.";
+          reference
+            "RFC 5277, Section 3.4, <replayLogCreationTime>
+             element.";
+        }
+
+        list access {
+          key encoding;
+          min-elements 1;
+          description
+            "The server will create an entry in this list for each
+             encoding format that is supported for this stream.
+             The media type 'text/event-stream' is expected
+             for all event streams. This list identifies the
+             sub-types supported for this stream.";
+
+          leaf encoding {
+            type string;
+            description
+              "This is the secondary encoding format within the
+               'text/event-stream' encoding used by all streams.
+               The type 'xml' is supported for XML encoding.
+               The type 'json' is supported for JSON encoding.";
+          }
+
+          leaf location {
+            type inet:uri;
+            mandatory true;
+            description
+              "Contains a URL that represents the entry point
+               for establishing notification delivery via server
+               sent events.";
+          }
+        }
+      }
+    }
+  }
+
+}
diff --git a/restconf/sal-rest-connector/src/test/resources/modules/ietf-restconf-monitoring@2016-08-15.yang b/restconf/sal-rest-connector/src/test/resources/modules/ietf-restconf-monitoring@2016-08-15.yang
new file mode 100644 (file)
index 0000000..8204141
--- /dev/null
@@ -0,0 +1,148 @@
+module ietf-restconf-monitoring {
+  namespace "urn:ietf:params:xml:ns:yang:ietf-restconf-monitoring";
+  prefix "rcmon";
+
+  import ietf-yang-types { prefix yang; }
+  import ietf-inet-types { prefix inet; }
+
+  organization
+    "IETF NETCONF (Network Configuration) Working Group";
+
+  contact
+    "WG Web:   <http://tools.ietf.org/wg/netconf/>
+     WG List:  <mailto:netconf@ietf.org>
+     Author:   Andy Bierman
+               <mailto:andy@yumaworks.com>
+     Author:   Martin Bjorklund
+               <mailto:mbj@tail-f.com>
+     Author:   Kent Watsen
+               <mailto:kwatsen@juniper.net>";
+
+  description
+    "This module contains monitoring information for the
+     RESTCONF protocol.
+     Copyright (c) 2016 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
+     (http://trustee.ietf.org/license-info).
+     This version of this YANG module is part of RFC XXXX; see
+     the RFC itself for full legal notices.";
+
+  // RFC Ed.: replace XXXX with actual RFC number and remove this
+  // note.
+
+  // RFC Ed.: remove this note
+  // Note: extracted from draft-ietf-netconf-restconf-17.txt
+
+  // RFC Ed.: update the date below with the date of RFC publication
+  // and remove this note.
+  revision 2016-08-15 {
+    description
+      "Initial revision.";
+    reference
+      "RFC XXXX: RESTCONF Protocol.";
+  }
+
+  container restconf-state {
+    config false;
+    description
+      "Contains RESTCONF protocol monitoring information.";
+
+    container capabilities {
+      description
+        "Contains a list of protocol capability URIs";
+
+      leaf-list capability {
+        type inet:uri;
+        description "A RESTCONF protocol capability URI.";
+      }
+    }
+
+    container streams {
+      description
+        "Container representing the notification event streams
+         supported by the server.";
+       reference
+         "RFC 5277, Section 3.4, <streams> element.";
+
+      list stream {
+        key name;
+        description
+          "Each entry describes an event stream supported by
+           the server.";
+
+        leaf name {
+          type string;
+          description "The stream name";
+          reference "RFC 5277, Section 3.4, <name> element.";
+        }
+
+        leaf description {
+          type string;
+          description "Description of stream content";
+          reference
+            "RFC 5277, Section 3.4, <description> element.";
+        }
+
+        leaf replay-support {
+          type boolean;
+          default false;
+          description
+            "Indicates if replay buffer supported for this stream.
+             If 'true', then the server MUST support the 'start-time'
+             and 'stop-time' query parameters for this stream.";
+          reference
+            "RFC 5277, Section 3.4, <replaySupport> element.";
+        }
+
+        leaf replay-log-creation-time {
+          when "../replay-support" {
+            description
+              "Only present if notification replay is supported";
+          }
+          type yang:date-and-time;
+          description
+            "Indicates the time the replay log for this stream
+             was created.";
+          reference
+            "RFC 5277, Section 3.4, <replayLogCreationTime>
+             element.";
+        }
+
+        list access {
+          key encoding;
+          min-elements 1;
+          description
+            "The server will create an entry in this list for each
+             encoding format that is supported for this stream.
+             The media type 'text/event-stream' is expected
+             for all event streams. This list identifies the
+             sub-types supported for this stream.";
+
+          leaf encoding {
+            type string;
+            description
+              "This is the secondary encoding format within the
+               'text/event-stream' encoding used by all streams.
+               The type 'xml' is supported for XML encoding.
+               The type 'json' is supported for JSON encoding.";
+          }
+
+          leaf location {
+            type inet:uri;
+            mandatory true;
+            description
+              "Contains a URL that represents the entry point
+               for establishing notification delivery via server
+               sent events.";
+          }
+        }
+      }
+    }
+  }
+
+}
diff --git a/restconf/sal-rest-connector/src/test/resources/modules/modules-behind-mount-point/ietf-restconf-monitoring@2016-08-15.yang b/restconf/sal-rest-connector/src/test/resources/modules/modules-behind-mount-point/ietf-restconf-monitoring@2016-08-15.yang
new file mode 100644 (file)
index 0000000..8204141
--- /dev/null
@@ -0,0 +1,148 @@
+module ietf-restconf-monitoring {
+  namespace "urn:ietf:params:xml:ns:yang:ietf-restconf-monitoring";
+  prefix "rcmon";
+
+  import ietf-yang-types { prefix yang; }
+  import ietf-inet-types { prefix inet; }
+
+  organization
+    "IETF NETCONF (Network Configuration) Working Group";
+
+  contact
+    "WG Web:   <http://tools.ietf.org/wg/netconf/>
+     WG List:  <mailto:netconf@ietf.org>
+     Author:   Andy Bierman
+               <mailto:andy@yumaworks.com>
+     Author:   Martin Bjorklund
+               <mailto:mbj@tail-f.com>
+     Author:   Kent Watsen
+               <mailto:kwatsen@juniper.net>";
+
+  description
+    "This module contains monitoring information for the
+     RESTCONF protocol.
+     Copyright (c) 2016 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
+     (http://trustee.ietf.org/license-info).
+     This version of this YANG module is part of RFC XXXX; see
+     the RFC itself for full legal notices.";
+
+  // RFC Ed.: replace XXXX with actual RFC number and remove this
+  // note.
+
+  // RFC Ed.: remove this note
+  // Note: extracted from draft-ietf-netconf-restconf-17.txt
+
+  // RFC Ed.: update the date below with the date of RFC publication
+  // and remove this note.
+  revision 2016-08-15 {
+    description
+      "Initial revision.";
+    reference
+      "RFC XXXX: RESTCONF Protocol.";
+  }
+
+  container restconf-state {
+    config false;
+    description
+      "Contains RESTCONF protocol monitoring information.";
+
+    container capabilities {
+      description
+        "Contains a list of protocol capability URIs";
+
+      leaf-list capability {
+        type inet:uri;
+        description "A RESTCONF protocol capability URI.";
+      }
+    }
+
+    container streams {
+      description
+        "Container representing the notification event streams
+         supported by the server.";
+       reference
+         "RFC 5277, Section 3.4, <streams> element.";
+
+      list stream {
+        key name;
+        description
+          "Each entry describes an event stream supported by
+           the server.";
+
+        leaf name {
+          type string;
+          description "The stream name";
+          reference "RFC 5277, Section 3.4, <name> element.";
+        }
+
+        leaf description {
+          type string;
+          description "Description of stream content";
+          reference
+            "RFC 5277, Section 3.4, <description> element.";
+        }
+
+        leaf replay-support {
+          type boolean;
+          default false;
+          description
+            "Indicates if replay buffer supported for this stream.
+             If 'true', then the server MUST support the 'start-time'
+             and 'stop-time' query parameters for this stream.";
+          reference
+            "RFC 5277, Section 3.4, <replaySupport> element.";
+        }
+
+        leaf replay-log-creation-time {
+          when "../replay-support" {
+            description
+              "Only present if notification replay is supported";
+          }
+          type yang:date-and-time;
+          description
+            "Indicates the time the replay log for this stream
+             was created.";
+          reference
+            "RFC 5277, Section 3.4, <replayLogCreationTime>
+             element.";
+        }
+
+        list access {
+          key encoding;
+          min-elements 1;
+          description
+            "The server will create an entry in this list for each
+             encoding format that is supported for this stream.
+             The media type 'text/event-stream' is expected
+             for all event streams. This list identifies the
+             sub-types supported for this stream.";
+
+          leaf encoding {
+            type string;
+            description
+              "This is the secondary encoding format within the
+               'text/event-stream' encoding used by all streams.
+               The type 'xml' is supported for XML encoding.
+               The type 'json' is supported for JSON encoding.";
+          }
+
+          leaf location {
+            type inet:uri;
+            mandatory true;
+            description
+              "Contains a URL that represents the entry point
+               for establishing notification delivery via server
+               sent events.";
+          }
+        }
+      }
+    }
+  }
+
+}
diff --git a/restconf/sal-rest-connector/src/test/resources/notifications/ietf-restconf-monitoring@2016-08-15.yang b/restconf/sal-rest-connector/src/test/resources/notifications/ietf-restconf-monitoring@2016-08-15.yang
new file mode 100644 (file)
index 0000000..8204141
--- /dev/null
@@ -0,0 +1,148 @@
+module ietf-restconf-monitoring {
+  namespace "urn:ietf:params:xml:ns:yang:ietf-restconf-monitoring";
+  prefix "rcmon";
+
+  import ietf-yang-types { prefix yang; }
+  import ietf-inet-types { prefix inet; }
+
+  organization
+    "IETF NETCONF (Network Configuration) Working Group";
+
+  contact
+    "WG Web:   <http://tools.ietf.org/wg/netconf/>
+     WG List:  <mailto:netconf@ietf.org>
+     Author:   Andy Bierman
+               <mailto:andy@yumaworks.com>
+     Author:   Martin Bjorklund
+               <mailto:mbj@tail-f.com>
+     Author:   Kent Watsen
+               <mailto:kwatsen@juniper.net>";
+
+  description
+    "This module contains monitoring information for the
+     RESTCONF protocol.
+     Copyright (c) 2016 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
+     (http://trustee.ietf.org/license-info).
+     This version of this YANG module is part of RFC XXXX; see
+     the RFC itself for full legal notices.";
+
+  // RFC Ed.: replace XXXX with actual RFC number and remove this
+  // note.
+
+  // RFC Ed.: remove this note
+  // Note: extracted from draft-ietf-netconf-restconf-17.txt
+
+  // RFC Ed.: update the date below with the date of RFC publication
+  // and remove this note.
+  revision 2016-08-15 {
+    description
+      "Initial revision.";
+    reference
+      "RFC XXXX: RESTCONF Protocol.";
+  }
+
+  container restconf-state {
+    config false;
+    description
+      "Contains RESTCONF protocol monitoring information.";
+
+    container capabilities {
+      description
+        "Contains a list of protocol capability URIs";
+
+      leaf-list capability {
+        type inet:uri;
+        description "A RESTCONF protocol capability URI.";
+      }
+    }
+
+    container streams {
+      description
+        "Container representing the notification event streams
+         supported by the server.";
+       reference
+         "RFC 5277, Section 3.4, <streams> element.";
+
+      list stream {
+        key name;
+        description
+          "Each entry describes an event stream supported by
+           the server.";
+
+        leaf name {
+          type string;
+          description "The stream name";
+          reference "RFC 5277, Section 3.4, <name> element.";
+        }
+
+        leaf description {
+          type string;
+          description "Description of stream content";
+          reference
+            "RFC 5277, Section 3.4, <description> element.";
+        }
+
+        leaf replay-support {
+          type boolean;
+          default false;
+          description
+            "Indicates if replay buffer supported for this stream.
+             If 'true', then the server MUST support the 'start-time'
+             and 'stop-time' query parameters for this stream.";
+          reference
+            "RFC 5277, Section 3.4, <replaySupport> element.";
+        }
+
+        leaf replay-log-creation-time {
+          when "../replay-support" {
+            description
+              "Only present if notification replay is supported";
+          }
+          type yang:date-and-time;
+          description
+            "Indicates the time the replay log for this stream
+             was created.";
+          reference
+            "RFC 5277, Section 3.4, <replayLogCreationTime>
+             element.";
+        }
+
+        list access {
+          key encoding;
+          min-elements 1;
+          description
+            "The server will create an entry in this list for each
+             encoding format that is supported for this stream.
+             The media type 'text/event-stream' is expected
+             for all event streams. This list identifies the
+             sub-types supported for this stream.";
+
+          leaf encoding {
+            type string;
+            description
+              "This is the secondary encoding format within the
+               'text/event-stream' encoding used by all streams.
+               The type 'xml' is supported for XML encoding.
+               The type 'json' is supported for JSON encoding.";
+          }
+
+          leaf location {
+            type inet:uri;
+            mandatory true;
+            description
+              "Contains a URL that represents the entry point
+               for establishing notification delivery via server
+               sent events.";
+          }
+        }
+      }
+    }
+  }
+
+}