use of org.onosproject.openstacknetworking.api.OpenstackNetworkService in project onos by opennetworkinglab.
the class DirectPortListCompleter 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().filter(port -> port.getvNicType().equals(DIRECT)).map(Port::getId).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);
}
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 IpAddressCompleter method complete.
@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
StringsCompleter delegate = new StringsCompleter();
OpenstackNetworkService osNetService = get(OpenstackNetworkService.class);
Set<IpAddress> set = osNetService.externalPeerRouters().stream().map(ExternalPeerRouter::ipAddress).collect(Collectors.toSet());
SortedSet<String> strings = delegate.getStrings();
Iterator<IpAddress> 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 OpenstackNetworkListCommand method doExecute.
@Override
protected void doExecute() {
OpenstackNetworkService service = get(OpenstackNetworkService.class);
List<Network> networks = Lists.newArrayList(service.networks());
networks.sort(Comparator.comparing(Network::getId));
if (outputJson()) {
print("%s", json(networks));
} else {
print(FORMAT, "ID", "Name", "Type", "SegId", "Subnets", "HostRoutes");
for (Network net : networks) {
List<Subnet> subnets = service.subnets().stream().filter(subnet -> subnet.getNetworkId().equals(net.getId())).collect(Collectors.toList());
List<String> subnetsString = subnets.stream().map(Subnet::getCidr).collect(Collectors.toList());
List<String> hostRoutes = Lists.newArrayList();
subnets.forEach(subnet -> {
subnet.getHostRoutes().forEach(h -> hostRoutes.add(h.toString()));
});
print(FORMAT, net.getId(), deriveResourceName(net), service.networkType(net.getId()).toString(), net.getProviderSegID(), subnets.isEmpty() ? "" : subnetsString, hostRoutes.isEmpty() ? "" : hostRoutes);
}
}
}
use of org.onosproject.openstacknetworking.api.OpenstackNetworkService in project onos by opennetworkinglab.
the class OpenstackSubnetListCommand method doExecute.
@Override
protected void doExecute() {
OpenstackNetworkService service = get(OpenstackNetworkService.class);
List<Subnet> subnets = Lists.newArrayList(service.subnets());
subnets.sort(Comparator.comparing(Subnet::getId));
if (outputJson()) {
print("%s", json(subnets));
} else {
print(FORMAT, "ID", "Name", "CIDR", "GatewayIp", "NetworkId", "NetworkName", "HostRoutes");
for (Subnet subnet : subnets) {
Network osNet = service.network(subnet.getNetworkId());
String netName = osNet == null ? "N/A" : deriveResourceName(osNet);
print(FORMAT, subnet.getId(), deriveResourceName(subnet), subnet.getCidr(), subnet.getGateway(), subnet.getNetworkId(), netName, subnet.getHostRoutes());
}
}
}
Aggregations