Fix for defect 4135 00/26000/1
authorSharad Mishra <sharad.d.mishra@intel.com>
Wed, 12 Aug 2015 17:53:14 +0000 (13:53 -0400)
committerSharad Mishra <sharad.d.mishra@intel.com>
Tue, 25 Aug 2015 22:04:07 +0000 (15:04 -0700)
https://bugs.opendaylight.org/show_bug.cgi?id=4135

If integration bridge or external bridge exist prior to
connecting to ODL, then the pre-existing bridge is not added.
But the side effect is that the controller is not set on
this bridge.
Current code checks to see if the bridge already exists on the node. This
patch adds a check to see if the bridge exists on CONFIG datastore. If the
bridge does not exist on config, it indicates that the bridge existed prior
to ODL connection, and it adds the bridge.

Signed-off-by: Sharad Mishra <sharad.d.mishra@intel.com>
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/api/Southbound.java
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/BridgeConfigurationManagerImpl.java
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/SouthboundImpl.java

index b0a59fd40d2cf47e7d7787a28b021156aa19c6b2..7a8f6e6a593255e785777a743b0ea77d6993c657 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.ovsdb.openstack.netvirt.api;
 
 import java.util.List;
 import java.util.Map;
+
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 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;
@@ -76,4 +77,5 @@ public interface Southbound {
     Long getOFPort(OvsdbTerminationPointAugmentation port);
     Long getOFPort(Node bridgeNode, String portName);
     DataBroker getDatabroker();
+    OvsdbBridgeAugmentation getBridgeFromConfig(Node ovsdbNode, String bridgeName);
 }
index 81e8b21e3c3ec0b1dfecab3f0bb5969cc32abbc8..a9e84bad2dc9f657b07c9c55433393d50818aa49 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.ovsdb.openstack.netvirt.impl;
 
 import org.opendaylight.neutron.spi.NeutronNetwork;
 import org.opendaylight.ovsdb.openstack.netvirt.ConfigInterface;
+import org.opendaylight.ovsdb.openstack.netvirt.MdsalHelper;
 import org.opendaylight.ovsdb.openstack.netvirt.NetworkHandler;
 import org.opendaylight.ovsdb.openstack.netvirt.api.BridgeConfigurationManager;
 import org.opendaylight.ovsdb.openstack.netvirt.api.ConfigurationService;
@@ -457,7 +458,8 @@ public class BridgeConfigurationManagerImpl implements BridgeConfigurationManage
      */
     private boolean addBridge(Node ovsdbNode, String bridgeName) throws Exception {
         boolean rv = true;
-        if (!southbound.isBridgeOnOvsdbNode(ovsdbNode, bridgeName)) {
+        if ((!southbound.isBridgeOnOvsdbNode(ovsdbNode, bridgeName)) ||
+                (southbound.getBridgeFromConfig(ovsdbNode, bridgeName) == null)) {
             rv = southbound.addBridge(ovsdbNode, bridgeName, getControllerTarget(ovsdbNode));
         }
         return rv;
index 0f68198c7338433bf5c17dab3498ebf4ce77c4e5..22934ea40965811109523cd7fe0f8dcfc4b02e6e 100644 (file)
@@ -721,4 +721,14 @@ public class SouthboundImpl implements Southbound {
         }
         return ofPort;
     }
+    public OvsdbBridgeAugmentation getBridgeFromConfig(Node node, String bridge) {
+        OvsdbBridgeAugmentation ovsdbBridgeAugmentation = null;
+        InstanceIdentifier<Node> bridgeIid =
+                MdsalHelper.createInstanceIdentifier(node.getKey(), bridge);
+        Node bridgeNode = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, bridgeIid);
+        if (bridgeNode != null) {
+            ovsdbBridgeAugmentation = bridgeNode.getAugmentation(OvsdbBridgeAugmentation.class);
+        }
+        return ovsdbBridgeAugmentation;
+    }
 }