Search in sources :

Example 1 with OvsdbSet

use of org.onosproject.ovsdb.rfc.notation.OvsdbSet in project onos by opennetworkinglab.

the class DefaultOpenstackNodeHandler method isDpdkIntfsCreated.

private boolean isDpdkIntfsCreated(OpenstackNode osNode, Collection<DpdkInterface> dpdkInterfaces) {
    OvsdbClientService client = getOvsdbClient(osNode, ovsdbPortNum, ovsdbController);
    if (client == null) {
        log.info("Failed to get ovsdb client");
        return false;
    }
    Set<OvsdbPort> ports = client.getPorts();
    for (DpdkInterface dpdkIntf : dpdkInterfaces) {
        Optional<OvsdbPort> port = ports.stream().filter(ovsdbPort -> ovsdbPort.portName().value().equals(dpdkIntf.intf())).findAny();
        if (!port.isPresent()) {
            return false;
        }
        Interface intf = client.getInterface(dpdkIntf.intf());
        if (intf == null) {
            return false;
        }
        OvsdbSet mtu = (OvsdbSet) intf.getMtuColumn().data();
        if (mtu == null) {
            return false;
        }
        OvsdbMap option = (OvsdbMap) intf.getOptionsColumn().data();
        if (option == null) {
            return false;
        }
        if (!mtu.set().contains(dpdkIntf.mtu().intValue()) || !option.toString().contains(dpdkIntf.pciAddress())) {
            log.trace("The dpdk interface {} was created but mtu or " + "pci address is different from the config.");
            return false;
        }
    }
    return true;
}
Also used : DpdkInterface(org.onosproject.openstacknode.api.DpdkInterface) GENEVE(org.onosproject.openstacknode.api.Constants.GENEVE) DefaultBridgeDescription(org.onosproject.net.behaviour.DefaultBridgeDescription) OSClient(org.openstack4j.api.OSClient) OVSDB_PORT(org.onosproject.openstacknode.impl.OsgiPropertyConstants.OVSDB_PORT) OpenstackNodeUtil.structurePortName(org.onosproject.openstacknode.util.OpenstackNodeUtil.structurePortName) CoreService(org.onosproject.core.CoreService) DeviceService(org.onosproject.net.device.DeviceService) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) BRIDGE_PREFIX(org.onosproject.openstacknode.api.Constants.BRIDGE_PREFIX) GRE(org.onosproject.openstacknode.api.Constants.GRE) COMPLETE(org.onosproject.openstacknode.api.NodeState.COMPLETE) INTEGRATION_BRIDGE(org.onosproject.openstacknode.api.Constants.INTEGRATION_BRIDGE) OpenstackNodeUtil.getConnectedClient(org.onosproject.openstacknode.util.OpenstackNodeUtil.getConnectedClient) OpenstackPhyInterface(org.onosproject.openstacknode.api.OpenstackPhyInterface) TpPort.tpPort(org.onlab.packet.TpPort.tpPort) INTEGRATION_TO_PHYSICAL_PREFIX(org.onosproject.openstacknode.api.Constants.INTEGRATION_TO_PHYSICAL_PREFIX) OpenstackNodeListener(org.onosproject.openstacknode.api.OpenstackNodeListener) OvsdbController(org.onosproject.ovsdb.controller.OvsdbController) Port(org.onosproject.net.Port) ApplicationId(org.onosproject.core.ApplicationId) OpenstackNodeUtil.isOvsdbConnected(org.onosproject.openstacknode.util.OpenstackNodeUtil.isOvsdbConnected) NodeId(org.onosproject.cluster.NodeId) OpenstackNodeService(org.onosproject.openstacknode.api.OpenstackNodeService) Device(org.onosproject.net.Device) Deactivate(org.osgi.service.component.annotations.Deactivate) BridgeName(org.onosproject.net.behaviour.BridgeName) Collection(java.util.Collection) OpenstackNodeUtil.addOrRemoveSystemInterface(org.onosproject.openstacknode.util.OpenstackNodeUtil.addOrRemoveSystemInterface) Set(java.util.Set) Executors.newSingleThreadExecutor(java.util.concurrent.Executors.newSingleThreadExecutor) Collectors(java.util.stream.Collectors) DefaultPatchDescription(org.onosproject.net.behaviour.DefaultPatchDescription) Objects(java.util.Objects) List(java.util.List) TunnelEndPoints(org.onosproject.net.behaviour.TunnelEndPoints) OvsdbPort(org.onosproject.ovsdb.controller.OvsdbPort) OpenstackNodeUtil.getOvsdbClient(org.onosproject.openstacknode.util.OpenstackNodeUtil.getOvsdbClient) DeviceEvent(org.onosproject.net.device.DeviceEvent) Optional(java.util.Optional) ClusterService(org.onosproject.cluster.ClusterService) DeviceId(org.onosproject.net.DeviceId) Dictionary(java.util.Dictionary) BridgeConfig(org.onosproject.net.behaviour.BridgeConfig) InterfaceConfig(org.onosproject.net.behaviour.InterfaceConfig) GATEWAY(org.onosproject.openstacknode.api.OpenstackNode.NodeType.GATEWAY) AUTO_RECOVERY(org.onosproject.openstacknode.impl.OsgiPropertyConstants.AUTO_RECOVERY) Tools(org.onlab.util.Tools) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) BridgeDescription(org.onosproject.net.behaviour.BridgeDescription) INIT(org.onosproject.openstacknode.api.NodeState.INIT) ComponentContext(org.osgi.service.component.ComponentContext) PORT_NAME(org.onosproject.net.AnnotationKeys.PORT_NAME) Interface(org.onosproject.ovsdb.rfc.table.Interface) OpenstackNodeAdminService(org.onosproject.openstacknode.api.OpenstackNodeAdminService) INCOMPLETE(org.onosproject.openstacknode.api.NodeState.INCOMPLETE) ControllerNode(org.onosproject.cluster.ControllerNode) CONTROLLER(org.onosproject.openstacknode.api.OpenstackNode.NodeType.CONTROLLER) OvsdbMap(org.onosproject.ovsdb.rfc.notation.OvsdbMap) TUNNEL_BRIDGE(org.onosproject.openstacknode.api.Constants.TUNNEL_BRIDGE) Component(org.osgi.service.component.annotations.Component) Lists(com.google.common.collect.Lists) DefaultTunnelDescription(org.onosproject.net.behaviour.DefaultTunnelDescription) OvsdbSet(org.onosproject.ovsdb.rfc.notation.OvsdbSet) OVSDB_PORT_NUM_DEFAULT(org.onosproject.openstacknode.impl.OsgiPropertyConstants.OVSDB_PORT_NUM_DEFAULT) Activate(org.osgi.service.component.annotations.Activate) VXLAN_TUNNEL(org.onosproject.openstacknode.api.Constants.VXLAN_TUNNEL) GENEVE_TUNNEL(org.onosproject.openstacknode.api.Constants.GENEVE_TUNNEL) ExecutorService(java.util.concurrent.ExecutorService) IpAddress(org.onlab.packet.IpAddress) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) PHYSICAL_TO_INTEGRATION_SUFFIX(org.onosproject.openstacknode.api.Constants.PHYSICAL_TO_INTEGRATION_SUFFIX) DEVICE_CREATED(org.onosproject.openstacknode.api.NodeState.DEVICE_CREATED) ControllerInfo(org.onosproject.net.behaviour.ControllerInfo) DeviceListener(org.onosproject.net.device.DeviceListener) GRE_TUNNEL(org.onosproject.openstacknode.api.Constants.GRE_TUNNEL) OpenstackNodeUtil.addOrRemoveDpdkInterface(org.onosproject.openstacknode.util.OpenstackNodeUtil.addOrRemoveDpdkInterface) OpenstackNodeUtil.getBooleanProperty(org.onosproject.openstacknode.util.OpenstackNodeUtil.getBooleanProperty) Logger(org.slf4j.Logger) PatchDescription(org.onosproject.net.behaviour.PatchDescription) TunnelDescription(org.onosproject.net.behaviour.TunnelDescription) OpenstackNodeHandler(org.onosproject.openstacknode.api.OpenstackNodeHandler) APP_ID(org.onosproject.openstacknode.api.OpenstackNodeService.APP_ID) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) TunnelKeys(org.onosproject.net.behaviour.TunnelKeys) DeviceAdminService(org.onosproject.net.device.DeviceAdminService) OpenstackNodeEvent(org.onosproject.openstacknode.api.OpenstackNodeEvent) NETDEV(org.onosproject.openstacknode.api.DpdkConfig.DatapathType.NETDEV) VXLAN(org.onosproject.openstacknode.api.Constants.VXLAN) Modified(org.osgi.service.component.annotations.Modified) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) OvsdbClientService(org.onosproject.ovsdb.controller.OvsdbClientService) Reference(org.osgi.service.component.annotations.Reference) LeadershipService(org.onosproject.cluster.LeadershipService) NodeState(org.onosproject.openstacknode.api.NodeState) AUTO_RECOVERY_DEFAULT(org.onosproject.openstacknode.impl.OsgiPropertyConstants.AUTO_RECOVERY_DEFAULT) OvsdbSet(org.onosproject.ovsdb.rfc.notation.OvsdbSet) DpdkInterface(org.onosproject.openstacknode.api.DpdkInterface) OpenstackNodeUtil.addOrRemoveDpdkInterface(org.onosproject.openstacknode.util.OpenstackNodeUtil.addOrRemoveDpdkInterface) OvsdbClientService(org.onosproject.ovsdb.controller.OvsdbClientService) OvsdbMap(org.onosproject.ovsdb.rfc.notation.OvsdbMap) OvsdbPort(org.onosproject.ovsdb.controller.OvsdbPort) DpdkInterface(org.onosproject.openstacknode.api.DpdkInterface) OpenstackPhyInterface(org.onosproject.openstacknode.api.OpenstackPhyInterface) OpenstackNodeUtil.addOrRemoveSystemInterface(org.onosproject.openstacknode.util.OpenstackNodeUtil.addOrRemoveSystemInterface) Interface(org.onosproject.ovsdb.rfc.table.Interface) OpenstackNodeUtil.addOrRemoveDpdkInterface(org.onosproject.openstacknode.util.OpenstackNodeUtil.addOrRemoveDpdkInterface)

Example 2 with OvsdbSet

use of org.onosproject.ovsdb.rfc.notation.OvsdbSet in project onos by opennetworkinglab.

the class DefaultOvsdbClient method getPortError.

@Override
public boolean getPortError(List<OvsdbPortName> portNames, DeviceId bridgeId) {
    Uuid bridgeUuid = getBridgeUuid(bridgeId);
    List<Interface> interfaceList = portNames.stream().collect(Collectors.toMap(java.util.function.Function.identity(), port -> (Interface) getInterfacebyPort(getPortUuid(port.value(), bridgeUuid.value()), port.value()))).entrySet().stream().filter(intf -> Objects.nonNull(intf.getValue()) && ((OvsdbSet) intf.getValue().getOpenFlowPortColumn().data()).set().stream().findAny().orElse(OFPORT_ERROR_COMPARISON).equals(OFPORT_ERROR)).map(Map.Entry::getValue).collect(Collectors.toList());
    interfaceList.forEach(intf -> ((Consumer<Interface>) intf1 -> {
        try {
            Set<String> setErrors = ((OvsdbSet) intf1.getErrorColumn().data()).set();
            log.info("Port has errors. ofport value - {}, Interface - {} has error - {} ", intf1.getOpenFlowPortColumn().data(), intf1.getName(), setErrors.stream().findFirst().get());
        } catch (ColumnSchemaNotFoundException | VersionMismatchException e) {
            log.debug("Port has errors. ofport value - {}, Interface - {} has error - {} ", intf1.getOpenFlowPortColumn().data(), intf1.getName(), e);
        }
    }).accept(intf));
    return !interfaceList.isEmpty();
}
Also used : OvsdbSet(org.onosproject.ovsdb.rfc.notation.OvsdbSet) 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) 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) Map(java.util.Map) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) OvsdbMap(org.onosproject.ovsdb.rfc.notation.OvsdbMap) Interface(org.onosproject.ovsdb.rfc.table.Interface) OvsdbInterface(org.onosproject.ovsdb.controller.OvsdbInterface)

Example 3 with OvsdbSet

use of org.onosproject.ovsdb.rfc.notation.OvsdbSet in project onos by opennetworkinglab.

the class DefaultOvsdbClient method getOvsdbQueue.

private OvsdbQueue getOvsdbQueue(Row row) {
    DatabaseSchema dbSchema = getDatabaseSchema(DATABASENAME);
    Queue queue = (Queue) TableGenerator.getTable(dbSchema, row, OvsdbTable.QUEUE);
    if (queue == null) {
        return null;
    }
    OvsdbSet dscpOvsdbSet = ((OvsdbSet) queue.getDscpColumn().data());
    Set dscpSet = dscpOvsdbSet.set();
    Long dscp = null;
    if (dscpSet != null && !dscpSet.isEmpty()) {
        dscp = Long.valueOf(dscpSet.toArray()[0].toString());
    }
    Map<String, String> otherConfigs;
    Map<String, String> externalIds;
    otherConfigs = ((OvsdbMap) queue.getOtherConfigColumn().data()).map();
    externalIds = ((OvsdbMap) queue.getExternalIdsColumn().data()).map();
    return OvsdbQueue.builder().dscp(dscp).otherConfigs(otherConfigs).externalIds(externalIds).build();
}
Also used : OvsdbSet(org.onosproject.ovsdb.rfc.notation.OvsdbSet) Set(java.util.Set) ImmutableSet(com.google.common.collect.ImmutableSet) HashSet(java.util.HashSet) OvsdbSet(org.onosproject.ovsdb.rfc.notation.OvsdbSet) OvsdbQueue(org.onosproject.ovsdb.controller.OvsdbQueue) Queue(org.onosproject.ovsdb.rfc.table.Queue) DatabaseSchema(org.onosproject.ovsdb.rfc.schema.DatabaseSchema)

Example 4 with OvsdbSet

use of org.onosproject.ovsdb.rfc.notation.OvsdbSet in project onos by opennetworkinglab.

the class DefaultOvsdbClient method removeQos.

@Override
public void removeQos(PortNumber portNumber) {
    DatabaseSchema dbSchema = schema.get(DATABASENAME);
    OvsdbRowStore rowStore = getRowStore(DATABASENAME, PORT);
    if (rowStore == null) {
        log.debug("The qos uuid is null");
        return;
    }
    ConcurrentMap<String, Row> ovsTableRows = rowStore.getRowStore();
    Row portRow = ovsTableRows.values().stream().filter(r -> r.getColumn("name").data().equals(portNumber.name())).findFirst().orElse(null);
    if (portRow == null) {
        log.warn("Couldn't find port {} in ovsdb port table.", portNumber.name());
        return;
    }
    OvsdbSet ovsdbSet = ((OvsdbSet) portRow.getColumn(PORT_QOS).data());
    @SuppressWarnings("unchecked") Set<Uuid> qosIdSet = ovsdbSet.set();
    if (qosIdSet == null || qosIdSet.isEmpty()) {
        return;
    }
    Uuid qosUuid = (Uuid) qosIdSet.toArray()[0];
    Condition condition = ConditionUtil.isEqual(UUID, portRow.uuid());
    List<Condition> conditions = Lists.newArrayList(condition);
    Mutation mutation = MutationUtil.delete(PORT_QOS, qosUuid);
    List<Mutation> mutations = Lists.newArrayList(mutation);
    ArrayList<Operation> operations = Lists.newArrayList();
    Mutate mutate = new Mutate(dbSchema.getTableSchema(PORT), conditions, mutations);
    operations.add(mutate);
    transactConfig(DATABASENAME, operations);
}
Also used : Condition(org.onosproject.ovsdb.rfc.notation.Condition) Mutate(org.onosproject.ovsdb.rfc.operations.Mutate) Operation(org.onosproject.ovsdb.rfc.operations.Operation) OvsdbRowStore(org.onosproject.ovsdb.controller.OvsdbRowStore) OvsdbSet(org.onosproject.ovsdb.rfc.notation.OvsdbSet) Uuid(org.onosproject.ovsdb.rfc.notation.Uuid) Row(org.onosproject.ovsdb.rfc.notation.Row) Mutation(org.onosproject.ovsdb.rfc.notation.Mutation) DatabaseSchema(org.onosproject.ovsdb.rfc.schema.DatabaseSchema)

Example 5 with OvsdbSet

use of org.onosproject.ovsdb.rfc.notation.OvsdbSet 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

OvsdbSet (org.onosproject.ovsdb.rfc.notation.OvsdbSet)15 Set (java.util.Set)10 Row (org.onosproject.ovsdb.rfc.notation.Row)9 DatabaseSchema (org.onosproject.ovsdb.rfc.schema.DatabaseSchema)9 ImmutableSet (com.google.common.collect.ImmutableSet)8 HashSet (java.util.HashSet)8 Uuid (org.onosproject.ovsdb.rfc.notation.Uuid)8 Bridge (org.onosproject.ovsdb.rfc.table.Bridge)8 OvsdbBridge (org.onosproject.ovsdb.controller.OvsdbBridge)7 OvsdbRowStore (org.onosproject.ovsdb.controller.OvsdbRowStore)7 ArrayList (java.util.ArrayList)6 OvsdbPort (org.onosproject.ovsdb.controller.OvsdbPort)6 OvsdbMap (org.onosproject.ovsdb.rfc.notation.OvsdbMap)6 Lists (com.google.common.collect.Lists)5 List (java.util.List)5 Objects (java.util.Objects)5 Optional (java.util.Optional)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 Function (com.google.common.base.Function)4 ImmutableList (com.google.common.collect.ImmutableList)4