Use mounted device schema context when resolving mounted device rpc path 61/37961/1
authorAndrej Mak <andmak@cisco.com>
Thu, 21 Apr 2016 09:28:07 +0000 (11:28 +0200)
committerAndrej Mak <andmak@cisco.com>
Thu, 21 Apr 2016 10:52:00 +0000 (12:52 +0200)
It wasn't possible to invoke rpcs on device, which were not present
also in controller schema context, so only rpcs like get-schema and
create-subscription worked. Now, device schema context is used to
lookup rpc definition during parsing path, so rpcs defined by device works.

Change-Id: I1046bad566260c804ce0f786c56c74afe3d7f723
Signed-off-by: Andrej Mak <andmak@cisco.com>
opendaylight/restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/ControllerContext.java

index f21823cda081bc2d5db4d59247092092687430f8..e4f71a7ff03e00a07df93422f9bd8b0eb7826cc2 100644 (file)
@@ -596,7 +596,13 @@ public class ControllerContext implements SchemaContextListener {
             targetNode = findInstanceDataChildByNameAndNamespace(parentNode, nodeName, module.getNamespace());
 
             if (targetNode == null && parentNode instanceof Module) {
-                final RpcDefinition rpc = ControllerContext.getInstance().getRpcDefinition(head, module.getRevision());
+                final RpcDefinition rpc;
+                if (mountPoint == null) {
+                    rpc = ControllerContext.getInstance().getRpcDefinition(head, module.getRevision());
+                } else {
+                    final String rpcName = toNodeName(head);
+                    rpc = ControllerContext.getInstance().getRpcDefinition(module, rpcName);
+                }
                 if (rpc != null) {
                     return new InstanceIdentifierContext<RpcDefinition>(builder.build(), rpc, mountPoint,
                             mountPoint != null ? mountPoint.getSchemaContext() : globalSchema);
@@ -829,6 +835,16 @@ public class ControllerContext implements SchemaContextListener {
         return validName == null ? null : qnameToRpc.get().get(validName);
     }
 
+    private RpcDefinition getRpcDefinition(final Module module, final String rpcName) {
+        QName rpcQName = QName.create(module.getQNameModule(), rpcName);
+        for (RpcDefinition rpcDefinition : module.getRpcs()) {
+            if (rpcQName.equals(rpcDefinition.getQName())) {
+                return rpcDefinition;
+            }
+        }
+        return null;
+    }
+
     @Override
     public void onGlobalContextUpdated(final SchemaContext context) {
         if (context != null) {