Search in sources :

Example 51 with OpenstackNode

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

the class OpenstackNodeCodecTest method testOpenstackDpdkComputeNodeEncode.

/**
 * Tests the openstack compute node encoding with dpdk config.
 */
@Test
public void testOpenstackDpdkComputeNodeEncode() {
    DpdkInterface dpdkInterface1 = DefaultDpdkInterface.builder().deviceName("br-int").intf("dpdk0").mtu(Long.valueOf(1600)).pciAddress("0000:85:00.0").type(DpdkInterface.Type.DPDK).build();
    DpdkInterface dpdkInterface2 = DefaultDpdkInterface.builder().deviceName("br-tun").intf("dpdk1").pciAddress("0000:85:00.1").type(DpdkInterface.Type.DPDK).build();
    Collection<DpdkInterface> dpdkInterfaceCollection = new ArrayList<>();
    dpdkInterfaceCollection.add(dpdkInterface1);
    dpdkInterfaceCollection.add(dpdkInterface2);
    DpdkConfig dpdkConfig = DefaultDpdkConfig.builder().datapathType(DpdkConfig.DatapathType.NETDEV).dpdkIntfs(dpdkInterfaceCollection).build();
    OpenstackNode node = DefaultOpenstackNode.builder().hostname("compute").type(OpenstackNode.NodeType.COMPUTE).state(NodeState.INIT).managementIp(IpAddress.valueOf("10.10.10.1")).intgBridge(DeviceId.deviceId("br-int")).vlanIntf("vlan").dataIp(IpAddress.valueOf("20.20.20.2")).dpdkConfig(dpdkConfig).build();
    ObjectNode nodeJson = openstackNodeCodec.encode(node, context);
    assertThat(nodeJson, matchesOpenstackNode(node));
}
Also used : DpdkConfig(org.onosproject.openstacknode.api.DpdkConfig) DefaultDpdkConfig(org.onosproject.openstacknode.api.DefaultDpdkConfig) DpdkInterface(org.onosproject.openstacknode.api.DpdkInterface) DefaultDpdkInterface(org.onosproject.openstacknode.api.DefaultDpdkInterface) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ArrayList(java.util.ArrayList) OpenstackNodeJsonMatcher.matchesOpenstackNode(org.onosproject.openstacknode.codec.OpenstackNodeJsonMatcher.matchesOpenstackNode) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) DefaultOpenstackNode(org.onosproject.openstacknode.api.DefaultOpenstackNode) Test(org.junit.Test)

Example 52 with OpenstackNode

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

the class OpenstackNodeManagerTest method testUpdateNodeStateIncomplete.

/**
 * Checks if updating a node state to incomplete generates proper events.
 */
@Test
public void testUpdateNodeStateIncomplete() {
    OpenstackNode updated = DefaultOpenstackNode.from(COMPUTE_3).state(NodeState.INCOMPLETE).build();
    target.updateNode(updated);
    assertEquals(ERR_NOT_MATCH, updated, target.node(COMPUTE_3_HOSTNAME));
    validateEvents(OPENSTACK_NODE_UPDATED, OPENSTACK_NODE_INCOMPLETE);
}
Also used : OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) DefaultOpenstackNode(org.onosproject.openstacknode.api.DefaultOpenstackNode) OpenstackNodeTest(org.onosproject.openstacknode.api.OpenstackNodeTest) Test(org.junit.Test)

Example 53 with OpenstackNode

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

the class OpenstackNetworkingUtilTest method testGetGwByInstancePort.

/**
 * Tests the getGwByInstancePort method.
 */
@Test
public void testGetGwByInstancePort() {
    Set<OpenstackNode> gws = Sets.newConcurrentHashSet();
    gws.add(genGateway(1));
    gws.add(genGateway(2));
    gws.add(genGateway(3));
    int expectedGwIndex = 2;
    OpenstackNode gw = getGwByInstancePort(gws, instancePort1);
    assertEquals(genGateway(expectedGwIndex), gw);
    assertNull(getGwByInstancePort(gws, null));
}
Also used : DefaultOpenstackNode(org.onosproject.openstacknode.api.DefaultOpenstackNode) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) OpenstackNodeTest(org.onosproject.openstacknode.api.OpenstackNodeTest) Test(org.junit.Test) OpenstackFloatingIpWebResourceTest(org.onosproject.openstacknetworking.web.OpenstackFloatingIpWebResourceTest) OpenstackNetworkWebResourceTest(org.onosproject.openstacknetworking.web.OpenstackNetworkWebResourceTest)

Example 54 with OpenstackNode

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

the class OpenstackTroubleshootManager method probeNorthSouth.

@Override
public Reachability probeNorthSouth(InstancePort port) {
    Optional<OpenstackNode> gw = osNodeService.completeNodes(GATEWAY).stream().findFirst();
    if (!gw.isPresent()) {
        log.warn("Gateway is not available to troubleshoot north-south traffic.");
        return null;
    }
    // install flow rules to enforce forwarding ICMP_REPLY to controller
    eventExecutor.execute(() -> setNorthSouthIcmpReplyRule(port, gw.get(), true));
    timeoutPredicate(1, ICMP_RULE_INSTALL_TIMEOUT_MS, this::checkNorthSouthIcmpReplyRule, port.ipAddress().toString());
    // send out ICMP ECHO request
    sendIcmpEchoRequest(null, port, gw.get(), Direction.NORTH_SOUTH);
    BooleanSupplier checkReachability = () -> icmpReachabilityMap.asJavaMap().values().stream().allMatch(Reachability::isReachable);
    timeoutSupplier(1, ICMP_REPLY_TIMEOUT_MS, checkReachability);
    // uninstall ICMP_REPLY enforcing rules
    eventExecutor.execute(() -> setNorthSouthIcmpReplyRule(port, gw.get(), false));
    return icmpReachabilityMap.asJavaMap().get(String.valueOf(icmpIdCounter.get()));
}
Also used : OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) BooleanSupplier(java.util.function.BooleanSupplier) Reachability(org.onosproject.openstacktroubleshoot.api.Reachability)

Example 55 with OpenstackNode

use of org.onosproject.openstacknode.api.OpenstackNode 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)76 OpenstackNodeService (org.onosproject.openstacknode.api.OpenstackNodeService)22 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)19 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)19 TrafficSelector (org.onosproject.net.flow.TrafficSelector)19 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)19 PortNumber (org.onosproject.net.PortNumber)14 DefaultOpenstackNode (org.onosproject.openstacknode.api.DefaultOpenstackNode)14 DeviceService (org.onosproject.net.device.DeviceService)13 Set (java.util.Set)12 Test (org.junit.Test)12 IpAddress (org.onlab.packet.IpAddress)12 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)9 Objects (java.util.Objects)9 Optional (java.util.Optional)9 ExecutorService (java.util.concurrent.ExecutorService)9 Collectors (java.util.stream.Collectors)9 ComponentConfigService (org.onosproject.cfg.ComponentConfigService)9 Produces (javax.ws.rs.Produces)8 InstancePort (org.onosproject.openstacknetworking.api.InstancePort)7