Updating fix for bug 3989 based on discussion in OVSDB meeting 18/26118/3
authorRaksha Madhava Bangera <raksha.madhava.bangera@intel.com>
Thu, 27 Aug 2015 20:40:11 +0000 (13:40 -0700)
committerRaksha Madhava Bangera <raksha.madhava.bangera@intel.com>
Tue, 8 Sep 2015 20:33:04 +0000 (13:33 -0700)
Signed-off-by: Raksha Madhava Bangera <raksha.madhava.bangera@intel.com>
Updating the patch as per review comments

Signed-off-by: Raksha Madhava Bangera <raksha.madhava.bangera@intel.com>
Removing whitespace

Signed-off-by: Raksha Madhava Bangera <raksha.madhava.bangera@intel.com>
southbound/southbound-api/src/main/yang/ovsdb.yang
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbDataChangeListener.java

index 18b2452267776bd3473b58a0cea6ee05d3082583..6d9edb5aa116df823810c96eaf6a755d91cb41bb 100755 (executable)
@@ -343,7 +343,10 @@ module ovsdb {
     }
 
     grouping ovsdb-node-attributes {
-        description "";
+        description "Plugin will not allow multiple connections to the same device.
+        If an application attempts to make more than one connection to the device by
+        putting multiple entries in the config data store, then it is the responsibility
+        of the application to clean the config data store";
         container connection-info{
             uses ovsdb-connection-info-attributes;
         }
index 72d85d21b10a649ff1aa89644b1502ca2a5a122f..434ef04aa42af97f87eb0ce48f634cc59fb355da 100644 (file)
@@ -26,6 +26,7 @@ import org.opendaylight.ovsdb.southbound.ovsdb.transact.DataChangesManagedByOvsd
 import org.opendaylight.ovsdb.southbound.ovsdb.transact.TransactCommandAggregator;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfo;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
@@ -70,6 +71,19 @@ public class OvsdbDataChangeListener implements DataChangeListener, AutoCloseabl
     public void onDataChanged(
             AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes) {
         LOG.trace("onDataChanged: {}", changes);
+        for (Entry<InstanceIdentifier<?>, DataObject> created : changes.getCreatedData().entrySet()) {
+            // TODO validate we have the correct kind of InstanceIdentifier
+            if (created.getValue() instanceof OvsdbNodeAugmentation) {
+                OvsdbNodeAugmentation ovsdbNode = (OvsdbNodeAugmentation)created.getValue();
+                ConnectionInfo key = ovsdbNode.getConnectionInfo();
+                InstanceIdentifier<Node> iid = cm.getInstanceIdentifier(key);
+                if ( iid != null) {
+                    LOG.warn("Connection to device {} already exists. Plugin does not allow multiple connections "
+                              + "to same device, hence dropping the request {}", key, ovsdbNode);
+                    return;
+                }
+            }
+        }
         // Connect first if we have to:
         connect(changes);