Bug-8053 OVS Bridge other_config:hwaddr not preserved for nodes not in config DS 56/53856/4
authorJosh <jhershbe@redhat.com>
Sun, 26 Mar 2017 09:11:30 +0000 (12:11 +0300)
committerSam Hague <shague@redhat.com>
Sun, 9 Apr 2017 18:51:28 +0000 (18:51 +0000)
SouthboundUtils.addBridge - add version that takes other configs

Change-Id: Id451a850db7e99aef013decc4466e67feb1370b7
Signed-off-by: Josh <jhershbe@redhat.com>
utils/southbound-utils/src/main/java/org/opendaylight/ovsdb/utils/southbound/utils/SouthboundUtils.java

index a481467ca82ad9ac8f6269c85ea0046a5af110e8..fd8fd7a58f1041483d4c139d2319df048f23febf 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2015, 2017 Red Hat, Inc. and others.  All rights reserved.
+ * Copyright (c) 2015 - 2017 Red Hat, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -651,6 +651,21 @@ public class SouthboundUtils {
     public boolean addBridge(Node ovsdbNode, String bridgeName, List<String> controllersStr,
                              final Class<? extends DatapathTypeBase> dpType, String mac,
                              Long maxBackoff, Long inactivityProbe) {
+        List<BridgeOtherConfigs> otherConfigs = new ArrayList<>();
+        if (mac != null) {
+            BridgeOtherConfigsBuilder macOtherConfigBuilder = new BridgeOtherConfigsBuilder();
+            macOtherConfigBuilder.setBridgeOtherConfigKey("hwaddr");
+            macOtherConfigBuilder.setBridgeOtherConfigValue(mac);
+            otherConfigs.add(macOtherConfigBuilder.build());
+        }
+
+        return addBridge(ovsdbNode, bridgeName, controllersStr, dpType, otherConfigs, null, null);
+    }
+
+    public boolean addBridge(Node ovsdbNode, String bridgeName, List<String> controllersStr,
+                             final Class<? extends DatapathTypeBase> dpType,
+                             List<BridgeOtherConfigs> otherConfigs,
+                             Long maxBackoff, Long inactivityProbe) {
         boolean result;
 
         LOG.info("addBridge: node: {}, bridgeName: {}, controller(s): {}", ovsdbNode, bridgeName, controllersStr);
@@ -666,18 +681,17 @@ public class SouthboundUtils {
             ovsdbBridgeAugmentationBuilder.setBridgeName(new OvsdbBridgeName(bridgeName));
             ovsdbBridgeAugmentationBuilder.setProtocolEntry(createMdsalProtocols());
             ovsdbBridgeAugmentationBuilder.setFailMode( OVSDB_FAIL_MODE_MAP.inverse().get("secure"));
+            // TODO: Currently netvirt relies on this function to set disabled-in-band=true. However,
+            // TODO (cont): a better design would be to have netvirt pass that in. That way this function
+            // TODO (cont): can take a null otherConfigs to erase other_configs.
+            if (otherConfigs == null) {
+                otherConfigs = new ArrayList<>();
+            }
             BridgeOtherConfigsBuilder bridgeOtherConfigsBuilder = new BridgeOtherConfigsBuilder();
             bridgeOtherConfigsBuilder.setBridgeOtherConfigKey(DISABLE_IN_BAND);
             bridgeOtherConfigsBuilder.setBridgeOtherConfigValue("true");
-            List<BridgeOtherConfigs> bridgeOtherConfigsList = new ArrayList<>();
-            bridgeOtherConfigsList.add(bridgeOtherConfigsBuilder.build());
-            if (mac != null) {
-                BridgeOtherConfigsBuilder macOtherConfigBuilder = new BridgeOtherConfigsBuilder();
-                macOtherConfigBuilder.setBridgeOtherConfigKey("hwaddr");
-                macOtherConfigBuilder.setBridgeOtherConfigValue(mac);
-                bridgeOtherConfigsList.add(macOtherConfigBuilder.build());
-            }
-            ovsdbBridgeAugmentationBuilder.setBridgeOtherConfigs(bridgeOtherConfigsList);
+            otherConfigs.add(bridgeOtherConfigsBuilder.build());
+            ovsdbBridgeAugmentationBuilder.setBridgeOtherConfigs(otherConfigs);
             setManagedByForBridge(ovsdbBridgeAugmentationBuilder, ovsdbNode.getKey());
             if (dpType != null) {
                 ovsdbBridgeAugmentationBuilder.setDatapathType(dpType);