use of org.onosproject.openstacknetworking.api.OpenstackRouterService in project onos by opennetworkinglab.
the class OpenstackFloatingIpListCommand method doExecute.
@Override
protected void doExecute() {
OpenstackRouterService service = get(OpenstackRouterService.class);
List<NetFloatingIP> floatingIps = Lists.newArrayList(service.floatingIps());
floatingIps.sort(Comparator.comparing(NetFloatingIP::getFloatingIpAddress));
if (outputJson()) {
print("%s", json(floatingIps));
} else {
print(FORMAT, "ID", "Floating IP", "Fixed IP");
for (NetFloatingIP floatingIp : floatingIps) {
print(FORMAT, floatingIp.getId(), floatingIp.getFloatingIpAddress(), Strings.isNullOrEmpty(floatingIp.getFixedIpAddress()) ? "" : floatingIp.getFixedIpAddress());
}
}
}
use of org.onosproject.openstacknetworking.api.OpenstackRouterService in project onos by opennetworkinglab.
the class UpdateExternalPeerRouterVlanCommand method doExecute.
@Override
protected void doExecute() {
OpenstackNetworkAdminService osNetAdminService = get(OpenstackNetworkAdminService.class);
OpenstackRouterService osRouterService = get(OpenstackRouterService.class);
IpAddress externalPeerIpAddress = IpAddress.valueOf(IpAddress.Version.INET, Ip4Address.valueOf(ipAddress).toOctets());
if (osNetAdminService.externalPeerRouters().isEmpty()) {
print(NO_ELEMENT);
return;
} else if (osNetAdminService.externalPeerRouters().stream().noneMatch(router -> router.ipAddress().toString().equals(ipAddress))) {
print(NO_ELEMENT);
return;
}
Subnet subnet = osNetAdminService.subnets().stream().filter(s -> s.getGateway().equals(ipAddress)).findAny().orElse(null);
if (subnet == null) {
return;
}
Network network = osNetAdminService.network(subnet.getNetworkId());
if (network == null) {
return;
}
Router router = osRouterService.routers().stream().filter(r -> r.getExternalGatewayInfo().getNetworkId().equals(network.getId())).findAny().orElse(null);
if (router == null) {
return;
}
try {
if (vlanId.equals(NONE)) {
osNetAdminService.updateExternalPeerRouterVlan(externalPeerIpAddress, VlanId.NONE);
osNetAdminService.deriveExternalPeerRouterMac(router.getExternalGatewayInfo(), router, VlanId.NONE);
} else {
osNetAdminService.updateExternalPeerRouterVlan(externalPeerIpAddress, VlanId.vlanId(vlanId));
osNetAdminService.deriveExternalPeerRouterMac(router.getExternalGatewayInfo(), router, VlanId.vlanId(vlanId));
}
} catch (IllegalArgumentException e) {
log.error("Exception occurred because of {}", e.toString());
}
print(FORMAT, "Router IP", "Mac Address", "VLAN ID");
List<ExternalPeerRouter> routers = Lists.newArrayList(osNetAdminService.externalPeerRouters());
for (ExternalPeerRouter r : routers) {
print(FORMAT, r.ipAddress(), r.macAddress().toString(), r.vlanId());
}
}
Aggregations