mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
if networkID is not specified, get one network with free ips.
This commit is contained in:
parent
96f092a0a9
commit
df6ce24f43
@ -92,6 +92,8 @@ public interface NetworkModel {
|
||||
|
||||
boolean areServicesSupportedByNetworkOffering(long networkOfferingId, Service... services);
|
||||
|
||||
Network getNetworkWithSGWithFreeIPs(Long zoneId);
|
||||
|
||||
Network getNetworkWithSecurityGroupEnabled(Long zoneId);
|
||||
|
||||
String getIpOfNetworkElementInVirtualNetwork(long accountId, long dataCenterId);
|
||||
@ -277,4 +279,4 @@ public interface NetworkModel {
|
||||
boolean getNetworkEgressDefaultPolicy(Long networkId);
|
||||
|
||||
void checkNetworkPermissions(Account owner, Network network, AccessType accessType);
|
||||
}
|
||||
}
|
||||
|
||||
@ -740,6 +740,31 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
|
||||
return networks.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkVO getNetworkWithSGWithFreeIPs(Long zoneId) {
|
||||
List<NetworkVO> networks = _networksDao.listByZoneSecurityGroup(zoneId);
|
||||
if (networks == null || networks.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
NetworkVO ret_network = null;
|
||||
for (NetworkVO nw : networks) {
|
||||
List<VlanVO> vlans = _vlanDao.listVlansByNetworkId(nw.getId());
|
||||
for (VlanVO vlan : vlans) {
|
||||
if (_ipAddressDao.countFreeIpsInVlan(vlan.getId()) > 0) {
|
||||
ret_network = nw;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ret_network != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ret_network == null) {
|
||||
s_logger.debug("Can not find network with security group enabled with free IPs");
|
||||
}
|
||||
return ret_network;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkVO getNetworkWithSecurityGroupEnabled(Long zoneId) {
|
||||
List<NetworkVO> networks = _networksDao.listByZoneSecurityGroup(zoneId);
|
||||
|
||||
@ -2350,7 +2350,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.getNetworkWithSecurityGroupEnabled(zone.getId());
|
||||
Network networkWithSecurityGroup = _networkModel.getNetworkWithSGWithFreeIPs(zone.getId());
|
||||
if (networkWithSecurityGroup == null) {
|
||||
throw new InvalidParameterValueException("No network with security enabled is found in zone id=" + zone.getId());
|
||||
}
|
||||
|
||||
@ -229,6 +229,15 @@ public class MockNetworkModelImpl extends ManagerBase implements NetworkModel {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.network.NetworkModel#getNetworkWithSGWithFreeIPs(java.lang.Long)
|
||||
*/
|
||||
@Override
|
||||
public NetworkVO getNetworkWithSGWithFreeIPs(Long zoneId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.network.NetworkModel#getNetworkWithSecurityGroupEnabled(java.lang.Long)
|
||||
*/
|
||||
|
||||
@ -240,6 +240,15 @@ public class MockNetworkModelImpl extends ManagerBase implements NetworkModel {
|
||||
return (_ntwkOfferingSrvcDao.areServicesSupportedByNetworkOffering(networkOfferingId, services));
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.network.NetworkModel#getNetworkWithSGWithFreeIPs(java.lang.Long)
|
||||
*/
|
||||
@Override
|
||||
public NetworkVO getNetworkWithSGWithFreeIPs(Long zoneId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.network.NetworkModel#getNetworkWithSecurityGroupEnabled(java.lang.Long)
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user