Fixed create bridge
Fixed to update bridge attributes instead of do nothing when the
bridge is already exist.
Change-Id: I30e398fde8ea6af98f034e133a5832e6a51cf697
diff --git a/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/DefaultOvsdbClient.java b/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/DefaultOvsdbClient.java
index 8a661ab..5f72606 100644
--- a/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/DefaultOvsdbClient.java
+++ b/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/DefaultOvsdbClient.java
@@ -578,16 +578,7 @@
return false;
}
- String bridgeUuid = getBridgeUuid(bridgeName);
- if (bridgeUuid != null) {
- log.warn("Bridge {} is already exist", bridgeName);
- // remove existing one and re-create?
- return false;
- }
-
Bridge bridge = (Bridge) TableGenerator.createTable(dbSchema, OvsdbTable.BRIDGE);
- bridge.setName(bridgeName);
-
Set<String> failMode = new HashSet<>(Arrays.asList("secure"));
bridge.setFailMode(failMode);
@@ -598,9 +589,15 @@
options.put("datapath-id", dpid);
bridge.setOtherConfig(options);
- bridgeUuid = insertConfig(OvsdbConstant.BRIDGE, "_uuid",
- OvsdbConstant.DATABASENAME, "bridges",
- ovsUuid, bridge.getRow());
+ String bridgeUuid = getBridgeUuid(bridgeName);
+ if (bridgeUuid == null) {
+ bridge.setName(bridgeName);
+ bridgeUuid = insertConfig(OvsdbConstant.BRIDGE, "_uuid",
+ OvsdbConstant.DATABASENAME, "bridges",
+ ovsUuid, bridge.getRow());
+ } else {
+ updateConfig(OvsdbConstant.BRIDGE, "_uuid", bridgeUuid, bridge.getRow());
+ }
if (bridgeUuid != null) {
createPort(bridgeName, bridgeName);