Search in sources :

Example 1 with DissociateNetworksInputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DissociateNetworksInputBuilder in project netvirt by opendaylight.

the class ConfigureL3VpnCommand method deleteL3VpnCLI.

private void deleteL3VpnCLI() throws InterruptedException, ExecutionException {
    if (vid == null) {
        session.getConsole().println("Please supply a valid VPN ID");
        session.getConsole().println(getHelp("delete"));
        return;
    }
    Uuid vpnId = new Uuid(vid);
    // disassociation of network(s) (removal of subnet(s)) from VPN to be followed by deletion of VPN
    RpcResult<DissociateNetworksOutput> dissociateNetworksRpcResult = null;
    List<Uuid> networkIdList = null;
    networkIdList = neutronVpnManager.getNetworksForVpn(vpnId);
    if (networkIdList != null && !networkIdList.isEmpty()) {
        Future<RpcResult<DissociateNetworksOutput>> result = neutronvpnService.dissociateNetworks(new DissociateNetworksInputBuilder().setVpnId(vpnId).setNetworkId(networkIdList).build());
        dissociateNetworksRpcResult = result.get();
        if (dissociateNetworksRpcResult.isSuccessful()) {
            session.getConsole().println("Subnet(s) removed from VPN successfully");
            LOG.trace("dissociateNetworks: {}", result);
        } else {
            session.getConsole().println("Error while removing subnet(s) from VPN: " + result.get().getErrors());
            session.getConsole().println(getHelp("delete"));
        }
    }
    if (networkIdList == null || networkIdList.isEmpty() || dissociateNetworksRpcResult.isSuccessful()) {
        List<Uuid> vpnIdList = new ArrayList<>();
        vpnIdList.add(vpnId);
        Future<RpcResult<DeleteL3VPNOutput>> result = neutronvpnService.deleteL3VPN(new DeleteL3VPNInputBuilder().setId(vpnIdList).build());
        RpcResult<DeleteL3VPNOutput> rpcResult = result.get();
        if (rpcResult.isSuccessful()) {
            session.getConsole().println("L3VPN deleted successfully");
            LOG.trace("deletel3vpn: {}", result);
        } else {
            session.getConsole().println("Error populating deleteL3VPN : " + result.get().getErrors());
            session.getConsole().println(getHelp("delete"));
        }
    } else {
        session.getConsole().println("Not proceeding with deletion of L3VPN since error(s) encountered " + "in removing subnet(s) from VPN");
    }
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) DissociateNetworksOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DissociateNetworksOutput) DeleteL3VPNOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DeleteL3VPNOutput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ArrayList(java.util.ArrayList) DeleteL3VPNInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DeleteL3VPNInputBuilder) DissociateNetworksInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DissociateNetworksInputBuilder)

Aggregations

ArrayList (java.util.ArrayList)1 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)1 DeleteL3VPNInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DeleteL3VPNInputBuilder)1 DeleteL3VPNOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DeleteL3VPNOutput)1 DissociateNetworksInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DissociateNetworksInputBuilder)1 DissociateNetworksOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DissociateNetworksOutput)1 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)1