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);
}
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);
}
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());
}
}
}
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());
}
}
}
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));
}
}
});
}
}
Aggregations