Search in sources :

Example 1 with OvsdbPort

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

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

the class OvsdbBridgeConfig method getPorts.

@Override
public Collection<PortDescription> getPorts() {
    OvsdbClientService client = getOvsdbClientService(handler());
    if (client == null) {
        return Collections.emptyList();
    }
    Set<OvsdbPort> ports = client.getPorts();
    return ports.stream().map(x -> DefaultPortDescription.builder().withPortNumber(PortNumber.portNumber(x.portNumber().value())).isEnabled(true).annotations(DefaultAnnotations.builder().set("portName", x.portName().value()).build()).build()).collect(Collectors.toSet());
}
Also used : DefaultBridgeDescription(org.onosproject.net.behaviour.DefaultBridgeDescription) OvsdbNodeId(org.onosproject.ovsdb.controller.OvsdbNodeId) BridgeDescription(org.onosproject.net.behaviour.BridgeDescription) Collection(java.util.Collection) BridgeName(org.onosproject.net.behaviour.BridgeName) PortNumber(org.onosproject.net.PortNumber) Set(java.util.Set) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) AbstractHandlerBehaviour(org.onosproject.net.driver.AbstractHandlerBehaviour) List(java.util.List) DefaultAnnotations(org.onosproject.net.DefaultAnnotations) DefaultPortDescription(org.onosproject.net.device.DefaultPortDescription) DriverHandler(org.onosproject.net.driver.DriverHandler) OvsdbController(org.onosproject.ovsdb.controller.OvsdbController) OvsdbBridge(org.onosproject.ovsdb.controller.OvsdbBridge) OvsdbPort(org.onosproject.ovsdb.controller.OvsdbPort) PortDescription(org.onosproject.net.device.PortDescription) OvsdbClientService(org.onosproject.ovsdb.controller.OvsdbClientService) DeviceId(org.onosproject.net.DeviceId) Collections(java.util.Collections) IpAddress(org.onlab.packet.IpAddress) BridgeConfig(org.onosproject.net.behaviour.BridgeConfig) OvsdbClientService(org.onosproject.ovsdb.controller.OvsdbClientService) OvsdbPort(org.onosproject.ovsdb.controller.OvsdbPort)

Example 3 with OvsdbPort

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

the class DefaultOvsdbClient method getOvsdbPort.

private OvsdbPort getOvsdbPort(Row row) {
    DatabaseSchema dbSchema = getDatabaseSchema(DATABASENAME);
    Interface intf = (Interface) TableGenerator.getTable(dbSchema, row, OvsdbTable.INTERFACE);
    if (intf == null) {
        return null;
    }
    long ofPort = getOfPort(intf);
    String portName = intf.getName();
    if ((ofPort < 0) || (portName == null)) {
        return null;
    }
    return new OvsdbPort(new OvsdbPortNumber(ofPort), new OvsdbPortName(portName));
}
Also used : OvsdbPortNumber(org.onosproject.ovsdb.controller.OvsdbPortNumber) OvsdbPortName(org.onosproject.ovsdb.controller.OvsdbPortName) Interface(org.onosproject.ovsdb.rfc.table.Interface) OvsdbInterface(org.onosproject.ovsdb.controller.OvsdbInterface) OvsdbPort(org.onosproject.ovsdb.controller.OvsdbPort) DatabaseSchema(org.onosproject.ovsdb.rfc.schema.DatabaseSchema)

Example 4 with OvsdbPort

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

the class OvsdbBridgeConfig method getPortNumbers.

@Override
public Set<PortNumber> getPortNumbers() {
    DriverHandler handler = handler();
    OvsdbClientService client = getOvsdbClientService(handler);
    if (client == null) {
        return Collections.emptySet();
    }
    Set<OvsdbPort> ports = client.getPorts();
    return ports.stream().map(x -> PortNumber.portNumber(x.portNumber().value(), x.portName().value())).collect(Collectors.toSet());
}
Also used : DefaultBridgeDescription(org.onosproject.net.behaviour.DefaultBridgeDescription) OvsdbNodeId(org.onosproject.ovsdb.controller.OvsdbNodeId) BridgeDescription(org.onosproject.net.behaviour.BridgeDescription) Collection(java.util.Collection) BridgeName(org.onosproject.net.behaviour.BridgeName) PortNumber(org.onosproject.net.PortNumber) Set(java.util.Set) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) AbstractHandlerBehaviour(org.onosproject.net.driver.AbstractHandlerBehaviour) List(java.util.List) DefaultAnnotations(org.onosproject.net.DefaultAnnotations) DefaultPortDescription(org.onosproject.net.device.DefaultPortDescription) DriverHandler(org.onosproject.net.driver.DriverHandler) OvsdbController(org.onosproject.ovsdb.controller.OvsdbController) OvsdbBridge(org.onosproject.ovsdb.controller.OvsdbBridge) OvsdbPort(org.onosproject.ovsdb.controller.OvsdbPort) PortDescription(org.onosproject.net.device.PortDescription) OvsdbClientService(org.onosproject.ovsdb.controller.OvsdbClientService) DeviceId(org.onosproject.net.DeviceId) Collections(java.util.Collections) IpAddress(org.onlab.packet.IpAddress) BridgeConfig(org.onosproject.net.behaviour.BridgeConfig) OvsdbClientService(org.onosproject.ovsdb.controller.OvsdbClientService) DriverHandler(org.onosproject.net.driver.DriverHandler) OvsdbPort(org.onosproject.ovsdb.controller.OvsdbPort)

Example 5 with OvsdbPort

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

the class OvsdbBridgeConfig method getLocalPorts.

@Override
public List<PortNumber> getLocalPorts(Iterable<String> ifaceIds) {
    List<PortNumber> ports = new ArrayList<>();
    DriverHandler handler = handler();
    OvsdbClientService client = getOvsdbClientService(handler);
    if (client == null) {
        return Collections.emptyList();
    }
    Set<OvsdbPort> ovsdbSet = client.getLocalPorts(ifaceIds);
    ovsdbSet.forEach(o -> {
        PortNumber port = PortNumber.portNumber(o.portNumber().value(), o.portName().value());
        ports.add(port);
    });
    return ports;
}
Also used : OvsdbClientService(org.onosproject.ovsdb.controller.OvsdbClientService) ArrayList(java.util.ArrayList) DriverHandler(org.onosproject.net.driver.DriverHandler) PortNumber(org.onosproject.net.PortNumber) OvsdbPort(org.onosproject.ovsdb.controller.OvsdbPort)

Aggregations

OvsdbPort (org.onosproject.ovsdb.controller.OvsdbPort)6 OvsdbClientService (org.onosproject.ovsdb.controller.OvsdbClientService)4 ArrayList (java.util.ArrayList)3 Collection (java.util.Collection)3 List (java.util.List)3 Set (java.util.Set)3 Collectors (java.util.stream.Collectors)3 IpAddress (org.onlab.packet.IpAddress)3 DeviceId (org.onosproject.net.DeviceId)3 PortNumber (org.onosproject.net.PortNumber)3 BridgeConfig (org.onosproject.net.behaviour.BridgeConfig)3 BridgeDescription (org.onosproject.net.behaviour.BridgeDescription)3 BridgeName (org.onosproject.net.behaviour.BridgeName)3 DefaultBridgeDescription (org.onosproject.net.behaviour.DefaultBridgeDescription)3 OvsdbController (org.onosproject.ovsdb.controller.OvsdbController)3 Interface (org.onosproject.ovsdb.rfc.table.Interface)3 Collections (java.util.Collections)2 DefaultAnnotations (org.onosproject.net.DefaultAnnotations)2 DriverHandler (org.onosproject.net.driver.DriverHandler)2 Lists (com.google.common.collect.Lists)1