Search in sources :

Example 1 with Bridge

use of org.onosproject.ovsdb.rfc.table.Bridge in project onos by opennetworkinglab.

the class DefaultOvsdbClient method setControllersWithUuid.

private void setControllersWithUuid(Uuid bridgeUuid, List<ControllerInfo> controllers) {
    DatabaseSchema dbSchema = schema.get(DATABASENAME);
    if (dbSchema == null) {
        log.debug("There is no schema");
        return;
    }
    List<Controller> oldControllers = getControllers(bridgeUuid);
    if (oldControllers == null) {
        log.warn("There are no controllers");
        return;
    }
    Set<ControllerInfo> newControllers = new HashSet<>(controllers);
    List<Controller> removeControllers = new ArrayList<>();
    oldControllers.forEach(controller -> {
        ControllerInfo controllerInfo = new ControllerInfo((String) controller.getTargetColumn().data());
        if (newControllers.contains(controllerInfo)) {
            newControllers.remove(controllerInfo);
        } else {
            removeControllers.add(controller);
        }
    });
    OvsdbRowStore controllerRowStore = getRowStore(DATABASENAME, CONTROLLER);
    if (controllerRowStore == null) {
        log.debug("There is no controller table");
        return;
    }
    newControllers.stream().map(c -> {
        Controller controller = (Controller) TableGenerator.createTable(dbSchema, OvsdbTable.CONTROLLER);
        controller.setTarget(c.target());
        return controller;
    }).forEach(c -> insertConfig(CONTROLLER, UUID, BRIDGE, BRIDGE_CONTROLLER, bridgeUuid.value(), c.getRow()));
    // Controller removal is extremely dangerous operation, because with
    // empty controller list, all existing flow rules will be wiped out.
    // To harden the setController operation, we need to double check whether
    // the updated controller list size is bigger than the remove controller list size
    List<Controller> updatedControllers = getControllers(bridgeUuid);
    if (updatedControllers != null && updatedControllers.size() > removeControllers.size()) {
        removeControllers.forEach(c -> deleteConfig(CONTROLLER, UUID, c.getRow().uuid().value(), BRIDGE, BRIDGE_CONTROLLER, c.getRow().uuid()));
    } else {
        log.warn("New controllers were not properly configured to OVS " + "bridge {} or failed to retrieve controller list from OVS " + "bridge {}", bridgeUuid, bridgeUuid);
    }
}
Also used : QUEUE_EXTERNAL_ID_KEY(org.onosproject.ovsdb.controller.OvsdbConstant.QUEUE_EXTERNAL_ID_KEY) Controller(org.onosproject.ovsdb.rfc.table.Controller) ColumnSchemaNotFoundException(org.onosproject.ovsdb.rfc.exception.ColumnSchemaNotFoundException) OFPORT(org.onosproject.ovsdb.controller.OvsdbConstant.OFPORT) PortNumber(org.onosproject.net.PortNumber) QueueId(org.onosproject.net.behaviour.QueueId) FromJsonUtil(org.onosproject.ovsdb.rfc.utils.FromJsonUtil) Map(java.util.Map) JsonNode(com.fasterxml.jackson.databind.JsonNode) Update(org.onosproject.ovsdb.rfc.operations.Update) Qos(org.onosproject.ovsdb.rfc.table.Qos) Callback(org.onosproject.ovsdb.rfc.jsonrpc.Callback) Set(java.util.Set) MIRRORS(org.onosproject.ovsdb.controller.OvsdbConstant.MIRRORS) OvsdbQueue(org.onosproject.ovsdb.controller.OvsdbQueue) Bridge(org.onosproject.ovsdb.rfc.table.Bridge) MIRROR(org.onosproject.ovsdb.controller.OvsdbConstant.MIRROR) Mirror(org.onosproject.ovsdb.rfc.table.Mirror) OvsdbPort(org.onosproject.ovsdb.controller.OvsdbPort) OperationResult(org.onosproject.ovsdb.rfc.message.OperationResult) OvsdbStore(org.onosproject.ovsdb.controller.OvsdbStore) DeviceId(org.onosproject.net.DeviceId) DATABASENAME(org.onosproject.ovsdb.controller.OvsdbConstant.DATABASENAME) Interface(org.onosproject.ovsdb.rfc.table.Interface) JsonRpcWriterUtil(org.onosproject.ovsdb.rfc.utils.JsonRpcWriterUtil) MirroringStatistics(org.onosproject.net.behaviour.MirroringStatistics) PORTS(org.onosproject.ovsdb.controller.OvsdbConstant.PORTS) ArrayList(java.util.ArrayList) DeviceCpuStats(org.onosproject.net.behaviour.DeviceCpuStats) Lists(com.google.common.collect.Lists) OvsdbInterface(org.onosproject.ovsdb.controller.OvsdbInterface) INTERFACE(org.onosproject.ovsdb.controller.OvsdbConstant.INTERFACE) BRIDGE_CONTROLLER(org.onosproject.ovsdb.controller.OvsdbConstant.BRIDGE_CONTROLLER) OvsdbPortName(org.onosproject.ovsdb.controller.OvsdbPortName) QUEUE(org.onosproject.ovsdb.controller.OvsdbConstant.QUEUE) QosId(org.onosproject.net.behaviour.QosId) OvsdbRowStore(org.onosproject.ovsdb.controller.OvsdbRowStore) EXTERNAL_ID(org.onosproject.ovsdb.controller.OvsdbConstant.EXTERNAL_ID) EXTERNAL_ID_INTERFACE_ID(org.onosproject.ovsdb.controller.OvsdbConstant.EXTERNAL_ID_INTERFACE_ID) Uuid(org.onosproject.ovsdb.rfc.notation.Uuid) OvsdbTable(org.onosproject.ovsdb.rfc.table.OvsdbTable) Channel(io.netty.channel.Channel) ExecutionException(java.util.concurrent.ExecutionException) Futures(com.google.common.util.concurrent.Futures) OvsdbBridge(org.onosproject.ovsdb.controller.OvsdbBridge) Column(org.onosproject.ovsdb.rfc.notation.Column) MutationUtil(org.onosproject.ovsdb.rfc.utils.MutationUtil) OvsdbClientService(org.onosproject.ovsdb.controller.OvsdbClientService) Row(org.onosproject.ovsdb.rfc.notation.Row) CONTROLLER(org.onosproject.ovsdb.controller.OvsdbConstant.CONTROLLER) TableGenerator(org.onosproject.ovsdb.rfc.table.TableGenerator) ControlProtocolVersion(org.onosproject.net.behaviour.ControlProtocolVersion) Mutation(org.onosproject.ovsdb.rfc.notation.Mutation) OvsdbPortNumber(org.onosproject.ovsdb.controller.OvsdbPortNumber) OvsdbTableStore(org.onosproject.ovsdb.controller.OvsdbTableStore) QOS_EXTERNAL_ID_KEY(org.onosproject.ovsdb.controller.OvsdbConstant.QOS_EXTERNAL_ID_KEY) LoggerFactory(org.slf4j.LoggerFactory) TimeoutException(java.util.concurrent.TimeoutException) SettableFuture(com.google.common.util.concurrent.SettableFuture) DeviceMemoryStats(org.onosproject.net.behaviour.DeviceMemoryStats) QUEUES(org.onosproject.ovsdb.controller.OvsdbConstant.QUEUES) Delete(org.onosproject.ovsdb.rfc.operations.Delete) UUID(org.onosproject.ovsdb.controller.OvsdbConstant.UUID) ConditionUtil(org.onosproject.ovsdb.rfc.utils.ConditionUtil) Function(com.google.common.base.Function) ImmutableSet(com.google.common.collect.ImmutableSet) OFPORT_ERROR(org.onosproject.ovsdb.controller.OvsdbConstant.OFPORT_ERROR) TYPEVXLAN(org.onosproject.ovsdb.controller.OvsdbConstant.TYPEVXLAN) InetSocketAddress(java.net.InetSocketAddress) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) Operation(org.onosproject.ovsdb.rfc.operations.Operation) Objects(java.util.Objects) List(java.util.List) Optional(java.util.Optional) Queue(org.onosproject.ovsdb.rfc.table.Queue) OvsdbQos(org.onosproject.ovsdb.controller.OvsdbQos) Insert(org.onosproject.ovsdb.rfc.operations.Insert) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) OvsdbNodeId(org.onosproject.ovsdb.controller.OvsdbNodeId) OvsdbMirror(org.onosproject.ovsdb.controller.OvsdbMirror) HashMap(java.util.HashMap) AtomicReference(java.util.concurrent.atomic.AtomicReference) ConcurrentMap(java.util.concurrent.ConcurrentMap) BRIDGE(org.onosproject.ovsdb.controller.OvsdbConstant.BRIDGE) OvsdbMap(org.onosproject.ovsdb.rfc.notation.OvsdbMap) HashSet(java.util.HashSet) PORT(org.onosproject.ovsdb.controller.OvsdbConstant.PORT) ImmutableList(com.google.common.collect.ImmutableList) TableUpdates(org.onosproject.ovsdb.rfc.message.TableUpdates) OvsdbSet(org.onosproject.ovsdb.rfc.notation.OvsdbSet) PORT_QOS(org.onosproject.ovsdb.controller.OvsdbConstant.PORT_QOS) DatabaseSchema(org.onosproject.ovsdb.rfc.schema.DatabaseSchema) TableSchema(org.onosproject.ovsdb.rfc.schema.TableSchema) ColumnSchema(org.onosproject.ovsdb.rfc.schema.ColumnSchema) IpAddress(org.onlab.packet.IpAddress) Port(org.onosproject.ovsdb.rfc.table.Port) ControllerInfo(org.onosproject.net.behaviour.ControllerInfo) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) VersionMismatchException(org.onosproject.ovsdb.rfc.exception.VersionMismatchException) MirroringName(org.onosproject.net.behaviour.MirroringName) BRIDGES(org.onosproject.ovsdb.controller.OvsdbConstant.BRIDGES) Maps(com.google.common.collect.Maps) INTERFACES(org.onosproject.ovsdb.controller.OvsdbConstant.INTERFACES) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) QOS(org.onosproject.ovsdb.controller.OvsdbConstant.QOS) QueueDescription(org.onosproject.net.behaviour.QueueDescription) Mutate(org.onosproject.ovsdb.rfc.operations.Mutate) Collections(java.util.Collections) Condition(org.onosproject.ovsdb.rfc.notation.Condition) ArrayList(java.util.ArrayList) Controller(org.onosproject.ovsdb.rfc.table.Controller) OvsdbRowStore(org.onosproject.ovsdb.controller.OvsdbRowStore) ControllerInfo(org.onosproject.net.behaviour.ControllerInfo) DatabaseSchema(org.onosproject.ovsdb.rfc.schema.DatabaseSchema) HashSet(java.util.HashSet)

Example 2 with Bridge

use of org.onosproject.ovsdb.rfc.table.Bridge 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)

Example 3 with Bridge

use of org.onosproject.ovsdb.rfc.table.Bridge in project onos by opennetworkinglab.

the class DefaultOvsdbClient method getBridgeUuid.

@Override
public String getBridgeUuid(String bridgeName) {
    DatabaseSchema dbSchema = schema.get(DATABASENAME);
    OvsdbRowStore rowStore = getRowStore(DATABASENAME, BRIDGE);
    if (rowStore == null) {
        log.debug("The bridge uuid is null");
        return null;
    }
    ConcurrentMap<String, Row> bridgeTableRows = rowStore.getRowStore();
    if (bridgeTableRows == null) {
        log.debug("The bridge uuid is null");
        return null;
    }
    for (String uuid : bridgeTableRows.keySet()) {
        Bridge bridge = (Bridge) TableGenerator.getTable(dbSchema, bridgeTableRows.get(uuid), OvsdbTable.BRIDGE);
        if (bridge.getName().equals(bridgeName)) {
            return uuid;
        }
    }
    return null;
}
Also used : Row(org.onosproject.ovsdb.rfc.notation.Row) OvsdbRowStore(org.onosproject.ovsdb.controller.OvsdbRowStore) Bridge(org.onosproject.ovsdb.rfc.table.Bridge) OvsdbBridge(org.onosproject.ovsdb.controller.OvsdbBridge) DatabaseSchema(org.onosproject.ovsdb.rfc.schema.DatabaseSchema)

Example 4 with Bridge

use of org.onosproject.ovsdb.rfc.table.Bridge in project onos by opennetworkinglab.

the class DefaultOvsdbClient method createMirror.

@Override
public boolean createMirror(String bridgeName, OvsdbMirror mirror) {
    /**
     * Retrieves bridge's uuid. It is necessary to update
     * Bridge table.
     */
    String bridgeUuid = getBridgeUuid(bridgeName);
    if (bridgeUuid == null) {
        log.warn("Couldn't find bridge {} in {}", bridgeName, nodeId.getIpAddress());
        return false;
    }
    OvsdbMirror.Builder mirrorBuilder = OvsdbMirror.builder();
    mirrorBuilder.mirroringName(mirror.mirroringName());
    mirrorBuilder.selectAll(mirror.selectAll());
    /**
     * Retrieves the uuid of the monitored dst ports.
     */
    mirrorBuilder.monitorDstPorts(mirror.monitorDstPorts().parallelStream().map(dstPort -> {
        String dstPortUuid = getPortUuid(dstPort.value(), bridgeUuid);
        if (dstPortUuid != null) {
            return Uuid.uuid(dstPortUuid);
        }
        log.warn("Couldn't find port {} in {}", dstPort.value(), nodeId.getIpAddress());
        return null;
    }).filter(Objects::nonNull).collect(Collectors.toSet()));
    /**
     * Retrieves the uuid of the monitored src ports.
     */
    mirrorBuilder.monitorSrcPorts(mirror.monitorSrcPorts().parallelStream().map(srcPort -> {
        String srcPortUuid = getPortUuid(srcPort.value(), bridgeUuid);
        if (srcPortUuid != null) {
            return Uuid.uuid(srcPortUuid);
        }
        log.warn("Couldn't find port {} in {}", srcPort.value(), nodeId.getIpAddress());
        return null;
    }).filter(Objects::nonNull).collect(Collectors.toSet()));
    mirrorBuilder.monitorVlans(mirror.monitorVlans());
    mirrorBuilder.mirrorPort(mirror.mirrorPort());
    mirrorBuilder.mirrorVlan(mirror.mirrorVlan());
    mirrorBuilder.externalIds(mirror.externalIds());
    mirror = mirrorBuilder.build();
    if (mirror.monitorDstPorts().isEmpty() && mirror.monitorSrcPorts().isEmpty() && mirror.monitorVlans().isEmpty()) {
        log.warn("Invalid monitoring data");
        return false;
    }
    DatabaseSchema dbSchema = schema.get(DATABASENAME);
    Mirror mirrorEntry = (Mirror) TableGenerator.createTable(dbSchema, OvsdbTable.MIRROR);
    mirrorEntry.setName(mirror.mirroringName());
    mirrorEntry.setSelectDstPort(mirror.monitorDstPorts());
    mirrorEntry.setSelectSrcPort(mirror.monitorSrcPorts());
    mirrorEntry.setSelectVlan(mirror.monitorVlans());
    mirrorEntry.setExternalIds(mirror.externalIds());
    /**
     * If mirror port, retrieves the uuid of the mirror port.
     */
    if (mirror.mirrorPort() != null) {
        String outputPortUuid = getPortUuid(mirror.mirrorPort().value(), bridgeUuid);
        if (outputPortUuid == null) {
            log.warn("Couldn't find port {} in {}", mirror.mirrorPort().value(), nodeId.getIpAddress());
            return false;
        }
        mirrorEntry.setOutputPort(Uuid.uuid(outputPortUuid));
    } else if (mirror.mirrorVlan() != null) {
        mirrorEntry.setOutputVlan(mirror.mirrorVlan());
    } else {
        log.warn("Invalid mirror, no mirror port and no mirror vlan");
        return false;
    }
    ArrayList<Operation> operations = Lists.newArrayList();
    Insert mirrorInsert = new Insert(dbSchema.getTableSchema("Mirror"), "Mirror", mirrorEntry.getRow());
    operations.add(mirrorInsert);
    // update the bridge table
    Condition condition = ConditionUtil.isEqual(UUID, Uuid.uuid(bridgeUuid));
    Mutation mutation = MutationUtil.insert(MIRRORS, Uuid.uuid("Mirror"));
    List<Condition> conditions = Lists.newArrayList(condition);
    List<Mutation> mutations = Lists.newArrayList(mutation);
    operations.add(new Mutate(dbSchema.getTableSchema("Bridge"), conditions, mutations));
    transactConfig(DATABASENAME, operations);
    log.info("Created mirror {}", mirror.mirroringName());
    return true;
}
Also used : QUEUE_EXTERNAL_ID_KEY(org.onosproject.ovsdb.controller.OvsdbConstant.QUEUE_EXTERNAL_ID_KEY) Controller(org.onosproject.ovsdb.rfc.table.Controller) ColumnSchemaNotFoundException(org.onosproject.ovsdb.rfc.exception.ColumnSchemaNotFoundException) OFPORT(org.onosproject.ovsdb.controller.OvsdbConstant.OFPORT) PortNumber(org.onosproject.net.PortNumber) QueueId(org.onosproject.net.behaviour.QueueId) FromJsonUtil(org.onosproject.ovsdb.rfc.utils.FromJsonUtil) Map(java.util.Map) JsonNode(com.fasterxml.jackson.databind.JsonNode) Update(org.onosproject.ovsdb.rfc.operations.Update) Qos(org.onosproject.ovsdb.rfc.table.Qos) Callback(org.onosproject.ovsdb.rfc.jsonrpc.Callback) Set(java.util.Set) MIRRORS(org.onosproject.ovsdb.controller.OvsdbConstant.MIRRORS) OvsdbQueue(org.onosproject.ovsdb.controller.OvsdbQueue) Bridge(org.onosproject.ovsdb.rfc.table.Bridge) MIRROR(org.onosproject.ovsdb.controller.OvsdbConstant.MIRROR) Mirror(org.onosproject.ovsdb.rfc.table.Mirror) OvsdbPort(org.onosproject.ovsdb.controller.OvsdbPort) OperationResult(org.onosproject.ovsdb.rfc.message.OperationResult) OvsdbStore(org.onosproject.ovsdb.controller.OvsdbStore) DeviceId(org.onosproject.net.DeviceId) DATABASENAME(org.onosproject.ovsdb.controller.OvsdbConstant.DATABASENAME) Interface(org.onosproject.ovsdb.rfc.table.Interface) JsonRpcWriterUtil(org.onosproject.ovsdb.rfc.utils.JsonRpcWriterUtil) MirroringStatistics(org.onosproject.net.behaviour.MirroringStatistics) PORTS(org.onosproject.ovsdb.controller.OvsdbConstant.PORTS) ArrayList(java.util.ArrayList) DeviceCpuStats(org.onosproject.net.behaviour.DeviceCpuStats) Lists(com.google.common.collect.Lists) OvsdbInterface(org.onosproject.ovsdb.controller.OvsdbInterface) INTERFACE(org.onosproject.ovsdb.controller.OvsdbConstant.INTERFACE) BRIDGE_CONTROLLER(org.onosproject.ovsdb.controller.OvsdbConstant.BRIDGE_CONTROLLER) OvsdbPortName(org.onosproject.ovsdb.controller.OvsdbPortName) QUEUE(org.onosproject.ovsdb.controller.OvsdbConstant.QUEUE) QosId(org.onosproject.net.behaviour.QosId) OvsdbRowStore(org.onosproject.ovsdb.controller.OvsdbRowStore) EXTERNAL_ID(org.onosproject.ovsdb.controller.OvsdbConstant.EXTERNAL_ID) EXTERNAL_ID_INTERFACE_ID(org.onosproject.ovsdb.controller.OvsdbConstant.EXTERNAL_ID_INTERFACE_ID) Uuid(org.onosproject.ovsdb.rfc.notation.Uuid) OvsdbTable(org.onosproject.ovsdb.rfc.table.OvsdbTable) Channel(io.netty.channel.Channel) ExecutionException(java.util.concurrent.ExecutionException) Futures(com.google.common.util.concurrent.Futures) OvsdbBridge(org.onosproject.ovsdb.controller.OvsdbBridge) Column(org.onosproject.ovsdb.rfc.notation.Column) MutationUtil(org.onosproject.ovsdb.rfc.utils.MutationUtil) OvsdbClientService(org.onosproject.ovsdb.controller.OvsdbClientService) Row(org.onosproject.ovsdb.rfc.notation.Row) CONTROLLER(org.onosproject.ovsdb.controller.OvsdbConstant.CONTROLLER) TableGenerator(org.onosproject.ovsdb.rfc.table.TableGenerator) ControlProtocolVersion(org.onosproject.net.behaviour.ControlProtocolVersion) Mutation(org.onosproject.ovsdb.rfc.notation.Mutation) OvsdbPortNumber(org.onosproject.ovsdb.controller.OvsdbPortNumber) OvsdbTableStore(org.onosproject.ovsdb.controller.OvsdbTableStore) QOS_EXTERNAL_ID_KEY(org.onosproject.ovsdb.controller.OvsdbConstant.QOS_EXTERNAL_ID_KEY) LoggerFactory(org.slf4j.LoggerFactory) TimeoutException(java.util.concurrent.TimeoutException) SettableFuture(com.google.common.util.concurrent.SettableFuture) DeviceMemoryStats(org.onosproject.net.behaviour.DeviceMemoryStats) QUEUES(org.onosproject.ovsdb.controller.OvsdbConstant.QUEUES) Delete(org.onosproject.ovsdb.rfc.operations.Delete) UUID(org.onosproject.ovsdb.controller.OvsdbConstant.UUID) ConditionUtil(org.onosproject.ovsdb.rfc.utils.ConditionUtil) Function(com.google.common.base.Function) ImmutableSet(com.google.common.collect.ImmutableSet) OFPORT_ERROR(org.onosproject.ovsdb.controller.OvsdbConstant.OFPORT_ERROR) TYPEVXLAN(org.onosproject.ovsdb.controller.OvsdbConstant.TYPEVXLAN) InetSocketAddress(java.net.InetSocketAddress) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) Operation(org.onosproject.ovsdb.rfc.operations.Operation) Objects(java.util.Objects) List(java.util.List) Optional(java.util.Optional) Queue(org.onosproject.ovsdb.rfc.table.Queue) OvsdbQos(org.onosproject.ovsdb.controller.OvsdbQos) Insert(org.onosproject.ovsdb.rfc.operations.Insert) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) OvsdbNodeId(org.onosproject.ovsdb.controller.OvsdbNodeId) OvsdbMirror(org.onosproject.ovsdb.controller.OvsdbMirror) HashMap(java.util.HashMap) AtomicReference(java.util.concurrent.atomic.AtomicReference) ConcurrentMap(java.util.concurrent.ConcurrentMap) BRIDGE(org.onosproject.ovsdb.controller.OvsdbConstant.BRIDGE) OvsdbMap(org.onosproject.ovsdb.rfc.notation.OvsdbMap) HashSet(java.util.HashSet) PORT(org.onosproject.ovsdb.controller.OvsdbConstant.PORT) ImmutableList(com.google.common.collect.ImmutableList) TableUpdates(org.onosproject.ovsdb.rfc.message.TableUpdates) OvsdbSet(org.onosproject.ovsdb.rfc.notation.OvsdbSet) PORT_QOS(org.onosproject.ovsdb.controller.OvsdbConstant.PORT_QOS) DatabaseSchema(org.onosproject.ovsdb.rfc.schema.DatabaseSchema) TableSchema(org.onosproject.ovsdb.rfc.schema.TableSchema) ColumnSchema(org.onosproject.ovsdb.rfc.schema.ColumnSchema) IpAddress(org.onlab.packet.IpAddress) Port(org.onosproject.ovsdb.rfc.table.Port) ControllerInfo(org.onosproject.net.behaviour.ControllerInfo) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) VersionMismatchException(org.onosproject.ovsdb.rfc.exception.VersionMismatchException) MirroringName(org.onosproject.net.behaviour.MirroringName) BRIDGES(org.onosproject.ovsdb.controller.OvsdbConstant.BRIDGES) Maps(com.google.common.collect.Maps) INTERFACES(org.onosproject.ovsdb.controller.OvsdbConstant.INTERFACES) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) QOS(org.onosproject.ovsdb.controller.OvsdbConstant.QOS) QueueDescription(org.onosproject.net.behaviour.QueueDescription) Mutate(org.onosproject.ovsdb.rfc.operations.Mutate) Collections(java.util.Collections) Condition(org.onosproject.ovsdb.rfc.notation.Condition) Condition(org.onosproject.ovsdb.rfc.notation.Condition) Mutate(org.onosproject.ovsdb.rfc.operations.Mutate) Operation(org.onosproject.ovsdb.rfc.operations.Operation) OvsdbMirror(org.onosproject.ovsdb.controller.OvsdbMirror) Insert(org.onosproject.ovsdb.rfc.operations.Insert) Objects(java.util.Objects) Mutation(org.onosproject.ovsdb.rfc.notation.Mutation) Mirror(org.onosproject.ovsdb.rfc.table.Mirror) OvsdbMirror(org.onosproject.ovsdb.controller.OvsdbMirror) DatabaseSchema(org.onosproject.ovsdb.rfc.schema.DatabaseSchema)

Example 5 with Bridge

use of org.onosproject.ovsdb.rfc.table.Bridge in project onos by opennetworkinglab.

the class DefaultOvsdbClient method getControllers.

private List<Controller> getControllers(Uuid bridgeUuid) {
    DatabaseSchema dbSchema = schema.get(DATABASENAME);
    if (dbSchema == null) {
        return null;
    }
    OvsdbRowStore rowStore = getRowStore(DATABASENAME, BRIDGE);
    if (rowStore == null) {
        log.debug("There is no bridge table");
        return null;
    }
    Row bridgeRow = rowStore.getRow(bridgeUuid.value());
    Bridge bridge = (Bridge) TableGenerator.getTable(dbSchema, bridgeRow, OvsdbTable.BRIDGE);
    // FIXME remove log
    log.warn("type of controller column", bridge.getControllerColumn().data().getClass());
    Set<Uuid> controllerUuids = (Set<Uuid>) ((OvsdbSet) bridge.getControllerColumn().data()).set();
    OvsdbRowStore controllerRowStore = getRowStore(DATABASENAME, CONTROLLER);
    if (controllerRowStore == null) {
        log.debug("There is no controller table");
        return null;
    }
    List<Controller> ovsdbControllers = new ArrayList<>();
    ConcurrentMap<String, Row> controllerTableRows = controllerRowStore.getRowStore();
    controllerTableRows.forEach((key, row) -> {
        if (!controllerUuids.contains(Uuid.uuid(key))) {
            return;
        }
        Controller controller = (Controller) TableGenerator.getTable(dbSchema, row, OvsdbTable.CONTROLLER);
        ovsdbControllers.add(controller);
    });
    return ovsdbControllers;
}
Also used : Uuid(org.onosproject.ovsdb.rfc.notation.Uuid) Set(java.util.Set) ImmutableSet(com.google.common.collect.ImmutableSet) HashSet(java.util.HashSet) OvsdbSet(org.onosproject.ovsdb.rfc.notation.OvsdbSet) ArrayList(java.util.ArrayList) Row(org.onosproject.ovsdb.rfc.notation.Row) OvsdbRowStore(org.onosproject.ovsdb.controller.OvsdbRowStore) Controller(org.onosproject.ovsdb.rfc.table.Controller) Bridge(org.onosproject.ovsdb.rfc.table.Bridge) OvsdbBridge(org.onosproject.ovsdb.controller.OvsdbBridge) DatabaseSchema(org.onosproject.ovsdb.rfc.schema.DatabaseSchema)

Aggregations

Bridge (org.onosproject.ovsdb.rfc.table.Bridge)13 OvsdbBridge (org.onosproject.ovsdb.controller.OvsdbBridge)12 Row (org.onosproject.ovsdb.rfc.notation.Row)12 DatabaseSchema (org.onosproject.ovsdb.rfc.schema.DatabaseSchema)12 OvsdbRowStore (org.onosproject.ovsdb.controller.OvsdbRowStore)10 OvsdbSet (org.onosproject.ovsdb.rfc.notation.OvsdbSet)10 Uuid (org.onosproject.ovsdb.rfc.notation.Uuid)10 HashSet (java.util.HashSet)9 ImmutableSet (com.google.common.collect.ImmutableSet)8 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)8 Map (java.util.Map)8 Set (java.util.Set)8 ConcurrentMap (java.util.concurrent.ConcurrentMap)8 OvsdbMap (org.onosproject.ovsdb.rfc.notation.OvsdbMap)8 JsonNode (com.fasterxml.jackson.databind.JsonNode)6 Function (com.google.common.base.Function)6 ImmutableList (com.google.common.collect.ImmutableList)6 Lists (com.google.common.collect.Lists)6 Maps (com.google.common.collect.Maps)6