Search in sources :

Example 1 with OvsdbController

use of org.onosproject.ovsdb.controller.OvsdbController 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 OvsdbController

use of org.onosproject.ovsdb.controller.OvsdbController in project onos by opennetworkinglab.

the class OvsdbControllerConfig method getOvsdbClientService.

// Used for getting OvsdbClientService.
private OvsdbClientService getOvsdbClientService(DriverHandler handler) {
    OvsdbController ovsController = handler.get(OvsdbController.class);
    DeviceService deviceService = handler.get(DeviceService.class);
    DeviceId ofDeviceId = handler.data().deviceId();
    String[] mgmtAddress = deviceService.getDevice(ofDeviceId).annotations().value(AnnotationKeys.MANAGEMENT_ADDRESS).split(":");
    String targetIp = mgmtAddress[0];
    TpPort targetPort = null;
    if (mgmtAddress.length > 1) {
        targetPort = TpPort.tpPort(Integer.parseInt(mgmtAddress[1]));
    }
    List<OvsdbNodeId> nodeIds = ovsController.getNodeIds().stream().filter(nodeId -> nodeId.getIpAddress().equals(targetIp)).collect(Collectors.toList());
    if (nodeIds.isEmpty()) {
        // TODO decide what port?
        ovsController.connect(IpAddress.valueOf(targetIp), targetPort == null ? TpPort.tpPort(OvsdbConstant.OVSDBPORT) : targetPort);
        // FIXME... connect is async
        delay(1000);
    }
    List<OvsdbClientService> clientServices = ovsController.getNodeIds().stream().filter(nodeId -> nodeId.getIpAddress().equals(targetIp)).map(ovsController::getOvsdbClient).filter(cs -> cs.getBridges().stream().anyMatch(b -> dpidMatches(b, ofDeviceId))).collect(Collectors.toList());
    checkState(!clientServices.isEmpty(), "No clientServices found");
    // FIXME add connection to management address if null --> done ?
    return !clientServices.isEmpty() ? clientServices.get(0) : null;
}
Also used : TpPort(org.onlab.packet.TpPort) ControllerInfo(org.onosproject.net.behaviour.ControllerInfo) ImmutableSet(com.google.common.collect.ImmutableSet) OvsdbNodeId(org.onosproject.ovsdb.controller.OvsdbNodeId) DeviceService(org.onosproject.net.device.DeviceService) Set(java.util.Set) AnnotationKeys(org.onosproject.net.AnnotationKeys) ControllerConfig(org.onosproject.net.behaviour.ControllerConfig) Collectors(java.util.stream.Collectors) AbstractHandlerBehaviour(org.onosproject.net.driver.AbstractHandlerBehaviour) ArrayList(java.util.ArrayList) Preconditions.checkState(com.google.common.base.Preconditions.checkState) List(java.util.List) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) DriverHandler(org.onosproject.net.driver.DriverHandler) OvsdbController(org.onosproject.ovsdb.controller.OvsdbController) Tools.delay(org.onlab.util.Tools.delay) OvsdbBridge(org.onosproject.ovsdb.controller.OvsdbBridge) OvsdbConstant(org.onosproject.ovsdb.controller.OvsdbConstant) OvsdbClientService(org.onosproject.ovsdb.controller.OvsdbClientService) DeviceId(org.onosproject.net.DeviceId) IpAddress(org.onlab.packet.IpAddress) OvsdbClientService(org.onosproject.ovsdb.controller.OvsdbClientService) DeviceId(org.onosproject.net.DeviceId) DeviceService(org.onosproject.net.device.DeviceService) TpPort(org.onlab.packet.TpPort) OvsdbController(org.onosproject.ovsdb.controller.OvsdbController) OvsdbNodeId(org.onosproject.ovsdb.controller.OvsdbNodeId)

Example 3 with OvsdbController

use of org.onosproject.ovsdb.controller.OvsdbController in project onos by opennetworkinglab.

the class OvsdbInterfaceConfig method getOvsdbClient.

private OvsdbClientService getOvsdbClient(DriverHandler handler) {
    OvsdbController ovsController = handler.get(OvsdbController.class);
    OvsdbNodeId nodeId = changeDeviceIdToNodeId(handler.data().deviceId());
    return ovsController.getOvsdbClient(nodeId);
}
Also used : OvsdbController(org.onosproject.ovsdb.controller.OvsdbController) OvsdbNodeId(org.onosproject.ovsdb.controller.OvsdbNodeId)

Example 4 with OvsdbController

use of org.onosproject.ovsdb.controller.OvsdbController in project onos by opennetworkinglab.

the class OvsdbPortConfig method getOvsdbClient.

private OvsdbClientService getOvsdbClient(DriverHandler handler) {
    OvsdbController ovsController = handler.get(OvsdbController.class);
    OvsdbNodeId nodeId = changeDeviceIdToNodeId(handler.data().deviceId());
    return ovsController.getOvsdbClient(nodeId);
}
Also used : OvsdbController(org.onosproject.ovsdb.controller.OvsdbController) OvsdbNodeId(org.onosproject.ovsdb.controller.OvsdbNodeId)

Example 5 with OvsdbController

use of org.onosproject.ovsdb.controller.OvsdbController in project onos by opennetworkinglab.

the class OvsdbQueueConfig method getOvsdbClient.

private OvsdbClientService getOvsdbClient(DriverHandler handler) {
    OvsdbController ovsController = handler.get(OvsdbController.class);
    OvsdbNodeId nodeId = changeDeviceIdToNodeId(handler.data().deviceId());
    return ovsController.getOvsdbClient(nodeId);
}
Also used : OvsdbController(org.onosproject.ovsdb.controller.OvsdbController) OvsdbNodeId(org.onosproject.ovsdb.controller.OvsdbNodeId)

Aggregations

OvsdbController (org.onosproject.ovsdb.controller.OvsdbController)12 OvsdbNodeId (org.onosproject.ovsdb.controller.OvsdbNodeId)8 DeviceId (org.onosproject.net.DeviceId)5 DeviceService (org.onosproject.net.device.DeviceService)5 OvsdbClientService (org.onosproject.ovsdb.controller.OvsdbClientService)5 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 Set (java.util.Set)3 IpAddress (org.onlab.packet.IpAddress)3 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)2 Preconditions.checkState (com.google.common.base.Preconditions.checkState)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 Collection (java.util.Collection)2 TpPort (org.onlab.packet.TpPort)2 Tools.delay (org.onlab.util.Tools.delay)2 AnnotationKeys (org.onosproject.net.AnnotationKeys)2 BridgeName (org.onosproject.net.behaviour.BridgeName)2 ControllerInfo (org.onosproject.net.behaviour.ControllerInfo)2 AbstractHandlerBehaviour (org.onosproject.net.driver.AbstractHandlerBehaviour)2 DriverHandler (org.onosproject.net.driver.DriverHandler)2