Search in sources :

Example 6 with COMPUTE

use of org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE in project onos by opennetworkinglab.

the class OpenstackDirectPortAddCommand method doExecute.

@Override
protected void doExecute() {
    OpenstackNetworkService osNetService = get(OpenstackNetworkService.class);
    OpenstackNodeService osNodeService = get(OpenstackNodeService.class);
    DeviceService deviceService = get(DeviceService.class);
    Port port = osNetService.port(portId);
    if (port == null) {
        log.error("There's no port that matches the port ID {}", portId);
        return;
    }
    Optional<OpenstackNode> osNode = osNodeService.completeNodes(COMPUTE).stream().filter(node -> node.hostname().equals(port.getHostId())).findAny();
    if (!osNode.isPresent()) {
        log.error("There's no openstackNode that matches hostname {}", port.getHostId());
        return;
    }
    String intfName = getIntfNameFromPciAddress(port);
    if (intfName == null) {
        log.error("Failed to retrieve interface name from a port {}", portId);
        return;
    } else if (intfName.equals(UNSUPPORTED_VENDOR)) {
        return;
    }
    if (OpenstackNetworkingUtil.hasIntfAleadyInDevice(osNode.get().intgBridge(), intfName, deviceService)) {
        log.error("Interface {} is already added to the device {}", osNode.get().intgBridge());
        return;
    }
    log.info("Adding interface {} to the device {}..", intfName, osNode.get().intgBridge());
    osNodeService.addVfPort(osNode.get(), intfName);
}
Also used : UNSUPPORTED_VENDOR(org.onosproject.openstacknetworking.api.Constants.UNSUPPORTED_VENDOR) OpenstackNodeService(org.onosproject.openstacknode.api.OpenstackNodeService) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) OpenstackNetworkingUtil.getIntfNameFromPciAddress(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.getIntfNameFromPciAddress) COMPUTE(org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE) OpenstackNetworkingUtil(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil) DeviceService(org.onosproject.net.device.DeviceService) Argument(org.apache.karaf.shell.api.action.Argument) AbstractShellCommand.get(org.onosproject.cli.AbstractShellCommand.get) Command(org.apache.karaf.shell.api.action.Command) AbstractShellCommand(org.onosproject.cli.AbstractShellCommand) OpenstackNetworkService(org.onosproject.openstacknetworking.api.OpenstackNetworkService) Service(org.apache.karaf.shell.api.action.lifecycle.Service) Optional(java.util.Optional) Completion(org.apache.karaf.shell.api.action.Completion) Port(org.openstack4j.model.network.Port) OpenstackNodeService(org.onosproject.openstacknode.api.OpenstackNodeService) OpenstackNetworkService(org.onosproject.openstacknetworking.api.OpenstackNetworkService) Port(org.openstack4j.model.network.Port) DeviceService(org.onosproject.net.device.DeviceService) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode)

Example 7 with COMPUTE

use of org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE in project onos by opennetworkinglab.

the class OpenstackSwitchingHandler method setForwardingRulesForTunnel.

/**
 * Configures the flow rules which are used for L2 packet switching.
 * Note that these rules will be inserted in switching table (table 5).
 *
 * @param instPort instance port object
 * @param install install flag, add the rule if true, remove it otherwise
 */
private void setForwardingRulesForTunnel(InstancePort instPort, boolean install) {
    // switching rules for the instPorts in the same node
    TrafficSelector selector = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPDst(instPort.ipAddress().toIpPrefix()).matchTunnelId(getVni(instPort)).build();
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().setEthDst(instPort.macAddress()).setOutput(instPort.portNumber()).build();
    osFlowRuleService.setRule(appId, instPort.deviceId(), selector, treatment, PRIORITY_SWITCHING_RULE, FORWARDING_TABLE, install);
    // switching rules for the instPorts in the remote node
    OpenstackNode localNode = osNodeService.node(instPort.deviceId());
    if (localNode == null) {
        final String error = String.format("Cannot find openstack node for %s", instPort.deviceId());
        throw new IllegalStateException(error);
    }
    osNodeService.completeNodes(COMPUTE).stream().filter(remoteNode -> !remoteNode.intgBridge().equals(localNode.intgBridge())).forEach(remoteNode -> {
        PortNumber portNum = tunnelPortNumByNetId(instPort.networkId(), osNetworkService, remoteNode);
        TrafficTreatment treatmentToRemote = DefaultTrafficTreatment.builder().extension(buildExtension(deviceService, remoteNode.intgBridge(), localNode.dataIp().getIp4Address()), remoteNode.intgBridge()).setOutput(portNum).build();
        osFlowRuleService.setRule(appId, remoteNode.intgBridge(), selector, treatmentToRemote, PRIORITY_SWITCHING_RULE, FORWARDING_TABLE, install);
    });
}
Also used : CoreService(org.onosproject.core.CoreService) InstancePort(org.onosproject.openstacknetworking.api.InstancePort) PortNumber(org.onosproject.net.PortNumber) DeviceService(org.onosproject.net.device.DeviceService) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) OpenstackNetworkListener(org.onosproject.openstacknetworking.api.OpenstackNetworkListener) InstancePortEvent(org.onosproject.openstacknetworking.api.InstancePortEvent) OPENSTACK_INSTANCE_MIGRATION_STARTED(org.onosproject.openstacknetworking.api.InstancePortEvent.Type.OPENSTACK_INSTANCE_MIGRATION_STARTED) DriverService(org.onosproject.net.driver.DriverService) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) Ethernet(org.onlab.packet.Ethernet) PRIORITY_TUNNEL_TAG_RULE(org.onosproject.openstacknetworking.api.Constants.PRIORITY_TUNNEL_TAG_RULE) Type(org.onosproject.openstacknetworking.api.OpenstackNetwork.Type) ApplicationId(org.onosproject.core.ApplicationId) OpenstackNetworkEvent(org.onosproject.openstacknetworking.api.OpenstackNetworkEvent) MastershipService(org.onosproject.mastership.MastershipService) ACL_EGRESS_TABLE(org.onosproject.openstacknetworking.api.Constants.ACL_EGRESS_TABLE) NodeId(org.onosproject.cluster.NodeId) OpenstackNodeService(org.onosproject.openstacknode.api.OpenstackNodeService) OpenstackFlowRuleService(org.onosproject.openstacknetworking.api.OpenstackFlowRuleService) Deactivate(org.osgi.service.component.annotations.Deactivate) Set(java.util.Set) PRIORITY_ADMIN_RULE(org.onosproject.openstacknetworking.api.Constants.PRIORITY_ADMIN_RULE) Executors.newSingleThreadExecutor(java.util.concurrent.Executors.newSingleThreadExecutor) InstancePortListener(org.onosproject.openstacknetworking.api.InstancePortListener) Objects(java.util.Objects) OPENSTACK_NETWORKING_APP_ID(org.onosproject.openstacknetworking.api.Constants.OPENSTACK_NETWORKING_APP_ID) OpenstackNetworkingUtil.swapStaleLocation(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.swapStaleLocation) ClusterService(org.onosproject.cluster.ClusterService) OpenstackNetworkingUtil.tunnelPortNumByNetId(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.tunnelPortNumByNetId) PRE_FLAT_TABLE(org.onosproject.openstacknetworking.api.Constants.PRE_FLAT_TABLE) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) Network(org.openstack4j.model.network.Network) COMPUTE(org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE) RulePopulatorUtil.buildExtension(org.onosproject.openstacknetworking.util.RulePopulatorUtil.buildExtension) Strings(com.google.common.base.Strings) OpenstackNetworkService(org.onosproject.openstacknetworking.api.OpenstackNetworkService) Component(org.osgi.service.component.annotations.Component) TrafficSelector(org.onosproject.net.flow.TrafficSelector) Activate(org.osgi.service.component.annotations.Activate) ARP_TABLE(org.onosproject.openstacknetworking.api.Constants.ARP_TABLE) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) ExecutorService(java.util.concurrent.ExecutorService) Port(org.openstack4j.model.network.Port) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) FORWARDING_TABLE(org.onosproject.openstacknetworking.api.Constants.FORWARDING_TABLE) Logger(org.slf4j.Logger) VlanId(org.onlab.packet.VlanId) PRIORITY_SWITCHING_RULE(org.onosproject.openstacknetworking.api.Constants.PRIORITY_SWITCHING_RULE) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) OpenstackNetworkingUtil.getPropertyValue(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.getPropertyValue) ConfigProperty(org.onosproject.cfg.ConfigProperty) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) OpenstackNetworkingUtil.deriveResourceName(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.deriveResourceName) Reference(org.osgi.service.component.annotations.Reference) LeadershipService(org.onosproject.cluster.LeadershipService) VTAG_TABLE(org.onosproject.openstacknetworking.api.Constants.VTAG_TABLE) InstancePortService(org.onosproject.openstacknetworking.api.InstancePortService) ARP_BROADCAST_MODE(org.onosproject.openstacknetworking.api.Constants.ARP_BROADCAST_MODE) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) PortNumber(org.onosproject.net.PortNumber)

Example 8 with COMPUTE

use of org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE in project onos by opennetworkinglab.

the class OpenstackSwitchingIcmpHandler method processRouterIntfEvent.

private void processRouterIntfEvent(Router osRouter, RouterInterface routerIface, boolean install) {
    if (!getStatefulSnatFlag()) {
        return;
    }
    Subnet osSubnet = osNetworkService.subnet(routerIface.getSubnetId());
    Type netType = osNetworkService.networkType(osSubnet.getNetworkId());
    String segId = osNetworkService.segmentId(osSubnet.getNetworkId());
    IpAddress gatewayIp = IpAddress.valueOf(osSubnet.getGateway());
    Set<Subnet> routableSubnets = routableSubnets(osRouter, osSubnet.getId());
    osNodeService.completeNodes(COMPUTE).stream().filter(cNode -> cNode.dataIp() != null).forEach(cNode -> {
        setRoutableSubnetsIcmpRules(cNode, segId, osSubnet, routableSubnets, gatewayIp, netType, install);
    });
}
Also used : OpenstackRouterService(org.onosproject.openstacknetworking.api.OpenstackRouterService) CoreService(org.onosproject.core.CoreService) PortNumber(org.onosproject.net.PortNumber) DeviceService(org.onosproject.net.device.DeviceService) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) OpenstackNetworkingUtil.externalGatewayIp(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.externalGatewayIp) NXM_OF_ICMP_TYPE(org.onosproject.openstacknetworking.util.RulePopulatorUtil.NXM_OF_ICMP_TYPE) DriverService(org.onosproject.net.driver.DriverService) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) Ethernet(org.onlab.packet.Ethernet) OpenstackNodeListener(org.onosproject.openstacknode.api.OpenstackNodeListener) Type(org.onosproject.openstacknetworking.api.OpenstackNetwork.Type) ApplicationId(org.onosproject.core.ApplicationId) TYPE_ECHO_REPLY(org.onlab.packet.ICMP.TYPE_ECHO_REPLY) RulePopulatorUtil.buildMoveEthSrcToDstExtension(org.onosproject.openstacknetworking.util.RulePopulatorUtil.buildMoveEthSrcToDstExtension) MastershipService(org.onosproject.mastership.MastershipService) NodeId(org.onosproject.cluster.NodeId) PRIORITY_ICMP_RULE(org.onosproject.openstacknetworking.api.Constants.PRIORITY_ICMP_RULE) OpenstackNodeService(org.onosproject.openstacknode.api.OpenstackNodeService) ImmutableSet(com.google.common.collect.ImmutableSet) NXM_NX_IP_TTL(org.onosproject.openstacknetworking.util.RulePopulatorUtil.NXM_NX_IP_TTL) Device(org.onosproject.net.Device) OpenstackFlowRuleService(org.onosproject.openstacknetworking.api.OpenstackFlowRuleService) Deactivate(org.osgi.service.component.annotations.Deactivate) Set(java.util.Set) Executors.newSingleThreadExecutor(java.util.concurrent.Executors.newSingleThreadExecutor) USE_STATEFUL_SNAT(org.onosproject.openstacknetworking.impl.OsgiPropertyConstants.USE_STATEFUL_SNAT) Collectors(java.util.stream.Collectors) OpenstackNetworkingUtil.getPropertyValueAsBoolean(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.getPropertyValueAsBoolean) Objects(java.util.Objects) OPENSTACK_NETWORKING_APP_ID(org.onosproject.openstacknetworking.api.Constants.OPENSTACK_NETWORKING_APP_ID) ClusterService(org.onosproject.cluster.ClusterService) ROUTING_TABLE(org.onosproject.openstacknetworking.api.Constants.ROUTING_TABLE) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) Network(org.openstack4j.model.network.Network) COMPUTE(org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE) TYPE_ECHO_REQUEST(org.onlab.packet.ICMP.TYPE_ECHO_REQUEST) RouterInterface(org.openstack4j.model.network.RouterInterface) OpenstackRouterEvent(org.onosproject.openstacknetworking.api.OpenstackRouterEvent) OpenstackNetworkService(org.onosproject.openstacknetworking.api.OpenstackNetworkService) Component(org.osgi.service.component.annotations.Component) TrafficSelector(org.onosproject.net.flow.TrafficSelector) CODE_ECHO_REQEUST(org.onlab.packet.ICMP.CODE_ECHO_REQEUST) Router(org.openstack4j.model.network.Router) Activate(org.osgi.service.component.annotations.Activate) DEFAULT_GATEWAY_MAC(org.onosproject.openstacknetworking.api.Constants.DEFAULT_GATEWAY_MAC) RulePopulatorUtil.buildMoveIpSrcToDstExtension(org.onosproject.openstacknetworking.util.RulePopulatorUtil.buildMoveIpSrcToDstExtension) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) ExecutorService(java.util.concurrent.ExecutorService) IpAddress(org.onlab.packet.IpAddress) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Logger(org.slf4j.Logger) VlanId(org.onlab.packet.VlanId) Subnet(org.openstack4j.model.network.Subnet) RulePopulatorUtil.buildLoadExtension(org.onosproject.openstacknetworking.util.RulePopulatorUtil.buildLoadExtension) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) IPv4(org.onlab.packet.IPv4) OpenstackRouterListener(org.onosproject.openstacknetworking.api.OpenstackRouterListener) OpenstackNodeEvent(org.onosproject.openstacknode.api.OpenstackNodeEvent) ConfigProperty(org.onosproject.cfg.ConfigProperty) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) Reference(org.osgi.service.component.annotations.Reference) LeadershipService(org.onosproject.cluster.LeadershipService) Type(org.onosproject.openstacknetworking.api.OpenstackNetwork.Type) IpAddress(org.onlab.packet.IpAddress) Subnet(org.openstack4j.model.network.Subnet)

Example 9 with COMPUTE

use of org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE in project onos by opennetworkinglab.

the class OpenstackVtapManager method purgeVtap.

/**
 * Purges all flow rules and group tables, tunneling interface for openstack vtap.
 */
@Override
public void purgeVtap() {
    // Remove all flow rules
    flowRuleService.removeFlowRulesById(appId);
    // Remove all groups and tunnel interfaces
    osNodeService.completeNodes(COMPUTE).stream().filter(osNode -> osNode.state() == COMPLETE).forEach(osNode -> {
        groupService.getGroups(osNode.intgBridge(), appId).forEach(group -> groupService.removeGroup(osNode.intgBridge(), group.appCookie(), appId));
        OpenstackVtapNetwork vtapNetwork = getVtapNetwork();
        setTunnelInterface(osNode, vtapNetwork, false);
    });
    log.trace("{} all flow rules, groups, tunnel interface are purged", appId.name());
}
Also used : DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) PortNumber(org.onosproject.net.PortNumber) DeviceService(org.onosproject.net.device.DeviceService) OpenstackVtapUtil.getTunnelName(org.onosproject.openstackvtap.util.OpenstackVtapUtil.getTunnelName) COMPLETE(org.onosproject.openstacknode.api.NodeState.COMPLETE) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) VTAP_INBOUND_MIRROR_TABLE(org.onosproject.openstacknetworking.api.Constants.VTAP_INBOUND_MIRROR_TABLE) Executors.newSingleThreadScheduledExecutor(java.util.concurrent.Executors.newSingleThreadScheduledExecutor) FlowRuleService(org.onosproject.net.flow.FlowRuleService) Port(org.onosproject.net.Port) ApplicationId(org.onosproject.core.ApplicationId) PROTOCOL_UDP(org.onlab.packet.IPv4.PROTOCOL_UDP) OpenstackVtapUtil.isValidHost(org.onosproject.openstackvtap.util.OpenstackVtapUtil.isValidHost) VTAP_INBOUND_GROUP_TABLE(org.onosproject.openstacknetworking.api.Constants.VTAP_INBOUND_GROUP_TABLE) OpenstackNodeService(org.onosproject.openstacknode.api.OpenstackNodeService) OpenstackVtapUtil.getGroupKey(org.onosproject.openstackvtap.util.OpenstackVtapUtil.getGroupKey) Deactivate(org.osgi.service.component.annotations.Deactivate) Set(java.util.Set) Type(org.onosproject.openstackvtap.api.OpenstackVtap.Type) VTAP_OUTBOUND_MIRROR_TABLE(org.onosproject.openstacknetworking.api.Constants.VTAP_OUTBOUND_MIRROR_TABLE) GroupBuckets(org.onosproject.net.group.GroupBuckets) DeviceEvent(org.onosproject.net.device.DeviceEvent) DeviceId(org.onosproject.net.DeviceId) GroupDescription(org.onosproject.net.group.GroupDescription) Dictionary(java.util.Dictionary) VTAP_OUTBOUND_GROUP_TABLE(org.onosproject.openstacknetworking.api.Constants.VTAP_OUTBOUND_GROUP_TABLE) FlowRuleOperationsContext(org.onosproject.net.flow.FlowRuleOperationsContext) Tools(org.onlab.util.Tools) Host(org.onosproject.net.Host) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) OpenstackVtap(org.onosproject.openstackvtap.api.OpenstackVtap) ComponentContext(org.osgi.service.component.ComponentContext) PORT_NAME(org.onosproject.net.AnnotationKeys.PORT_NAME) HostListener(org.onosproject.net.host.HostListener) TUNNEL_NICIRA(org.onosproject.openstackvtap.impl.OsgiPropertyConstants.TUNNEL_NICIRA) HostService(org.onosproject.net.host.HostService) VTAP_INBOUND_TABLE(org.onosproject.openstacknetworking.api.Constants.VTAP_INBOUND_TABLE) Component(org.osgi.service.component.annotations.Component) Lists(com.google.common.collect.Lists) TrafficSelector(org.onosproject.net.flow.TrafficSelector) OpenstackVtapEvent(org.onosproject.openstackvtap.api.OpenstackVtapEvent) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) OpenstackVtapStore(org.onosproject.openstackvtap.api.OpenstackVtapStore) StreamSupport(java.util.stream.StreamSupport) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) ExtensionTreatmentResolver(org.onosproject.net.behaviour.ExtensionTreatmentResolver) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) FlowRuleOperations(org.onosproject.net.flow.FlowRuleOperations) DeviceListener(org.onosproject.net.device.DeviceListener) PROTOCOL_ICMP(org.onlab.packet.IPv4.PROTOCOL_ICMP) GroupService(org.onosproject.net.group.GroupService) GroupId(org.onosproject.core.GroupId) LeadershipService(org.onosproject.cluster.LeadershipService) OpenstackVtapUtil.hostCompareIp(org.onosproject.openstackvtap.util.OpenstackVtapUtil.hostCompareIp) HostLocation(org.onosproject.net.HostLocation) CoreService(org.onosproject.core.CoreService) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) VTAP_FLAT_OUTBOUND_GROUP_TABLE(org.onosproject.openstacknetworking.api.Constants.VTAP_FLAT_OUTBOUND_GROUP_TABLE) INTEGRATION_BRIDGE(org.onosproject.openstacknode.api.Constants.INTEGRATION_BRIDGE) OpenstackNodeListener(org.onosproject.openstacknode.api.OpenstackNodeListener) Mode(org.onosproject.openstackvtap.api.OpenstackVtapNetwork.Mode) OpenstackVtapUtil.dumpStackTrace(org.onosproject.openstackvtap.util.OpenstackVtapUtil.dumpStackTrace) TYPE_IPV4(org.onlab.packet.Ethernet.TYPE_IPV4) TUNNEL_NICRA_DEFAULT(org.onosproject.openstackvtap.impl.OsgiPropertyConstants.TUNNEL_NICRA_DEFAULT) NodeId(org.onosproject.cluster.NodeId) ImmutableSet(com.google.common.collect.ImmutableSet) AbstractListenerManager(org.onosproject.event.AbstractListenerManager) Device(org.onosproject.net.Device) DHCP_TABLE(org.onosproject.openstacknetworking.api.Constants.DHCP_TABLE) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) NICIRA_RESUBMIT_TABLE(org.onosproject.net.flow.instructions.ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_RESUBMIT_TABLE) VTAP_OUTBOUND_TABLE(org.onosproject.openstacknetworking.api.Constants.VTAP_OUTBOUND_TABLE) Objects(java.util.Objects) NICIRA_SET_TUNNEL_DST(org.onosproject.net.flow.instructions.ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_TUNNEL_DST) List(java.util.List) TunnelEndPoints(org.onosproject.net.behaviour.TunnelEndPoints) OpenstackVtapUtil.containsIp(org.onosproject.openstackvtap.util.OpenstackVtapUtil.containsIp) FLAT_TABLE(org.onosproject.openstacknetworking.api.Constants.FLAT_TABLE) FlowRule(org.onosproject.net.flow.FlowRule) ClusterService(org.onosproject.cluster.ClusterService) OpenstackVtapId(org.onosproject.openstackvtap.api.OpenstackVtapId) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) IpPrefix(org.onlab.packet.IpPrefix) InterfaceConfig(org.onosproject.net.behaviour.InterfaceConfig) OpenstackVtapListener(org.onosproject.openstackvtap.api.OpenstackVtapListener) COMPUTE(org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE) TunnelKey(org.onosproject.net.behaviour.TunnelKey) GroupBucket(org.onosproject.net.group.GroupBucket) VTAP_FLAT_OUTBOUND_TABLE(org.onosproject.openstacknetworking.api.Constants.VTAP_FLAT_OUTBOUND_TABLE) ExtensionPropertyException(org.onosproject.net.flow.instructions.ExtensionPropertyException) DefaultTunnelDescription(org.onosproject.net.behaviour.DefaultTunnelDescription) OpenstackVtapStoreDelegate(org.onosproject.openstackvtap.api.OpenstackVtapStoreDelegate) ImmutableList(com.google.common.collect.ImmutableList) OpenstackVtapAdminService(org.onosproject.openstackvtap.api.OpenstackVtapAdminService) HostEvent(org.onosproject.net.host.HostEvent) Activate(org.osgi.service.component.annotations.Activate) VTAP_FLAT_OUTBOUND_MIRROR_TABLE(org.onosproject.openstacknetworking.api.Constants.VTAP_FLAT_OUTBOUND_MIRROR_TABLE) IpAddress(org.onlab.packet.IpAddress) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) FORWARDING_TABLE(org.onosproject.openstacknetworking.api.Constants.FORWARDING_TABLE) Logger(org.slf4j.Logger) OpenstackVtapService(org.onosproject.openstackvtap.api.OpenstackVtapService) TunnelDescription(org.onosproject.net.behaviour.TunnelDescription) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) ExtensionTreatment(org.onosproject.net.flow.instructions.ExtensionTreatment) DefaultGroupBucket(org.onosproject.net.group.DefaultGroupBucket) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) OpenstackNodeEvent(org.onosproject.openstacknode.api.OpenstackNodeEvent) OpenstackVtapCriterion(org.onosproject.openstackvtap.api.OpenstackVtapCriterion) Modified(org.osgi.service.component.annotations.Modified) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) OpenstackVtapNetwork(org.onosproject.openstackvtap.api.OpenstackVtapNetwork) PROTOCOL_TCP(org.onlab.packet.IPv4.PROTOCOL_TCP) Reference(org.osgi.service.component.annotations.Reference) OpenstackVtapUtil.getTunnelType(org.onosproject.openstackvtap.util.OpenstackVtapUtil.getTunnelType) OpenstackVtapNetwork(org.onosproject.openstackvtap.api.OpenstackVtapNetwork)

Example 10 with COMPUTE

use of org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE in project onos by opennetworkinglab.

the class OpenstackEastWestProbeCommand method doExecute.

@Override
protected void doExecute() {
    OpenstackTroubleshootService tsService = get(OpenstackTroubleshootService.class);
    InstancePortService instPortService = get(InstancePortService.class);
    MastershipService mastershipService = get(MastershipService.class);
    ClusterService clusterService = get(ClusterService.class);
    OpenstackNodeService osNodeService = get(OpenstackNodeService.class);
    if (tsService == null) {
        error("Failed to troubleshoot openstack networking.");
        return;
    }
    if ((!isAll && vmIps == null) || (isAll && vmIps != null)) {
        print("Please specify one of VM IP address or -a option.");
        return;
    }
    NodeId localNodeId = clusterService.getLocalNode().id();
    for (OpenstackNode node : osNodeService.completeNodes(COMPUTE)) {
        if (!localNodeId.equals(mastershipService.getMasterFor(node.intgBridge()))) {
            error("Current node is not the master for all compute nodes. " + "Please enforce mastership first using openstack-reset-mastership -c !");
            return;
        }
    }
    if (isAll) {
        printHeader();
        // send ICMP PACKET_OUT to all connect VMs whose instance port state is ACTIVE
        Set<InstancePort> activePorts = instPortService.instancePorts().stream().filter(p -> p.state() == ACTIVE).collect(Collectors.toSet());
        activePorts.forEach(srcPort -> activePorts.forEach(dstPort -> printReachability(tsService.probeEastWest(srcPort, dstPort))));
    } else {
        if (vmIps.length > 2) {
            print("Too many VM IPs. The number of IP should be limited to 2.");
            return;
        }
        IpAddress srcIp = getIpAddress(vmIps[0]);
        if (srcIp == null) {
            return;
        }
        InstancePort srcPort = instPort(instPortService, srcIp);
        if (srcPort == null) {
            print("Specified source IP is not existing.");
            return;
        }
        final Set<IpAddress> dstIps = Sets.newConcurrentHashSet();
        if (vmIps.length == 2) {
            IpAddress dstIp = getIpAddress(vmIps[1]);
            if (dstIp == null) {
                return;
            }
            dstIps.add(dstIp);
        }
        if (vmIps.length == 1) {
            dstIps.addAll(instPortService.instancePorts().stream().filter(p -> !p.ipAddress().equals(srcIp)).filter(p -> p.state().equals(InstancePort.State.ACTIVE)).map(InstancePort::ipAddress).collect(Collectors.toSet()));
        }
        printHeader();
        dstIps.stream().filter(ip -> instPort(instPortService, ip) != null).map(ip -> instPort(instPortService, ip)).forEach(port -> probeExecutor.execute(() -> printReachability(tsService.probeEastWest(srcPort, port))));
    }
}
Also used : OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) COMPUTE(org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE) InstancePort(org.onosproject.openstacknetworking.api.InstancePort) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) Command(org.apache.karaf.shell.api.action.Command) OpenstackTroubleshootService(org.onosproject.openstacktroubleshoot.api.OpenstackTroubleshootService) Executors.newSingleThreadScheduledExecutor(java.util.concurrent.Executors.newSingleThreadScheduledExecutor) MastershipService(org.onosproject.mastership.MastershipService) ExecutorService(java.util.concurrent.ExecutorService) IpAddress(org.onlab.packet.IpAddress) NodeId(org.onosproject.cluster.NodeId) OpenstackNodeService(org.onosproject.openstacknode.api.OpenstackNodeService) ACTIVE(org.onosproject.openstacknetworking.api.InstancePort.State.ACTIVE) 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) Reachability(org.onosproject.openstacktroubleshoot.api.Reachability) Service(org.apache.karaf.shell.api.action.lifecycle.Service) Optional(java.util.Optional) Completion(org.apache.karaf.shell.api.action.Completion) ClusterService(org.onosproject.cluster.ClusterService) Option(org.apache.karaf.shell.api.action.Option) InstancePortService(org.onosproject.openstacknetworking.api.InstancePortService) OpenstackNodeService(org.onosproject.openstacknode.api.OpenstackNodeService) ClusterService(org.onosproject.cluster.ClusterService) OpenstackTroubleshootService(org.onosproject.openstacktroubleshoot.api.OpenstackTroubleshootService) InstancePortService(org.onosproject.openstacknetworking.api.InstancePortService) InstancePort(org.onosproject.openstacknetworking.api.InstancePort) NodeId(org.onosproject.cluster.NodeId) MastershipService(org.onosproject.mastership.MastershipService) IpAddress(org.onlab.packet.IpAddress) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode)

Aggregations

OpenstackNode (org.onosproject.openstacknode.api.OpenstackNode)10 COMPUTE (org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE)10 OpenstackNodeService (org.onosproject.openstacknode.api.OpenstackNodeService)10 Set (java.util.Set)9 DeviceService (org.onosproject.net.device.DeviceService)9 Tools.groupedThreads (org.onlab.util.Tools.groupedThreads)8 ComponentConfigService (org.onosproject.cfg.ComponentConfigService)8 ClusterService (org.onosproject.cluster.ClusterService)8 NodeId (org.onosproject.cluster.NodeId)8 ApplicationId (org.onosproject.core.ApplicationId)8 CoreService (org.onosproject.core.CoreService)8 PortNumber (org.onosproject.net.PortNumber)8 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)8 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)8 TrafficSelector (org.onosproject.net.flow.TrafficSelector)8 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)8 Activate (org.osgi.service.component.annotations.Activate)8 Component (org.osgi.service.component.annotations.Component)8 Deactivate (org.osgi.service.component.annotations.Deactivate)8 Reference (org.osgi.service.component.annotations.Reference)8