use of org.onosproject.openstacknetworking.api.OpenstackNetworkAdminService in project onos by opennetworkinglab.
the class UpdateExternalPeerRouterCommand method doExecute.
@Override
protected void doExecute() {
OpenstackNetworkAdminService service = get(OpenstackNetworkAdminService.class);
IpAddress externalPeerIpAddress = IpAddress.valueOf(IpAddress.Version.INET, Ip4Address.valueOf(ipAddress).toOctets());
if (service.externalPeerRouters().isEmpty()) {
print(NO_ELEMENT);
return;
} else if (service.externalPeerRouters().stream().noneMatch(router -> router.ipAddress().toString().equals(ipAddress))) {
print(NO_ELEMENT);
return;
}
try {
if (vlanId.equals(NONE)) {
service.updateExternalPeerRouter(externalPeerIpAddress, MacAddress.valueOf(macAddress), VlanId.NONE);
} else {
service.updateExternalPeerRouter(externalPeerIpAddress, MacAddress.valueOf(macAddress), 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(service.externalPeerRouters());
for (ExternalPeerRouter router : routers) {
print(FORMAT, router.ipAddress(), router.macAddress().toString(), router.vlanId());
}
}
Aggregations