mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-17 11:04:00 +01:00
bug 13191 : on account deletion gracefully cleanup all the resources configured on the NetScaler device
status 13191: resolved fixed
This commit is contained in:
parent
b15e5d6730
commit
47a6f74f6f
@ -514,10 +514,7 @@ public class NetscalerResource implements ServerResource {
|
|||||||
} else {
|
} else {
|
||||||
// delete the implemented load balancing rule and its destinations
|
// delete the implemented load balancing rule and its destinations
|
||||||
lbvserver lbserver = getVirtualServerIfExisits(nsVirtualServerName);
|
lbvserver lbserver = getVirtualServerIfExisits(nsVirtualServerName);
|
||||||
if (lbserver == null) {
|
if (lbserver != null) {
|
||||||
throw new ExecutionException("Failed to find virtual server with name:" + nsVirtualServerName);
|
|
||||||
}
|
|
||||||
|
|
||||||
//unbind the all services associated with this virtual server
|
//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);
|
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);
|
removeLBVirtualServer(nsVirtualServerName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (s_logger.isInfoEnabled()) {
|
if (s_logger.isInfoEnabled()) {
|
||||||
s_logger.info("Successfully executed resource LoadBalancerConfigCommand: " + _gson.toJson(cmd));
|
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 {
|
private void deleteGuestVlan(long vlanTag, String vlanSelfIp, String vlanNetmask) throws ExecutionException {
|
||||||
try {
|
try {
|
||||||
if (nsVlanExists(vlanTag)) {
|
|
||||||
|
|
||||||
// Delete all servers and associated services from this guest VLAN
|
// Delete all servers and associated services from this guest VLAN
|
||||||
deleteServersInGuestVlan(vlanTag, vlanSelfIp, vlanNetmask);
|
deleteServersInGuestVlan(vlanTag, vlanSelfIp, vlanNetmask);
|
||||||
|
|
||||||
// unbind vlan to the private interface
|
// unbind vlan to the private interface
|
||||||
|
try {
|
||||||
vlan_interface_binding vlanIfBinding = new vlan_interface_binding();
|
vlan_interface_binding vlanIfBinding = new vlan_interface_binding();
|
||||||
vlanIfBinding.set_id(vlanTag);
|
vlanIfBinding.set_id(vlanTag);
|
||||||
vlanIfBinding.set_ifnum(_privateInterface);
|
vlanIfBinding.set_ifnum(_privateInterface);
|
||||||
vlanIfBinding.set_tagged(true);
|
vlanIfBinding.set_tagged(true);
|
||||||
try {
|
|
||||||
apiCallResult = vlan_interface_binding.delete(_netscalerService, vlanIfBinding);
|
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) {
|
if (apiCallResult.errorcode != 0) {
|
||||||
throw new ExecutionException("Failed to unbind vlan:" + vlanTag + " with the private interface due to " + apiCallResult.message);
|
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
|
// unbind the vlan to subnet
|
||||||
|
try {
|
||||||
vlan_nsip_binding vlanSnipBinding = new vlan_nsip_binding();
|
vlan_nsip_binding vlanSnipBinding = new vlan_nsip_binding();
|
||||||
vlanSnipBinding.set_netmask(vlanNetmask);
|
vlanSnipBinding.set_netmask(vlanNetmask);
|
||||||
vlanSnipBinding.set_ipaddress(vlanSelfIp);
|
vlanSnipBinding.set_ipaddress(vlanSelfIp);
|
||||||
@ -949,14 +946,29 @@ public class NetscalerResource implements ServerResource {
|
|||||||
if (apiCallResult.errorcode != 0) {
|
if (apiCallResult.errorcode != 0) {
|
||||||
throw new ExecutionException("Failed to unbind vlan:" + vlanTag + " with the subnet due to " + apiCallResult.message);
|
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
|
// remove subnet IP
|
||||||
|
try {
|
||||||
nsip subnetIp = nsip.get(_netscalerService, vlanSelfIp);
|
nsip subnetIp = nsip.get(_netscalerService, vlanSelfIp);
|
||||||
apiCallResult = nsip.delete(_netscalerService, subnetIp);
|
apiCallResult = nsip.delete(_netscalerService, subnetIp);
|
||||||
if (apiCallResult.errorcode != 0) {
|
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
|
// remove vlan
|
||||||
apiCallResult = com.citrix.netscaler.nitro.resource.config.network.vlan.delete(_netscalerService, vlanTag);
|
apiCallResult = com.citrix.netscaler.nitro.resource.config.network.vlan.delete(_netscalerService, vlanTag);
|
||||||
if (apiCallResult.errorcode != 0) {
|
if (apiCallResult.errorcode != 0) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user