mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	Filter out networks without access while getting networks with SG with free IPs (#9596)
This commit is contained in:
		
							parent
							
								
									0a93dcec74
								
							
						
					
					
						commit
						9df783ca4b
					
				| @ -149,7 +149,7 @@ public interface NetworkModel { | ||||
| 
 | ||||
|     boolean areServicesSupportedByNetworkOffering(long networkOfferingId, Service... services); | ||||
| 
 | ||||
|     Network getNetworkWithSGWithFreeIPs(Long zoneId); | ||||
|     Network getNetworkWithSGWithFreeIPs(Account account, Long zoneId); | ||||
| 
 | ||||
|     Network getNetworkWithSecurityGroupEnabled(Long zoneId); | ||||
| 
 | ||||
|  | ||||
| @ -789,13 +789,19 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel, Confi | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public NetworkVO getNetworkWithSGWithFreeIPs(Long zoneId) { | ||||
|     public NetworkVO getNetworkWithSGWithFreeIPs(Account account, Long zoneId) { | ||||
|         List<NetworkVO> networks = _networksDao.listByZoneSecurityGroup(zoneId); | ||||
|         if (networks == null || networks.isEmpty()) { | ||||
|             return null; | ||||
|         } | ||||
|         NetworkVO ret_network = null; | ||||
|         for (NetworkVO nw : networks) { | ||||
|             try { | ||||
|                 checkAccountNetworkPermissions(account, nw); | ||||
|             } catch (PermissionDeniedException e) { | ||||
|                 continue; | ||||
|             } | ||||
| 
 | ||||
|             List<VlanVO> vlans = _vlanDao.listVlansByNetworkId(nw.getId()); | ||||
|             for (VlanVO vlan : vlans) { | ||||
|                 if (_ipAddressDao.countFreeIpsInVlan(vlan.getId()) > 0) { | ||||
|  | ||||
| @ -3653,7 +3653,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir | ||||
| 
 | ||||
|         // If no network is specified, find system security group enabled network | ||||
|         if (networkIdList == null || networkIdList.isEmpty()) { | ||||
|             Network networkWithSecurityGroup = _networkModel.getNetworkWithSGWithFreeIPs(zone.getId()); | ||||
|             Network networkWithSecurityGroup = _networkModel.getNetworkWithSGWithFreeIPs(owner, zone.getId()); | ||||
|             if (networkWithSecurityGroup == null) { | ||||
|                 throw new InvalidParameterValueException("No network with security enabled is found in zone id=" + zone.getUuid()); | ||||
|             } | ||||
| @ -8536,7 +8536,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir | ||||
|     private Network getNetworkForOvfNetworkMapping(DataCenter zone, Account owner) throws InsufficientCapacityException, ResourceAllocationException { | ||||
|         Network network = null; | ||||
|         if (zone.isSecurityGroupEnabled()) { | ||||
|             network = _networkModel.getNetworkWithSGWithFreeIPs(zone.getId()); | ||||
|             network = _networkModel.getNetworkWithSGWithFreeIPs(owner, zone.getId()); | ||||
|             if (network == null) { | ||||
|                 throw new InvalidParameterValueException("No network with security enabled is found in zone ID: " + zone.getUuid()); | ||||
|             } | ||||
|  | ||||
| @ -237,7 +237,7 @@ public class MockNetworkModelImpl extends ManagerBase implements NetworkModel { | ||||
|      * @see com.cloud.network.NetworkModel#getNetworkWithSGWithFreeIPs(java.lang.Long) | ||||
|      */ | ||||
|     @Override | ||||
|     public NetworkVO getNetworkWithSGWithFreeIPs(Long zoneId) { | ||||
|     public NetworkVO getNetworkWithSGWithFreeIPs(Account account, Long zoneId) { | ||||
|         // TODO Auto-generated method stub | ||||
|         return null; | ||||
|     } | ||||
|  | ||||
| @ -248,7 +248,7 @@ public class MockNetworkModelImpl extends ManagerBase implements NetworkModel { | ||||
|      * @see com.cloud.network.NetworkModel#getNetworkWithSGWithFreeIPs(java.lang.Long) | ||||
|      */ | ||||
|     @Override | ||||
|     public NetworkVO getNetworkWithSGWithFreeIPs(Long zoneId) { | ||||
|     public NetworkVO getNetworkWithSGWithFreeIPs(Account account, Long zoneId) { | ||||
|         // TODO Auto-generated method stub | ||||
|         return null; | ||||
|     } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user