use of org.onosproject.net.behaviour.ControlProtocolVersion in project onos by opennetworkinglab.
the class DefaultOvsdbClient method createBridge.
@Override
public boolean createBridge(OvsdbBridge ovsdbBridge) {
DatabaseSchema dbSchema = schema.get(DATABASENAME);
String ovsUuid = getOvsUuid(DATABASENAME);
if (dbSchema == null || ovsUuid == null) {
log.error("Can't find database Open_vSwitch");
return false;
}
Bridge bridge = (Bridge) TableGenerator.createTable(dbSchema, OvsdbTable.BRIDGE);
bridge.setOtherConfig(ovsdbBridge.otherConfigs());
if (ovsdbBridge.failMode().isPresent()) {
String failMode = ovsdbBridge.failMode().get().name().toLowerCase();
bridge.setFailMode(Sets.newHashSet(failMode));
}
if (ovsdbBridge.datapathType().isPresent()) {
String datapathType = ovsdbBridge.datapathType().get();
bridge.setDatapathType(datapathType);
}
if (ovsdbBridge.controlProtocols().isPresent()) {
bridge.setProtocols(ovsdbBridge.controlProtocols().get().stream().map(ControlProtocolVersion::toString).collect(Collectors.toCollection(HashSet::new)));
}
if (ovsdbBridge.mcastSnoopingEnable().isPresent()) {
boolean mcastSnoopingFlag = ovsdbBridge.mcastSnoopingEnable().get();
bridge.setMcastSnoopingEnable(mcastSnoopingFlag);
}
String bridgeUuid = getBridgeUuid(ovsdbBridge.name());
if (bridgeUuid == null) {
bridge.setName(ovsdbBridge.name());
bridgeUuid = insertConfig(BRIDGE, UUID, DATABASENAME, BRIDGES, ovsUuid, bridge.getRow());
} else {
// update the bridge if it's already existing
updateConfig(BRIDGE, UUID, bridgeUuid, bridge.getRow());
}
if (bridgeUuid == null) {
log.warn("Failed to create bridge {} on {}", ovsdbBridge.name(), nodeId);
return false;
}
createPort(ovsdbBridge.name(), ovsdbBridge.name());
setControllersWithUuid(Uuid.uuid(bridgeUuid), ovsdbBridge.controllers());
log.info("Created bridge {}", ovsdbBridge.name());
return true;
}
Aggregations