Search in sources :

Example 1 with GetL3VPNInputBuilder

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;
}
Also used : ArrayList(java.util.ArrayList) GetL3VPNOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.GetL3VPNOutput) L3vpnInstances(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.getl3vpn.output.L3vpnInstances) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) GetL3VPNInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.GetL3VPNInputBuilder)

Aggregations

ArrayList (java.util.ArrayList)1 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)1 GetL3VPNInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.GetL3VPNInputBuilder)1 GetL3VPNOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.GetL3VPNOutput)1 L3vpnInstances (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.getl3vpn.output.L3vpnInstances)1