Search in sources :

Example 1 with ControlProtocolVersion

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;
}
Also used : ControlProtocolVersion(org.onosproject.net.behaviour.ControlProtocolVersion) Bridge(org.onosproject.ovsdb.rfc.table.Bridge) OvsdbBridge(org.onosproject.ovsdb.controller.OvsdbBridge) DatabaseSchema(org.onosproject.ovsdb.rfc.schema.DatabaseSchema) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)1 ControlProtocolVersion (org.onosproject.net.behaviour.ControlProtocolVersion)1 OvsdbBridge (org.onosproject.ovsdb.controller.OvsdbBridge)1 DatabaseSchema (org.onosproject.ovsdb.rfc.schema.DatabaseSchema)1 Bridge (org.onosproject.ovsdb.rfc.table.Bridge)1