bug 13191 : on account deletion gracefully cleanup all the resources configured on the NetScaler device

status 13191: resolved fixed
This commit is contained in:
Murali reddy 2012-02-03 20:59:10 +05:30
parent b15e5d6730
commit 47a6f74f6f

View File

@ -514,10 +514,7 @@ public class NetscalerResource implements ServerResource {
} else {
// delete the implemented load balancing rule and its destinations
lbvserver lbserver = getVirtualServerIfExisits(nsVirtualServerName);
if (lbserver == null) {
throw new ExecutionException("Failed to find virtual server with name:" + nsVirtualServerName);
}
if (lbserver != null) {
//unbind the all services associated with this virtual server
com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding[] serviceBindings = com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding.get(_netscalerService, nsVirtualServerName);
@ -563,6 +560,7 @@ public class NetscalerResource implements ServerResource {
removeLBVirtualServer(nsVirtualServerName);
}
}
}
if (s_logger.isInfoEnabled()) {
s_logger.info("Successfully executed resource LoadBalancerConfigCommand: " + _gson.toJson(cmd));
@ -917,30 +915,29 @@ public class NetscalerResource implements ServerResource {
private void deleteGuestVlan(long vlanTag, String vlanSelfIp, String vlanNetmask) throws ExecutionException {
try {
if (nsVlanExists(vlanTag)) {
// Delete all servers and associated services from this guest VLAN
deleteServersInGuestVlan(vlanTag, vlanSelfIp, vlanNetmask);
// unbind vlan to the private interface
try {
vlan_interface_binding vlanIfBinding = new vlan_interface_binding();
vlanIfBinding.set_id(vlanTag);
vlanIfBinding.set_ifnum(_privateInterface);
vlanIfBinding.set_tagged(true);
try {
apiCallResult = vlan_interface_binding.delete(_netscalerService, vlanIfBinding);
} catch (nitro_exception e) {
// FIXME: Vlan binding (subsequent unbind) to an interfaces will fail on the VPX created on Xen server and on
// NetScaler SDX appliance till the VPX fix to handle VLAN's is released. Relaxing this restriction NetScaler until then
if (!(_deviceName.equalsIgnoreCase("NetscalerVPXLoadBalancer") && e.getErrorCode() == NitroError.NS_RESOURCE_NOT_EXISTS)) {
throw new ExecutionException("Failed to unbind vlan from the interface while shutdown of guest network on the Netscaler device due to " + e.getMessage());
}
}
if (apiCallResult.errorcode != 0) {
throw new ExecutionException("Failed to unbind vlan:" + vlanTag + " with the private interface due to " + apiCallResult.message);
}
} catch (nitro_exception e) {
// if Vlan to interface binding does not exist then ignore the exception and proceed
if (!(e.getErrorCode() == NitroError.NS_RESOURCE_NOT_EXISTS)) {
throw new ExecutionException("Failed to unbind vlan from the interface while shutdown of guest network on the Netscaler device due to " + e.getMessage());
}
}
// unbind the vlan to subnet
try {
vlan_nsip_binding vlanSnipBinding = new vlan_nsip_binding();
vlanSnipBinding.set_netmask(vlanNetmask);
vlanSnipBinding.set_ipaddress(vlanSelfIp);
@ -949,14 +946,29 @@ public class NetscalerResource implements ServerResource {
if (apiCallResult.errorcode != 0) {
throw new ExecutionException("Failed to unbind vlan:" + vlanTag + " with the subnet due to " + apiCallResult.message);
}
} catch (nitro_exception e) {
// if Vlan to subnet binding does not exist then ignore the exception and proceed
if (!(e.getErrorCode() == NitroError.NS_RESOURCE_NOT_EXISTS)) {
throw new ExecutionException("Failed to unbind vlan:" + vlanTag + " with the subnet due to " + e.getMessage());
}
}
// remove subnet IP
try {
nsip subnetIp = nsip.get(_netscalerService, vlanSelfIp);
apiCallResult = nsip.delete(_netscalerService, subnetIp);
if (apiCallResult.errorcode != 0) {
throw new ExecutionException("Failed to remove subnet ip:" + vlanTag + " to the subnet due to" + apiCallResult.message);
throw new ExecutionException("Failed to remove subnet ip:" + vlanSelfIp + " from the NetScaler device due to" + apiCallResult.message);
}
} catch (nitro_exception e) {
// if subnet SNIP does not exist then ignore the exception and proceed
if (!(e.getErrorCode() == NitroError.NS_RESOURCE_NOT_EXISTS)) {
throw new ExecutionException("Failed to remove subnet ip:" + vlanSelfIp + " from the NetScaler device due to" + e.getMessage());
}
}
// remove the vlan from the NetScaler device
if (nsVlanExists(vlanTag)) {
// remove vlan
apiCallResult = com.citrix.netscaler.nitro.resource.config.network.vlan.delete(_netscalerService, vlanTag);
if (apiCallResult.errorcode != 0) {