use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DissociateNetworksOutput 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");
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DissociateNetworksOutput in project netvirt by opendaylight.
the class NeutronvpnManager method dissociateNetworks.
/**
* It handles the invocations to the neutronvpn:dissociateNetworks RPC method.
*/
@Override
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
public Future<RpcResult<DissociateNetworksOutput>> dissociateNetworks(DissociateNetworksInput input) {
DissociateNetworksOutputBuilder opBuilder = new DissociateNetworksOutputBuilder();
SettableFuture<RpcResult<DissociateNetworksOutput>> result = SettableFuture.create();
LOG.debug("dissociateNetworks {}", input);
StringBuilder returnMsg = new StringBuilder();
Uuid vpnId = input.getVpnId();
try {
if (neutronvpnUtils.getVpnMap(vpnId) != null) {
List<Uuid> netIds = input.getNetworkId();
if (netIds != null && !netIds.isEmpty()) {
List<String> failed = dissociateNetworksFromVpn(vpnId, netIds);
if (!failed.isEmpty()) {
returnMsg.append(failed);
}
}
} else {
returnMsg.append("VPN not found : ").append(vpnId.getValue());
}
if (returnMsg.length() != 0) {
opBuilder.setResponse("ErrorType: PROTOCOL, ErrorTag: invalid-value, ErrorMessage: " + formatAndLog(LOG::error, "dissociate Networks to vpn {} failed due to {}", vpnId.getValue(), returnMsg));
result.set(RpcResultBuilder.<DissociateNetworksOutput>success().withResult(opBuilder.build()).build());
} else {
result.set(RpcResultBuilder.<DissociateNetworksOutput>success().build());
}
} catch (Exception ex) {
result.set(RpcResultBuilder.<DissociateNetworksOutput>failed().withError(ErrorType.APPLICATION, formatAndLog(LOG::error, "dissociate Networks to vpn {} failed due to {}", input.getVpnId().getValue(), ex.getMessage(), ex)).build());
}
LOG.debug("dissociateNetworks returns..");
return result;
}
Aggregations