L3: Add eth to br-ex
authorBadrinath <badrinath_viswanatha@dell.com>
Fri, 25 Sep 2015 11:14:56 +0000 (04:14 -0700)
committerAndre Fredette <afredette@redhat.com>
Mon, 19 Oct 2015 21:03:05 +0000 (17:03 -0400)
cherry-pick to master.

Change-Id: I89d917bb51d7f54d585d71076319eedd752b42d0
Signed-off-by: Badrinath <badrinath_viswanatha@dell.com>
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/api/BridgeConfigurationManager.java
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/BridgeConfigurationManagerImpl.java

index d58075cad0b467c11026db1a72dc67673212c52f..0d1b52cf75fa30772805efe3a6a7632dd1eda0aa 100644 (file)
@@ -117,4 +117,14 @@ public interface BridgeConfigurationManager {
      * @return a List in the format {eth1, eth2} given bridge_mappings=physnet1:eth1,physnet2:eth2
      */
     List<String> getAllPhysicalInterfaceNames(Node node);
+
+   /*
+     * Return br-ex interface configured in the bridge_mappings.
+     * Return null if br-ex is not configured in bridge_mappings.
+     * @param node the {@link Node} to query
+     * @param externalNetwork
+     * @return the interface as a string like eth3 given bridge_mappings=br-ex:eth3
+   */
+     String getExternalInterfaceName (Node node, String externalNetwork);
+
 }
index e58021f93b29a8e2f59c1b23b602a0a44cac67af..3ea4608014c0466a82ca6467caf80e3abc31611b 100644 (file)
@@ -200,6 +200,34 @@ public class BridgeConfigurationManagerImpl implements BridgeConfigurationManage
         return isCreated;
     }
 
+
+
+    @Override
+    public String getExternalInterfaceName (Node node, String extNetwork) {
+        String phyIf = null;
+        String providerMaps = southbound.getOtherConfig(node, OvsdbTables.OPENVSWITCH,
+                configurationService.getProviderMappingsKey());
+        if (providerMaps != null) {
+            for (String map : providerMaps.split(",")) {
+                String[] pair = map.split(":");
+                if (pair[0].equals(extNetwork)) {
+                    phyIf = pair[1];
+                    break;
+                }
+            }
+        }
+        if (phyIf == null) {
+            LOG.error("External interface not found for Node: {}, Network {}",
+                    node, extNetwork);
+        }
+        else {
+            LOG.info("External interface found for Node: {}, Network {} is {}",node,extNetwork,phyIf);
+        }
+        return phyIf;
+    }
+
+
+
     @Override
     public String getPhysicalInterfaceName (Node node, String physicalNetwork) {
         String phyIf = null;
@@ -378,8 +406,15 @@ public class BridgeConfigurationManagerImpl implements BridgeConfigurationManage
                 LOG.error("Add Port {} to Bridge {} failed", portNameExt, brExt);
                 return false;
             }
+            String extNetName = getExternalInterfaceName(extBridgeNode, brExt);
+            if ( extNetName != null) {
+                if (!addPortToBridge(extBridgeNode, brExt, extNetName)) {
+                    LOG.error("Add External Port {} to Bridge {} failed", extNetName, brExt);
+                    return false;
+                }
+            LOG.info("Add External Port {} to Ext Bridge {} success", extNetName, brExt);
+            }
         }
-
         /* For vlan network types add physical port to br-int. */
         if (network.getProviderNetworkType().equalsIgnoreCase(NetworkHandler.NETWORK_TYPE_VLAN)) {
             String phyNetName = this.getPhysicalInterfaceName(bridgeNode, network.getProviderPhysicalNetwork());
@@ -389,7 +424,7 @@ public class BridgeConfigurationManagerImpl implements BridgeConfigurationManage
             }
         }
 
-        LOG.debug("createBridges: node: {}, status: success", bridgeNode);
+        LOG.info("createBridges: node: {}, status: success", bridgeNode);
         return true;
     }