Search in sources :

Example 6 with OpenstackNetworkService

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

the class MacAddressCompleter method complete.

@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
    StringsCompleter delegate = new StringsCompleter();
    OpenstackNetworkService osNetService = get(OpenstackNetworkService.class);
    Set<MacAddress> set = osNetService.externalPeerRouters().stream().map(ExternalPeerRouter::macAddress).collect(Collectors.toSet());
    SortedSet<String> strings = delegate.getStrings();
    Iterator<MacAddress> it = set.iterator();
    while (it.hasNext()) {
        strings.add(it.next().toString());
    }
    return delegate.complete(session, commandLine, candidates);
}
Also used : OpenstackNetworkService(org.onosproject.openstacknetworking.api.OpenstackNetworkService) StringsCompleter(org.apache.karaf.shell.support.completers.StringsCompleter) MacAddress(org.onlab.packet.MacAddress)

Example 7 with OpenstackNetworkService

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

the class OpenstackNetworkingUtilTest method testIsAssociatedWithVMexceptionCase.

/**
 * Tests the isAssociatedWithVM method in case IllegalStateException is occurred.
 */
@Test(expected = IllegalStateException.class)
public void testIsAssociatedWithVMexceptionCase() {
    OpenstackNetworkService service = new TestOpenstackNetworkService();
    isAssociatedWithVM(service, floatingIp2);
}
Also used : OpenstackNetworkService(org.onosproject.openstacknetworking.api.OpenstackNetworkService) OpenstackNodeTest(org.onosproject.openstacknode.api.OpenstackNodeTest) Test(org.junit.Test) OpenstackFloatingIpWebResourceTest(org.onosproject.openstacknetworking.web.OpenstackFloatingIpWebResourceTest) OpenstackNetworkWebResourceTest(org.onosproject.openstacknetworking.web.OpenstackNetworkWebResourceTest)

Example 8 with OpenstackNetworkService

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

the class ExternalPeerRouterListCommand method doExecute.

@Override
protected void doExecute() {
    OpenstackNetworkService service = get(OpenstackNetworkService.class);
    List<ExternalPeerRouter> routers = Lists.newArrayList(service.externalPeerRouters());
    if (outputJson()) {
        print("%s", json(this, routers));
    } else {
        print(FORMAT, "Router IP", "Mac Address", "VLAN ID");
        for (ExternalPeerRouter router : routers) {
            print(FORMAT, router.ipAddress(), router.macAddress().toString(), router.vlanId());
        }
    }
}
Also used : ExternalPeerRouter(org.onosproject.openstacknetworking.api.ExternalPeerRouter) OpenstackNetworkService(org.onosproject.openstacknetworking.api.OpenstackNetworkService)

Example 9 with OpenstackNetworkService

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

the class InstancePortListCommand method doExecute.

@Override
protected void doExecute() {
    InstancePortService service = get(InstancePortService.class);
    OpenstackNetworkService osNetService = get(OpenstackNetworkService.class);
    List<InstancePort> instancePorts = Lists.newArrayList(service.instancePorts());
    instancePorts.sort(Comparator.comparing(InstancePort::portId));
    if (outputJson()) {
        print("%s", json(this, instancePorts));
    } else {
        print(FORMAT, "Port ID", "VM Device ID", "State", "Device ID", "Port Number", "Fixed IP");
        for (InstancePort port : instancePorts) {
            Port neutronPort = osNetService.port(port.portId());
            String vmId = "N/A";
            if (neutronPort != null) {
                vmId = neutronPort.getDeviceId();
            }
            print(FORMAT, port.portId(), vmId, port.state(), port.deviceId().toString(), port.portNumber().toLong(), port.ipAddress().toString());
        }
    }
}
Also used : InstancePortService(org.onosproject.openstacknetworking.api.InstancePortService) OpenstackNetworkService(org.onosproject.openstacknetworking.api.OpenstackNetworkService) InstancePort(org.onosproject.openstacknetworking.api.InstancePort) InstancePort(org.onosproject.openstacknetworking.api.InstancePort) Port(org.openstack4j.model.network.Port)

Example 10 with OpenstackNetworkService

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

the class OpenstackDetachedPortListCommand method doExecute.

@Override
protected void doExecute() {
    OpenstackNodeService nodeService = get(OpenstackNodeService.class);
    OpenstackNetworkService networkService = get(OpenstackNetworkService.class);
    DeviceService deviceService = get(DeviceService.class);
    if (isAll) {
        hostnames = nodeService.completeNodes().stream().map(OpenstackNode::hostname).toArray(String[]::new);
    }
    if (hostnames == null) {
        print("Please specify one of hostname or --all options.");
        return;
    }
    print(FORMAT, "Hostname", "Integration Bridge", "Detached Port");
    for (String hostname : hostnames) {
        networkService.ports().forEach(p -> {
            if (hostname.equals(p.getHostId())) {
                OpenstackNode osNode = nodeService.node(p.getHostId());
                if (osNode != null) {
                    Set<String> detachedPortNames = detachedOvsPort(p, deviceService.getPorts(osNode.intgBridge()));
                    detachedPortNames.forEach(dp -> print(FORMAT, hostname, osNode.intgBridge().toString(), dp));
                }
            }
        });
    }
}
Also used : OpenstackNodeService(org.onosproject.openstacknode.api.OpenstackNodeService) OpenstackNetworkService(org.onosproject.openstacknetworking.api.OpenstackNetworkService) DeviceService(org.onosproject.net.device.DeviceService) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode)

Aggregations

OpenstackNetworkService (org.onosproject.openstacknetworking.api.OpenstackNetworkService)17 StringsCompleter (org.apache.karaf.shell.support.completers.StringsCompleter)5 Port (org.openstack4j.model.network.Port)5 Command (org.apache.karaf.shell.api.action.Command)4 Service (org.apache.karaf.shell.api.action.lifecycle.Service)4 AbstractShellCommand (org.onosproject.cli.AbstractShellCommand)4 DeviceService (org.onosproject.net.device.DeviceService)4 Network (org.openstack4j.model.network.Network)4 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 OpenstackNode (org.onosproject.openstacknode.api.OpenstackNode)3 OpenstackNodeService (org.onosproject.openstacknode.api.OpenstackNodeService)3 Lists (com.google.common.collect.Lists)2 Comparator (java.util.Comparator)2 Argument (org.apache.karaf.shell.api.action.Argument)2 Completion (org.apache.karaf.shell.api.action.Completion)2 Test (org.junit.Test)2 AbstractShellCommand.get (org.onosproject.cli.AbstractShellCommand.get)2 InstancePort (org.onosproject.openstacknetworking.api.InstancePort)2 InstancePortService (org.onosproject.openstacknetworking.api.InstancePortService)2