Fixed Direct Account specific network creation

This commit is contained in:
alena 2011-11-04 18:01:32 -07:00
parent 17a7b7cda4
commit 2ef551874a
3 changed files with 17 additions and 18 deletions

View File

@ -168,18 +168,18 @@ public class CreateNetworkCmd extends BaseCmd {
if (offering == null) {
throw new InvalidParameterValueException("Unable to find network offering by id " + networkOfferingId);
}
if (offering.getGuestType() == GuestType.Shared) {
if (physicalNetworkId != null) {
if (physicalNetworkId != null) {
if (offering.getGuestType() == GuestType.Shared) {
return physicalNetworkId;
} else if (zoneId != null) {
return _networkService.findPhysicalNetworkId(zoneId, offering.getTags());
} else {
throw new InvalidParameterValueException("Either zoneId or physicalNetworkId have to be specified for the network of type " + GuestType.Shared);
throw new InvalidParameterValueException("Physical network id can be specified for networks of guest ip type " + GuestType.Shared + " only.");
}
} else if (physicalNetworkId != null) {
throw new InvalidParameterValueException("Physical network id can be specified for networks of guest ip type " + GuestType.Shared + " only.");
} else {
return null;
if (zoneId == null) {
throw new InvalidParameterValueException("ZoneId is required as physicalNetworkId is null");
}
return _networkService.findPhysicalNetworkId(zoneId, offering.getTags());
}
}

View File

@ -1049,8 +1049,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
if (locked == null) {
throw new ConcurrentOperationException("Unable to acquire lock on " + owner);
}
try {
if (predefined == null || (predefined.getCidr() == null && predefined.getBroadcastUri() == null && predefined.getBroadcastDomainType() != BroadcastDomainType.Vlan)) {
List<NetworkVO> configs = _networksDao.listBy(owner.getId(), offering.getId(), plan.getDataCenterId());
if (configs.size() > 0) {
@ -1868,9 +1868,12 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
if (networkOffering.getGuestType() == Network.GuestType.Isolated) {
if (isDefault != null && !isDefault) {
throw new InvalidParameterValueException("Can specify isDefault parameter only for network of type " + Network.GuestType.Shared);
} else {
} else if (areServicesSupportedByNetworkOffering(networkOffering.getId(), Service.SourceNat)){
isDefault = true;
} else {
isDefault = false;
}
if (isShared != null && isShared) {
throw new InvalidParameterValueException("Can specify isShared parameter for " + Network.GuestType.Shared + " networks only");
}
@ -1898,11 +1901,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
throw new InvalidParameterValueException("Can't specify vlan because network offering doesn't support it");
}
// Don't allow to create guest isolated network with Vlan specified
if (networkOffering.getGuestType() == Network.GuestType.Isolated && vlanId != null) {
throw new InvalidParameterValueException("Can't specify vlan when create " + Network.GuestType.Isolated + " network");
}
// If networkDomain is not specified, take it from the global configuration
if (areServicesSupportedByNetworkOffering(networkOfferingId, Service.Dns)) {
Map<Network.Capability, String> dnsCapabilities = getServiceCapabilities(networkOfferingId, Service.Dns);

View File

@ -34,7 +34,6 @@ import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.network.IPAddressVO;
import com.cloud.network.Network;
import com.cloud.network.Network.GuestType;
import com.cloud.network.Network.Service;
import com.cloud.network.Network.State;
import com.cloud.network.NetworkManager;
@ -76,9 +75,11 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
NetworkOfferingDao _networkOfferingDao;
protected boolean canHandle(NetworkOffering offering, DataCenter dc) {
// this guru handles only non-system network with type=Shared and serviceNat service disabled
// this guru handles only non-system network with:
//1) type=Shared
//2) type=Isolated and Source nat service disabled
//TODO - after broadCastDomainType + physical network are introduced, don't rely on network type of the dc
if (dc.getNetworkType() == NetworkType.Advanced && offering.getGuestType() == Network.GuestType.Shared && !_networkMgr.areServicesSupportedByNetworkOffering(offering.getId(), Service.SourceNat)&& offering.getTrafficType() == TrafficType.Guest) {
if (dc.getNetworkType() == NetworkType.Advanced && !_networkMgr.areServicesSupportedByNetworkOffering(offering.getId(), Service.SourceNat)&& offering.getTrafficType() == TrafficType.Guest) {
if (_networkMgr.areServicesSupportedByNetworkOffering(offering.getId(), Service.SecurityGroup)) {
return true;
} else if (!offering.isSystemOnly()) {