use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DeleteL3VPNInputBuilder 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");
}
}
Aggregations