mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-11-04 00:02:37 +01:00 
			
		
		
		
	bug 13179: Netscaler - Admin is allowed to delete the SDX instance when there are existing vpx instances that was created
status 13179: resolved fixed
This commit is contained in:
		
							parent
							
								
									207f0db318
								
							
						
					
					
						commit
						5f8936eb2f
					
				@ -288,10 +288,23 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
 | 
			
		||||
        DetailVO lbHostDetails = _hostDetailDao.findDetail(hostId, ApiConstants.LOAD_BALANCER_DEVICE_ID);
 | 
			
		||||
        long lbDeviceId = Long.parseLong(lbHostDetails.getValue());
 | 
			
		||||
 | 
			
		||||
        // check if any networks are using this load balancer device
 | 
			
		||||
        List<NetworkExternalLoadBalancerVO> networks = _networkLBDao.listByLoadBalancerDeviceId(lbDeviceId);
 | 
			
		||||
        if ((networks != null) && !networks.isEmpty()) {
 | 
			
		||||
            throw new CloudRuntimeException("Delete can not be done as there are networks using this load balancer device ");
 | 
			
		||||
        ExternalLoadBalancerDeviceVO lbDeviceVo = _externalLoadBalancerDeviceDao.findById(lbDeviceId);
 | 
			
		||||
        if (lbDeviceVo.getAllocationState() == LBDeviceAllocationState.Provider) {
 | 
			
		||||
            // check if cloudstack has provisioned any load balancer appliance on the device before deleting
 | 
			
		||||
            List<ExternalLoadBalancerDeviceVO> lbDevices = _externalLoadBalancerDeviceDao.listAll();
 | 
			
		||||
            if (lbDevices != null) {
 | 
			
		||||
                for (ExternalLoadBalancerDeviceVO lbDevice : lbDevices) {
 | 
			
		||||
                    if (lbDevice.getParentHostId() == hostId) {
 | 
			
		||||
                        throw new CloudRuntimeException("This load balancer device can not be deleted as there are one or more load balancers applainces provisioned by cloudstack on the device.");
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            // check if any networks are using this load balancer device
 | 
			
		||||
            List<NetworkExternalLoadBalancerVO> networks = _networkLBDao.listByLoadBalancerDeviceId(lbDeviceId);
 | 
			
		||||
            if ((networks != null) && !networks.isEmpty()) {
 | 
			
		||||
                throw new CloudRuntimeException("Delete can not be done as there are networks using this load balancer device ");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        try {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user