Search in sources :

Example 36 with InstancePort

use of org.onosproject.openstacknetworking.api.InstancePort in project onos by opennetworkinglab.

the class OpenstackNorthSouthProbeCommand method doExecute.

@Override
protected void doExecute() {
    OpenstackTroubleshootService tsService = get(OpenstackTroubleshootService.class);
    InstancePortService instPortService = get(InstancePortService.class);
    OpenstackNodeService osNodeService = get(OpenstackNodeService.class);
    MastershipService mastershipService = get(MastershipService.class);
    ClusterService clusterService = get(ClusterService.class);
    if (tsService == null || osNodeService == null || instPortService == null || mastershipService == 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 gw : osNodeService.completeNodes(GATEWAY)) {
        if (!localNodeId.equals(mastershipService.getMasterFor(gw.intgBridge()))) {
            error("Current node is not the master for all gateway 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
        instPortService.instancePorts().stream().filter(p -> p.state() == ACTIVE).filter(p -> instPortService.floatingIp(p.portId()) != null).forEach(port -> printReachability(tsService.probeNorthSouth(port)));
    } else {
        final Set<InstancePort> ports = Sets.newConcurrentHashSet();
        for (String ip : vmIps) {
            instPortService.instancePorts().stream().filter(p -> p.state().equals(InstancePort.State.ACTIVE)).filter(p -> instPortService.floatingIp(p.portId()) != null).filter(p -> ip.equals(instPortService.floatingIp(p.portId()).toString())).forEach(ports::add);
        }
        printHeader();
        ports.forEach(port -> probeExecutor.execute(() -> printReachability(tsService.probeNorthSouth(port))));
    }
}
Also used : NodeId(org.onosproject.cluster.NodeId) GATEWAY(org.onosproject.openstacknode.api.OpenstackNode.NodeType.GATEWAY) OpenstackNodeService(org.onosproject.openstacknode.api.OpenstackNodeService) ACTIVE(org.onosproject.openstacknetworking.api.InstancePort.State.ACTIVE) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) InstancePort(org.onosproject.openstacknetworking.api.InstancePort) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) Set(java.util.Set) Argument(org.apache.karaf.shell.api.action.Argument) Sets(com.google.common.collect.Sets) Command(org.apache.karaf.shell.api.action.Command) AbstractShellCommand(org.onosproject.cli.AbstractShellCommand) OpenstackTroubleshootService(org.onosproject.openstacktroubleshoot.api.OpenstackTroubleshootService) Executors.newSingleThreadScheduledExecutor(java.util.concurrent.Executors.newSingleThreadScheduledExecutor) Reachability(org.onosproject.openstacktroubleshoot.api.Reachability) Service(org.apache.karaf.shell.api.action.lifecycle.Service) Completion(org.apache.karaf.shell.api.action.Completion) ClusterService(org.onosproject.cluster.ClusterService) Option(org.apache.karaf.shell.api.action.Option) MastershipService(org.onosproject.mastership.MastershipService) ExecutorService(java.util.concurrent.ExecutorService) 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) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode)

Aggregations

InstancePort (org.onosproject.openstacknetworking.api.InstancePort)36 Test (org.junit.Test)13 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)10 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)10 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)9 TrafficSelector (org.onosproject.net.flow.TrafficSelector)9 InstancePortService (org.onosproject.openstacknetworking.api.InstancePortService)9 OpenstackNode (org.onosproject.openstacknode.api.OpenstackNode)9 Set (java.util.Set)7 Argument (org.apache.karaf.shell.api.action.Argument)7 Command (org.apache.karaf.shell.api.action.Command)7 Service (org.apache.karaf.shell.api.action.lifecycle.Service)7 AbstractShellCommand (org.onosproject.cli.AbstractShellCommand)7 PortNumber (org.onosproject.net.PortNumber)7 Port (org.openstack4j.model.network.Port)7 IpAddress (org.onlab.packet.IpAddress)6 ApplicationId (org.onosproject.core.ApplicationId)6 CoreService (org.onosproject.core.CoreService)6 OpenstackNetworkService (org.onosproject.openstacknetworking.api.OpenstackNetworkService)6 OpenstackNodeService (org.onosproject.openstacknode.api.OpenstackNodeService)6