Search in sources :

Example 1 with BridgeDescription

use of org.onosproject.net.behaviour.BridgeDescription in project onos by opennetworkinglab.

the class DefaultOpenstackNodeHandler method cleanPhysicalInterfaces.

private void cleanPhysicalInterfaces(OpenstackNode osNode) {
    Device device = deviceService.getDevice(osNode.ovsdb());
    BridgeConfig bridgeConfig = device.as(BridgeConfig.class);
    Set<String> bridgeNames = bridgeConfig.getBridges().stream().map(BridgeDescription::name).collect(Collectors.toSet());
    Set<String> phyNetworkNames = osNode.phyIntfs().stream().map(pi -> BRIDGE_PREFIX + pi.network()).collect(Collectors.toSet());
    // we remove existing physical bridges and patch ports, if the physical
    // bridges are not defined in openstack node
    bridgeNames.forEach(brName -> {
        if (!phyNetworkNames.contains(brName) && !brName.equals(INTEGRATION_BRIDGE)) {
            removePhysicalPatchPorts(osNode, brName.substring(NETWORK_BEGIN));
            removePhysicalBridge(osNode, brName.substring(NETWORK_BEGIN));
        }
    });
}
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) Device(org.onosproject.net.Device) BridgeConfig(org.onosproject.net.behaviour.BridgeConfig)

Example 2 with BridgeDescription

use of org.onosproject.net.behaviour.BridgeDescription in project onos by opennetworkinglab.

the class DefaultKubevirtNodeHandler method cleanPhysicalInterfaces.

private void cleanPhysicalInterfaces(KubevirtNode node) {
    Device device = deviceService.getDevice(node.ovsdb());
    BridgeConfig bridgeConfig = device.as(BridgeConfig.class);
    Set<String> bridgeNames = bridgeConfig.getBridges().stream().map(BridgeDescription::name).collect(Collectors.toSet());
    Set<String> phyNetworkNames = node.phyIntfs().stream().map(pi -> BRIDGE_PREFIX + pi.network()).collect(Collectors.toSet());
    // bridges are not defined in kubevirt node
    for (String brName : bridgeNames) {
        // physical bridges
        if (brName.equals(INTEGRATION_BRIDGE) || brName.equals(TUNNEL_BRIDGE) || brName.startsWith(TENANT_BRIDGE_PREFIX)) {
            continue;
        }
        if (!phyNetworkNames.contains(brName)) {
            removePhysicalPatchPorts(node, brName.substring(NETWORK_BEGIN));
            removePhysicalBridge(node, brName.substring(NETWORK_BEGIN));
            log.info("Removing physical bridge {}...", brName);
        }
    }
}
Also used : INTEGRATION_BRIDGE(org.onosproject.kubevirtnode.api.Constants.INTEGRATION_BRIDGE) DefaultBridgeDescription(org.onosproject.net.behaviour.DefaultBridgeDescription) GRE(org.onosproject.kubevirtnode.api.Constants.GRE) GATEWAY(org.onosproject.kubevirtnode.api.KubevirtNode.Type.GATEWAY) CoreService(org.onosproject.core.CoreService) DeviceService(org.onosproject.net.device.DeviceService) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) KubevirtNodeUtil.getOvsdbClient(org.onosproject.kubevirtnode.util.KubevirtNodeUtil.getOvsdbClient) DEVICE_CREATED(org.onosproject.kubevirtnode.api.KubevirtNodeState.DEVICE_CREATED) TpPort.tpPort(org.onlab.packet.TpPort.tpPort) GENEVE(org.onosproject.kubevirtnode.api.Constants.GENEVE) FlowRuleService(org.onosproject.net.flow.FlowRuleService) OvsdbController(org.onosproject.ovsdb.controller.OvsdbController) AUTO_RECOVERY(org.onosproject.kubevirtnode.impl.OsgiPropertyConstants.AUTO_RECOVERY) Port(org.onosproject.net.Port) ApplicationId(org.onosproject.core.ApplicationId) Thread.sleep(java.lang.Thread.sleep) NodeId(org.onosproject.cluster.NodeId) Device(org.onosproject.net.Device) AUTO_RECOVERY_DEFAULT(org.onosproject.kubevirtnode.impl.OsgiPropertyConstants.AUTO_RECOVERY_DEFAULT) Deactivate(org.osgi.service.component.annotations.Deactivate) KubevirtNodeUtil.isOvsdbConnected(org.onosproject.kubevirtnode.util.KubevirtNodeUtil.isOvsdbConnected) BridgeName(org.onosproject.net.behaviour.BridgeName) Set(java.util.Set) Executors.newSingleThreadExecutor(java.util.concurrent.Executors.newSingleThreadExecutor) KubevirtPhyInterface(org.onosproject.kubevirtnode.api.KubevirtPhyInterface) Collectors(java.util.stream.Collectors) INTEGRATION_TO_TUNNEL(org.onosproject.kubevirtnode.api.Constants.INTEGRATION_TO_TUNNEL) OVSDB_PORT(org.onosproject.kubevirtnode.impl.OsgiPropertyConstants.OVSDB_PORT) DefaultPatchDescription(org.onosproject.net.behaviour.DefaultPatchDescription) Objects(java.util.Objects) KubevirtNodeAdminService(org.onosproject.kubevirtnode.api.KubevirtNodeAdminService) List(java.util.List) TunnelEndPoints(org.onosproject.net.behaviour.TunnelEndPoints) INIT(org.onosproject.kubevirtnode.api.KubevirtNodeState.INIT) DeviceEvent(org.onosproject.net.device.DeviceEvent) ClusterService(org.onosproject.cluster.ClusterService) KubevirtNodeState(org.onosproject.kubevirtnode.api.KubevirtNodeState) DeviceId(org.onosproject.net.DeviceId) Dictionary(java.util.Dictionary) BridgeConfig(org.onosproject.net.behaviour.BridgeConfig) InterfaceConfig(org.onosproject.net.behaviour.InterfaceConfig) KubevirtNodeUtil.resolveHostname(org.onosproject.kubevirtnode.util.KubevirtNodeUtil.resolveHostname) Tools(org.onlab.util.Tools) BridgeDescription(org.onosproject.net.behaviour.BridgeDescription) ComponentContext(org.osgi.service.component.ComponentContext) TUNNEL_BRIDGE(org.onosproject.kubevirtnode.api.Constants.TUNNEL_BRIDGE) PORT_NAME(org.onosproject.net.AnnotationKeys.PORT_NAME) TunnelKey(org.onosproject.net.behaviour.TunnelKey) APP_ID(org.onosproject.kubevirtnode.api.KubevirtNodeService.APP_ID) COMPLETE(org.onosproject.kubevirtnode.api.KubevirtNodeState.COMPLETE) INCOMPLETE(org.onosproject.kubevirtnode.api.KubevirtNodeState.INCOMPLETE) KubevirtNodeHandler(org.onosproject.kubevirtnode.api.KubevirtNodeHandler) PHYSICAL_TO_INTEGRATION_SUFFIX(org.onosproject.kubevirtnode.api.Constants.PHYSICAL_TO_INTEGRATION_SUFFIX) INTEGRATION_TO_PHYSICAL_PREFIX(org.onosproject.kubevirtnode.api.Constants.INTEGRATION_TO_PHYSICAL_PREFIX) KubevirtApiConfigService(org.onosproject.kubevirtnode.api.KubevirtApiConfigService) Component(org.osgi.service.component.annotations.Component) Lists(com.google.common.collect.Lists) DefaultTunnelDescription(org.onosproject.net.behaviour.DefaultTunnelDescription) TENANT_BRIDGE_PREFIX(org.onosproject.kubevirtnode.api.Constants.TENANT_BRIDGE_PREFIX) KubevirtNodeUtil.structurePortName(org.onosproject.kubevirtnode.util.KubevirtNodeUtil.structurePortName) Activate(org.osgi.service.component.annotations.Activate) ExecutorService(java.util.concurrent.ExecutorService) IpAddress(org.onlab.packet.IpAddress) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) KubevirtNode(org.onosproject.kubevirtnode.api.KubevirtNode) ControllerInfo(org.onosproject.net.behaviour.ControllerInfo) DeviceListener(org.onosproject.net.device.DeviceListener) Logger(org.slf4j.Logger) BRIDGE_PREFIX(org.onosproject.kubevirtnode.api.Constants.BRIDGE_PREFIX) PatchDescription(org.onosproject.net.behaviour.PatchDescription) TunnelDescription(org.onosproject.net.behaviour.TunnelDescription) FLOW_KEY(org.onosproject.kubevirtnode.api.Constants.FLOW_KEY) OVSDB_PORT_NUM_DEFAULT(org.onosproject.kubevirtnode.impl.OsgiPropertyConstants.OVSDB_PORT_NUM_DEFAULT) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) DeviceAdminService(org.onosproject.net.device.DeviceAdminService) KubevirtNodeEvent(org.onosproject.kubevirtnode.api.KubevirtNodeEvent) KubevirtNodeListener(org.onosproject.kubevirtnode.api.KubevirtNodeListener) Modified(org.osgi.service.component.annotations.Modified) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) OvsdbClientService(org.onosproject.ovsdb.controller.OvsdbClientService) TUNNEL_TO_INTEGRATION(org.onosproject.kubevirtnode.api.Constants.TUNNEL_TO_INTEGRATION) VXLAN(org.onosproject.kubevirtnode.api.Constants.VXLAN) Reference(org.osgi.service.component.annotations.Reference) KubevirtNodeUtil.addOrRemoveSystemInterface(org.onosproject.kubevirtnode.util.KubevirtNodeUtil.addOrRemoveSystemInterface) LeadershipService(org.onosproject.cluster.LeadershipService) KubevirtNodeUtil.getBooleanProperty(org.onosproject.kubevirtnode.util.KubevirtNodeUtil.getBooleanProperty) Device(org.onosproject.net.Device) BridgeConfig(org.onosproject.net.behaviour.BridgeConfig)

Example 3 with BridgeDescription

use of org.onosproject.net.behaviour.BridgeDescription in project onos by opennetworkinglab.

the class OvsdbBridgeConfig method getBridges.

@Override
public Collection<BridgeDescription> getBridges() {
    OvsdbClientService client = getOvsdbClientService(handler());
    if (client == null) {
        return Collections.emptyList();
    }
    Set<OvsdbBridge> bridges = client.getBridges();
    return bridges.stream().map(bridge -> DefaultBridgeDescription.builder().name(bridge.name()).datapathId(bridge.datapathId().get()).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) OvsdbBridge(org.onosproject.ovsdb.controller.OvsdbBridge)

Aggregations

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 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 Lists (com.google.common.collect.Lists)2 Collection (java.util.Collection)2 Dictionary (java.util.Dictionary)2 Objects (java.util.Objects)2 ExecutorService (java.util.concurrent.ExecutorService)2 Executors.newSingleThreadExecutor (java.util.concurrent.Executors.newSingleThreadExecutor)2 TpPort.tpPort (org.onlab.packet.TpPort.tpPort)2 Tools (org.onlab.util.Tools)2 Tools.groupedThreads (org.onlab.util.Tools.groupedThreads)2 ComponentConfigService (org.onosproject.cfg.ComponentConfigService)2 ClusterService (org.onosproject.cluster.ClusterService)2