Search in sources :

Example 1 with INTEGRATION_BRIDGE

use of org.onosproject.openstacknode.api.Constants.INTEGRATION_BRIDGE 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 INTEGRATION_BRIDGE

use of org.onosproject.openstacknode.api.Constants.INTEGRATION_BRIDGE in project onos by opennetworkinglab.

the class OpenstackRecoverPortsCommand method recoverOvsPort.

/**
 * Recovers the openvswitch port from conf.db corruption.
 *
 * @param controller    ovsdb controller
 * @param ovsdbPort     ovsdb port number
 * @param node          openstack node
 * @param osPort        an openstack port
 * @param ovsPorts      set of openvswitch ports
 *
 * @return a set of recovered port name
 */
private Set<String> recoverOvsPort(OvsdbController controller, int ovsdbPort, OpenstackNode node, Port osPort, List<org.onosproject.net.Port> ovsPorts) {
    OvsdbClientService client = getOvsdbClient(node, ovsdbPort, controller);
    if (client == null) {
        return ImmutableSet.of();
    }
    Set<String> portNames = ovsPorts.stream().filter(ovsPort -> ovsPort.annotations() != null || ovsPort.annotations().keys().contains(PORT_NAME)).map(ovsPort -> ovsPort.annotations().value(PORT_NAME)).collect(Collectors.toSet());
    String tapPort = ifaceNameFromOsPortId(osPort.getId());
    Set<String> recoveredPortNames = Sets.newConcurrentHashSet();
    if (!portNames.contains(tapPort)) {
        Map<String, String> extIdMap = ImmutableMap.of(ATTACHED_MAC, osPort.getMacAddress(), IFACE_ID, osPort.getId(), IFACE_STATUS, StringUtils.lowerCase(osPort.getState().name()), VM_ID, osPort.getDeviceId());
        OvsdbInterface ovsIface = OvsdbInterface.builder().name(tapPort).options(ImmutableMap.of()).data(ImmutableMap.of(EXTERNALIDS, extIdMap)).build();
        client.createInterface(INTEGRATION_BRIDGE, ovsIface);
        recoveredPortNames.add(tapPort);
    }
    return ImmutableSet.copyOf(recoveredPortNames);
}
Also used : EXTERNALIDS(org.onosproject.ovsdb.rfc.table.Interface.InterfaceColumn.EXTERNALIDS) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) DeviceService(org.onosproject.net.device.DeviceService) INTEGRATION_BRIDGE(org.onosproject.openstacknode.api.Constants.INTEGRATION_BRIDGE) StringUtils(org.apache.commons.lang3.StringUtils) Command(org.apache.karaf.shell.api.action.Command) OpenstackNetworkService(org.onosproject.openstacknetworking.api.OpenstackNetworkService) OvsdbController(org.onosproject.ovsdb.controller.OvsdbController) Map(java.util.Map) OvsdbInterface(org.onosproject.ovsdb.controller.OvsdbInterface) OpenstackNetworkingUtil.ifaceNameFromOsPortId(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.ifaceNameFromOsPortId) Port(org.openstack4j.model.network.Port) OpenstackNodeService(org.onosproject.openstacknode.api.OpenstackNodeService) ImmutableSet(com.google.common.collect.ImmutableSet) OpenstackNetworkingUtil.getOvsdbClient(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.getOvsdbClient) ImmutableMap(com.google.common.collect.ImmutableMap) Set(java.util.Set) Argument(org.apache.karaf.shell.api.action.Argument) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) AbstractShellCommand(org.onosproject.cli.AbstractShellCommand) List(java.util.List) Service(org.apache.karaf.shell.api.action.lifecycle.Service) Completion(org.apache.karaf.shell.api.action.Completion) OvsdbClientService(org.onosproject.ovsdb.controller.OvsdbClientService) Option(org.apache.karaf.shell.api.action.Option) OvsdbInterface(org.onosproject.ovsdb.controller.OvsdbInterface) OvsdbClientService(org.onosproject.ovsdb.controller.OvsdbClientService)

Aggregations

List (java.util.List)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Lists (com.google.common.collect.Lists)1 Sets (com.google.common.collect.Sets)1 Collection (java.util.Collection)1 Dictionary (java.util.Dictionary)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 ExecutorService (java.util.concurrent.ExecutorService)1 Executors.newSingleThreadExecutor (java.util.concurrent.Executors.newSingleThreadExecutor)1 StringUtils (org.apache.commons.lang3.StringUtils)1 Argument (org.apache.karaf.shell.api.action.Argument)1 Command (org.apache.karaf.shell.api.action.Command)1 Completion (org.apache.karaf.shell.api.action.Completion)1 Option (org.apache.karaf.shell.api.action.Option)1 Service (org.apache.karaf.shell.api.action.lifecycle.Service)1