mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-11-04 00:02:37 +01:00 
			
		
		
		
	bug 8334: throw an error when try to create a network with the settings belonging to existing network
status 8334: resolved fixed
This commit is contained in:
		
							parent
							
								
									7d5706788c
								
							
						
					
					
						commit
						1d031e64b8
					
				@ -1184,7 +1184,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                userNetwork.setBroadcastDomainType(broadcastDomainType);
 | 
			
		||||
                _networkMgr.setupNetwork(systemAccount, offering, userNetwork, plan, null, null, true, isNetworkDefault); 
 | 
			
		||||
                _networkMgr.setupNetwork(systemAccount, offering, userNetwork, plan, null, null, true, isNetworkDefault, false); 
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -97,7 +97,7 @@ public interface NetworkManager extends NetworkService {
 | 
			
		||||
    List<IPAddressVO> listPublicIpAddressesInVirtualNetwork(long accountId, long dcId, Boolean sourceNat);	
 | 
			
		||||
    
 | 
			
		||||
    List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, DeploymentPlan plan, String name, String displayText, boolean isShared, boolean isDefault) throws ConcurrentOperationException;
 | 
			
		||||
    List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, Network predefined, DeploymentPlan plan, String name, String displayText, boolean isShared, boolean isDefault) throws ConcurrentOperationException;
 | 
			
		||||
    List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, Network predefined, DeploymentPlan plan, String name, String displayText, boolean isShared, boolean isDefault, boolean errorIfAlreadySetup) throws ConcurrentOperationException;
 | 
			
		||||
    
 | 
			
		||||
    List<NetworkOfferingVO> getSystemAccountNetworkOfferings(String... offeringNames);
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
@ -773,12 +773,12 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, DeploymentPlan plan, String name, String displayText, boolean isShared, boolean isDefault) throws ConcurrentOperationException {
 | 
			
		||||
        return setupNetwork(owner, offering, null, plan, name, displayText, isShared, isDefault);
 | 
			
		||||
        return setupNetwork(owner, offering, null, plan, name, displayText, isShared, isDefault, false);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    @DB
 | 
			
		||||
    public List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, Network predefined, DeploymentPlan plan, String name, String displayText, boolean isShared, boolean isDefault) throws ConcurrentOperationException {
 | 
			
		||||
    public List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, Network predefined, DeploymentPlan plan, String name, String displayText, boolean isShared, boolean isDefault, boolean errorIfAlreadySetup) throws ConcurrentOperationException {
 | 
			
		||||
        Transaction.currentTxn();
 | 
			
		||||
        Account locked = _accountDao.acquireInLockTable(owner.getId());
 | 
			
		||||
        if (locked == null) {
 | 
			
		||||
@ -792,17 +792,27 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
 | 
			
		||||
                    if (s_logger.isDebugEnabled()) {
 | 
			
		||||
                        s_logger.debug("Found existing network configuration for offering " + offering + ": " + configs.get(0));
 | 
			
		||||
                    }
 | 
			
		||||
                    
 | 
			
		||||
                    if (errorIfAlreadySetup) {
 | 
			
		||||
                        throw new InvalidParameterValueException("Found existing network configuration for offering " + offering + ": " + configs.get(0));
 | 
			
		||||
                    } else {
 | 
			
		||||
                        return configs;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            } else if (predefined != null && predefined.getCidr() != null && predefined.getBroadcastUri() == null && predefined.getBroadcastUri() == null) {
 | 
			
		||||
                List<NetworkVO> configs = _networksDao.listBy(owner.getId(), offering.getId(), plan.getDataCenterId(), predefined.getCidr());
 | 
			
		||||
                if (configs.size() > 0) {
 | 
			
		||||
                    if (s_logger.isDebugEnabled()) {
 | 
			
		||||
                        s_logger.debug("Found existing network configuration for offering " + offering + ": " + configs.get(0));
 | 
			
		||||
                    }
 | 
			
		||||
                    
 | 
			
		||||
                    if (errorIfAlreadySetup) {
 | 
			
		||||
                        throw new InvalidParameterValueException("Found existing network configuration for offering " + offering + ": " + configs.get(0));
 | 
			
		||||
                    } else {
 | 
			
		||||
                        return configs;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            List<NetworkVO> configs = new ArrayList<NetworkVO>();
 | 
			
		||||
 | 
			
		||||
@ -1492,7 +1502,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        List<NetworkVO> networks = setupNetwork(owner, networkOffering, userNetwork, plan, name, displayText, isShared, isDefault);
 | 
			
		||||
        List<NetworkVO> networks = setupNetwork(owner, networkOffering, userNetwork, plan, name, displayText, isShared, isDefault, true);
 | 
			
		||||
 | 
			
		||||
        Network network = null;
 | 
			
		||||
        if (networks == null || networks.isEmpty()) {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user