Hyunsun Moon
Committed by Gerrit Code Review

Fixed create bridge

Fixed to update bridge attributes instead of do nothing when the
bridge is already exist.

Change-Id: I30e398fde8ea6af98f034e133a5832e6a51cf697
...@@ -578,16 +578,7 @@ public class DefaultOvsdbClient ...@@ -578,16 +578,7 @@ public class DefaultOvsdbClient
578 return false; 578 return false;
579 } 579 }
580 580
581 - String bridgeUuid = getBridgeUuid(bridgeName);
582 - if (bridgeUuid != null) {
583 - log.warn("Bridge {} is already exist", bridgeName);
584 - // remove existing one and re-create?
585 - return false;
586 - }
587 -
588 Bridge bridge = (Bridge) TableGenerator.createTable(dbSchema, OvsdbTable.BRIDGE); 581 Bridge bridge = (Bridge) TableGenerator.createTable(dbSchema, OvsdbTable.BRIDGE);
589 - bridge.setName(bridgeName);
590 -
591 Set<String> failMode = new HashSet<>(Arrays.asList("secure")); 582 Set<String> failMode = new HashSet<>(Arrays.asList("secure"));
592 bridge.setFailMode(failMode); 583 bridge.setFailMode(failMode);
593 584
...@@ -598,9 +589,15 @@ public class DefaultOvsdbClient ...@@ -598,9 +589,15 @@ public class DefaultOvsdbClient
598 options.put("datapath-id", dpid); 589 options.put("datapath-id", dpid);
599 bridge.setOtherConfig(options); 590 bridge.setOtherConfig(options);
600 591
601 - bridgeUuid = insertConfig(OvsdbConstant.BRIDGE, "_uuid", 592 + String bridgeUuid = getBridgeUuid(bridgeName);
602 - OvsdbConstant.DATABASENAME, "bridges", 593 + if (bridgeUuid == null) {
603 - ovsUuid, bridge.getRow()); 594 + bridge.setName(bridgeName);
595 + bridgeUuid = insertConfig(OvsdbConstant.BRIDGE, "_uuid",
596 + OvsdbConstant.DATABASENAME, "bridges",
597 + ovsUuid, bridge.getRow());
598 + } else {
599 + updateConfig(OvsdbConstant.BRIDGE, "_uuid", bridgeUuid, bridge.getRow());
600 + }
604 601
605 if (bridgeUuid != null) { 602 if (bridgeUuid != null) {
606 createPort(bridgeName, bridgeName); 603 createPort(bridgeName, bridgeName);
......