use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.GetL3VPNInputBuilder in project netvirt by opendaylight.
the class NeutronvpnManager method showVpnConfigCLI.
/**
* Implementation of the "vpnservice:l3vpn-config-show" karaf CLI command.
*
* @param vpnuuid Uuid of the VPN whose config must be shown
* @return formatted output list
* @throws InterruptedException if there was a thread related problem getting the data to display
* @throws ExecutionException if there was any other problem getting the data to display
*/
public List<String> showVpnConfigCLI(Uuid vpnuuid) throws InterruptedException, ExecutionException {
List<String> result = new ArrayList<>();
if (vpnuuid == null) {
result.add("");
result.add("Displaying VPN config for all VPNs");
result.add("To display VPN config for a particular VPN, use the following syntax");
result.add(getshowVpnConfigCLIHelp());
}
RpcResult<GetL3VPNOutput> rpcResult = getL3VPN(new GetL3VPNInputBuilder().setId(vpnuuid).build()).get();
if (rpcResult.isSuccessful()) {
result.add("");
result.add(String.format(" %-37s %-37s %-7s ", "VPN ID", "Tenant ID", "RD"));
result.add("");
result.add(String.format(" %-80s ", "Import-RTs"));
result.add("");
result.add(String.format(" %-80s ", "Export-RTs"));
result.add("");
result.add(String.format(" %-76s ", "Subnet IDs"));
result.add("");
result.add("------------------------------------------------------------------------------------");
result.add("");
List<L3vpnInstances> vpnList = rpcResult.getResult().getL3vpnInstances();
for (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.VpnInstance vpn : vpnList) {
String tenantId = vpn.getTenantId() != null ? vpn.getTenantId().getValue() : "\" " + " \"";
result.add(String.format(" %-37s %-37s %-7s ", vpn.getId().getValue(), tenantId, vpn.getRouteDistinguisher()));
result.add("");
result.add(String.format(" %-80s ", vpn.getImportRT()));
result.add("");
result.add(String.format(" %-80s ", vpn.getExportRT()));
result.add("");
Uuid vpnid = vpn.getId();
List<Uuid> subnetList = neutronvpnUtils.getSubnetsforVpn(vpnid);
if (!subnetList.isEmpty()) {
for (Uuid subnetuuid : subnetList) {
result.add(String.format(" %-76s ", subnetuuid.getValue()));
}
} else {
result.add(String.format(" %-76s ", "\" \""));
}
result.add("");
result.add("----------------------------------------");
result.add("");
}
} else {
String errortag = rpcResult.getErrors().iterator().next().getTag();
if (Objects.equals(errortag, "")) {
result.add("");
result.add("No VPN has been configured yet");
} else if (Objects.equals(errortag, "invalid-value")) {
result.add("");
result.add("VPN " + vpnuuid.getValue() + " is not present");
} else {
result.add("error getting VPN info : " + rpcResult.getErrors());
result.add(getshowVpnConfigCLIHelp());
}
}
return result;
}
Aggregations