Search in sources :

Example 16 with OpenstackNetworkService

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

the class VmDeviceIdCompleter method complete.

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

Example 17 with OpenstackNetworkService

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

the class OpenstackNetworkingUtilTest method testIsAssociatedWithVM.

/**
 * Tests the isAssociatedWithVM method.
 */
@Test
public void testIsAssociatedWithVM() {
    OpenstackNetworkService service = new TestOpenstackNetworkService();
    NetFloatingIP floatingIp4 = new NeutronFloatingIP().toBuilder().portId("portId4").build();
    assertFalse(isAssociatedWithVM(service, floatingIp4));
    assertFalse(isAssociatedWithVM(service, floatingIp3));
    assertTrue(isAssociatedWithVM(service, floatingIp1));
}
Also used : NeutronFloatingIP(org.openstack4j.openstack.networking.domain.NeutronFloatingIP) OpenstackNetworkService(org.onosproject.openstacknetworking.api.OpenstackNetworkService) NetFloatingIP(org.openstack4j.model.network.NetFloatingIP) OpenstackNodeTest(org.onosproject.openstacknode.api.OpenstackNodeTest) Test(org.junit.Test) OpenstackFloatingIpWebResourceTest(org.onosproject.openstacknetworking.web.OpenstackFloatingIpWebResourceTest) OpenstackNetworkWebResourceTest(org.onosproject.openstacknetworking.web.OpenstackNetworkWebResourceTest)

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