Merge "Bug fixes for netconf southbound plugin."
authorTony Tkacik <ttkacik@cisco.com>
Sat, 15 Feb 2014 03:25:14 +0000 (03:25 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Sat, 15 Feb 2014 03:25:14 +0000 (03:25 +0000)
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationBrokerImpl.xtend
opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfDeviceTwoPhaseCommitTransaction.java
opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfMapping.xtend

index a7dcf80..9a431fe 100644 (file)
@@ -23,10 +23,11 @@ import org.opendaylight.yangtools.yang.binding.Notification
 import org.slf4j.LoggerFactory\r
 import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder\rimport com.google.common.collect.Multimaps\r
 import org.opendaylight.yangtools.concepts.util.ListenerRegistry\r
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService.NotificationInterestListener\rimport java.util.Set
-import com.google.common.collect.ImmutableSet
-import java.util.concurrent.Future
-
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService.NotificationInterestListener\rimport java.util.Set\r
+import java.util.Set\r
+import com.google.common.collect.ImmutableSet\r
+import java.util.concurrent.Future\r
+\r
 class NotificationBrokerImpl implements NotificationProviderService, AutoCloseable {\r
     \r
     val ListenerRegistry<NotificationInterestListener> interestListeners = ListenerRegistry.create;\r
@@ -105,14 +106,14 @@ class NotificationBrokerImpl implements NotificationProviderService, AutoCloseab
         submitAll(executor,tasks);\r
     }\r
     \r
-    def submitAll(ExecutorService service, Set<NotifyTask> tasks) {
+    def submitAll(ExecutorService service, Set<NotifyTask> tasks) {\r
         val ret = ImmutableSet.<Future<Object>>builder();\r
         for(task : tasks) {\r
             ret.add(service.submit(task));\r
         }\r
-        return ret.build();
+        return ret.build();\r
     }\r
-\r
+    \r
     override <T extends Notification> registerNotificationListener(Class<T> notificationType,\r
         NotificationListener<T> listener) {\r
         val reg = new GenericNotificationRegistration<T>(notificationType, listener, this);\r
index c16ee17..83700c8 100644 (file)
@@ -7,7 +7,7 @@
  */
 package org.opendaylight.controller.sal.connect.netconf;
 
-import static org.opendaylight.controller.sal.connect.netconf.NetconfMapping.NETCONF_ACTION_QNAME;
+import static org.opendaylight.controller.sal.connect.netconf.NetconfMapping.NETCONF_OPERATION_QNAME;
 import static org.opendaylight.controller.sal.connect.netconf.NetconfMapping.NETCONF_CANDIDATE_QNAME;
 import static org.opendaylight.controller.sal.connect.netconf.NetconfMapping.NETCONF_COMMIT_QNAME;
 import static org.opendaylight.controller.sal.connect.netconf.NetconfMapping.NETCONF_CONFIG_QNAME;
@@ -52,7 +52,7 @@ public class NetconfDeviceTwoPhaseCommitTransaction implements DataCommitTransac
 
     public void prepare() {
         for (InstanceIdentifier toRemove : modification.getRemovedConfigurationData()) {
-            sendRemove(toRemove);
+            sendDelete(toRemove);
         }
         for(Entry<InstanceIdentifier, CompositeNode> toUpdate : modification.getUpdatedConfigurationData().entrySet()) {
             sendMerge(toUpdate.getKey(),toUpdate.getValue());
@@ -64,8 +64,8 @@ public class NetconfDeviceTwoPhaseCommitTransaction implements DataCommitTransac
         sendEditRpc(createEditStructure(key, Optional.<String>absent(), Optional.of(value)));
     }
 
-    private void sendRemove(InstanceIdentifier toRemove) {
-        sendEditRpc(createEditStructure(toRemove, Optional.of("remove"), Optional.<CompositeNode> absent()));
+    private void sendDelete(InstanceIdentifier toDelete) {
+        sendEditRpc(createEditStructure(toDelete, Optional.of("delete"), Optional.<CompositeNode> absent()));
     }
 
     private void sendEditRpc(CompositeNode editStructure) {
@@ -92,7 +92,7 @@ public class NetconfDeviceTwoPhaseCommitTransaction implements DataCommitTransac
         return ret;
     }
 
-    private CompositeNode createEditStructure(InstanceIdentifier dataPath, Optional<String> action,
+    private CompositeNode createEditStructure(InstanceIdentifier dataPath, Optional<String> operation,
             Optional<CompositeNode> lastChildOverride) {
         List<PathArgument> path = dataPath.getPath();
         List<PathArgument> reversed = Lists.reverse(path);
@@ -110,8 +110,8 @@ public class NetconfDeviceTwoPhaseCommitTransaction implements DataCommitTransac
             }
 
             if (isLast) {
-                if (action.isPresent()) {
-                    builder.setAttribute(NETCONF_ACTION_QNAME, action.get());
+                if (operation.isPresent()) {
+                    builder.setAttribute(NETCONF_OPERATION_QNAME, operation.get());
                 }
                 if (lastChildOverride.isPresent()) {
                     List<Node<?>> children = lastChildOverride.get().getChildren();
index 53ed49c..f409ecd 100644 (file)
@@ -16,24 +16,30 @@ import java.util.Collections
 import java.util.List
 import java.util.Set
 import java.util.concurrent.atomic.AtomicInteger
-import org.opendaylight.controller.netconf.api.NetconfMessage
 import org.opendaylight.controller.sal.common.util.Rpcs
-import org.opendaylight.yangtools.yang.common.QName
-import org.opendaylight.yangtools.yang.common.RpcResult
 import org.opendaylight.yangtools.yang.data.api.CompositeNode
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument
-import org.opendaylight.yangtools.yang.data.api.Node
 import org.opendaylight.yangtools.yang.data.impl.CompositeNodeTOImpl
 import org.opendaylight.yangtools.yang.data.impl.ImmutableCompositeNode
-import org.opendaylight.yangtools.yang.data.impl.NodeUtils
-import org.opendaylight.yangtools.yang.data.impl.SimpleNodeTOImpl
+import java.util.Collections
+import java.util.List
+import java.util.Set
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument
+import org.opendaylight.yangtools.yang.data.api.Node
+import org.opendaylight.yangtools.yang.data.impl.CompositeNodeTOImpl
 import org.opendaylight.yangtools.yang.data.impl.codec.xml.XmlDocumentUtils
 import org.opendaylight.yangtools.yang.model.api.NotificationDefinition
 import org.opendaylight.yangtools.yang.model.api.SchemaContext
 import org.w3c.dom.Document
 import org.w3c.dom.Element
+import org.opendaylight.yangtools.yang.common.QName
+import org.opendaylight.yangtools.yang.data.impl.SimpleNodeTOImpl
+import org.opendaylight.controller.netconf.api.NetconfMessage
+import org.opendaylight.yangtools.yang.common.RpcResult
 
 class NetconfMapping {
 
@@ -50,7 +56,7 @@ class NetconfMapping {
     public static val NETCONF_GET_CONFIG_QNAME = QName.create(NETCONF_QNAME, "get-config");
     public static val NETCONF_EDIT_CONFIG_QNAME = QName.create(NETCONF_QNAME, "edit-config");
     public static val NETCONF_DELETE_CONFIG_QNAME = QName.create(NETCONF_QNAME, "delete-config");
-    public static val NETCONF_ACTION_QNAME = QName.create(NETCONF_QNAME, "action");
+    public static val NETCONF_OPERATION_QNAME = QName.create(NETCONF_QNAME, "operation");
     public static val NETCONF_COMMIT_QNAME = QName.create(NETCONF_QNAME, "commit");
     
     public static val NETCONF_CONFIG_QNAME = QName.create(NETCONF_QNAME, "config");
@@ -92,6 +98,9 @@ class NetconfMapping {
         for (arg : argument.keyValues.entrySet) {
             list.add = new SimpleNodeTOImpl(arg.key, null, arg.value);
         }
+        if (node != null) {
+            list.add(node);
+        }
         return new CompositeNodeTOImpl(argument.nodeType, null, list)
     }
 
@@ -120,9 +129,9 @@ class NetconfMapping {
     }
 
     static def NetconfMessage toRpcMessage(QName rpc, CompositeNode node,Optional<SchemaContext> ctx) {
-        val rpcPayload = wrap(NETCONF_RPC_QNAME, flattenInput(node));
-        val w3cPayload = NodeUtils.buildShadowDomTree(rpcPayload);
-        w3cPayload.documentElement.setAttribute("message-id", "m-" + messageId.andIncrement);
+        val rpcPayload = wrap(NETCONF_RPC_QNAME, flattenInput(node))
+        val w3cPayload = XmlDocumentUtils.toDocument(rpcPayload, XmlDocumentUtils.defaultValueCodecProvider)
+        w3cPayload.documentElement.setAttribute("message-id", "m-" + messageId.andIncrement)
         return new NetconfMessage(w3cPayload);
     }
     

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.