mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 11:52:28 +01:00
bug 10799: propagate to main
This commit is contained in:
parent
99e465f2fa
commit
f82aa97273
@ -25,20 +25,20 @@ import com.cloud.utils.SerialVersionUID;
|
||||
*/
|
||||
public abstract class InsufficientCapacityException extends Exception {
|
||||
private static final long serialVersionUID = SerialVersionUID.InsufficientCapacityException;
|
||||
|
||||
|
||||
Long id;
|
||||
Class<?> scope;
|
||||
|
||||
protected InsufficientCapacityException() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
public InsufficientCapacityException(String msg, Class<?> scope, Long id) {
|
||||
super(msg);
|
||||
this.scope = scope;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return scope where we are insufficient. The possible classes are
|
||||
* Host, StoragePool, Cluster, Pod, DataCenter, NetworkConfiguration.
|
||||
@ -46,7 +46,7 @@ public abstract class InsufficientCapacityException extends Exception {
|
||||
public Class<?> getScope() {
|
||||
return scope;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the id of the object that it is insufficient in. Note that this method is
|
||||
* marked such that if the id is not set, then it will throw NullPointerException.
|
||||
@ -56,4 +56,9 @@ public abstract class InsufficientCapacityException extends Exception {
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
String str = super.toString();
|
||||
return str + "Scope=" + scope + "; id=" + id;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1009,7 +1009,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
if (tableName.equals("host_pod_ref") || tableName.equals("host") || tableName.equals("volumes")) {
|
||||
selectSql += " AND removed is NULL";
|
||||
}
|
||||
|
||||
|
||||
if (tableName.equals("vm_instance")) {
|
||||
selectSql += " AND state != '" + VirtualMachine.State.Expunging.toString() + "'";
|
||||
}
|
||||
@ -1570,7 +1570,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
throw new InvalidParameterValueException("Please specify a valid domain id");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
boolean localStorageRequired = false;
|
||||
String storageType = cmd.getStorageType();
|
||||
if (storageType == null) {
|
||||
@ -1608,7 +1608,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
vm_type = VirtualMachine.Type.DomainRouter;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return createServiceOffering(userId, cmd.getIsSystem(), vm_type, cmd.getServiceOfferingName(), cpuNumber.intValue(), memory.intValue(), cpuSpeed.intValue(), cmd.getDisplayText(), localStorageRequired, offerHA,
|
||||
limitCpuUse, cmd.getTags(), cmd.getDomainId(), cmd.getHostTag());
|
||||
}
|
||||
@ -1642,7 +1642,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
|
||||
// Verify input parameters
|
||||
ServiceOffering offeringHandle = getServiceOffering(id);
|
||||
|
||||
|
||||
if (offeringHandle == null) {
|
||||
throw new InvalidParameterValueException("unable to find service offering " + id);
|
||||
}
|
||||
@ -1837,7 +1837,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
if (offering == null) {
|
||||
throw new InvalidParameterValueException("unable to find service offering " + offeringId);
|
||||
}
|
||||
|
||||
|
||||
if(offering.getDefaultUse()){
|
||||
throw new InvalidParameterValueException("Default service offerings cannot be deleted");
|
||||
}
|
||||
@ -2182,9 +2182,9 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
throw new InvalidParameterValueException("The IP range with tag: " + vlan.getVlanTag() + " in zone " + zone.getName()
|
||||
+ " has the same subnet. Please specify a different gateway/netmask.");
|
||||
}
|
||||
|
||||
|
||||
boolean vlansUntaggedAndVirtual = (vlanId.equals(Vlan.UNTAGGED) && vlanId.equals(vlan.getVlanTag()) && forVirtualNetwork && vlan.getVlanType() == VlanType.VirtualNetwork);
|
||||
|
||||
|
||||
if (vlansUntaggedAndVirtual && !newVlanSubnet.equals(otherVlanSubnet)) {
|
||||
throw new InvalidParameterValueException("The Untagged ip range with different subnet already exists in zone " + zone.getId());
|
||||
}
|
||||
@ -2400,9 +2400,9 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
IPRangeConfig config = new IPRangeConfig();
|
||||
config.savePublicIPRange(txn, startIPLong, endIPLong, zoneId, vlanDbId, sourceNetworkid);
|
||||
List<String> problemIps = config.savePublicIPRange(txn, startIPLong, endIPLong, zoneId, vlanDbId, sourceNetworkid);
|
||||
txn.commit();
|
||||
return true;
|
||||
return problemIps != null && problemIps.size() == 0;
|
||||
}
|
||||
|
||||
@DB
|
||||
@ -3152,7 +3152,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
if (offering != null && offering.getRemoved() == null) {
|
||||
return offering;
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -3185,14 +3185,14 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
|
||||
return networkRate;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public DiskOffering getDiskOffering(long diskOfferingId) {
|
||||
DiskOfferingVO offering = _diskOfferingDao.findById(diskOfferingId);
|
||||
if (offering != null && offering.getRemoved() == null) {
|
||||
return offering;
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -57,13 +57,13 @@ import com.cloud.dc.AccountVlanMapVO;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.DataCenter.NetworkType;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.Pod;
|
||||
import com.cloud.dc.PodVlanMapVO;
|
||||
import com.cloud.dc.Vlan;
|
||||
import com.cloud.dc.Vlan.VlanType;
|
||||
import com.cloud.dc.VlanVO;
|
||||
import com.cloud.dc.dao.AccountVlanMapDao;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.dc.dao.HostPodDao;
|
||||
import com.cloud.dc.dao.PodVlanMapDao;
|
||||
import com.cloud.dc.dao.VlanDao;
|
||||
import com.cloud.deploy.DataCenterDeployment;
|
||||
@ -214,7 +214,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
NetworkDomainDao _networkDomainDao;
|
||||
@Inject
|
||||
VMInstanceDao _vmDao;
|
||||
|
||||
|
||||
@Inject DomainRouterDao _routerDao;
|
||||
|
||||
private final HashMap<String, NetworkOfferingVO> _systemNetworks = new HashMap<String, NetworkOfferingVO>(5);
|
||||
@ -235,7 +235,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
boolean _supportDomainLevelVirtualNetwork;
|
||||
|
||||
private Map<String, String> _configs;
|
||||
|
||||
|
||||
|
||||
HashMap<Long, Long> _lastNetworkIdsToFree = new HashMap<Long, Long>();
|
||||
|
||||
@ -286,8 +286,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
|
||||
if (addrs.size() == 0) {
|
||||
if (podId != null) {
|
||||
s_logger.warn(errorMessage.toString());
|
||||
throw new InsufficientAddressCapacityException("Insufficient address capacity", HostPodDao.class, podId);
|
||||
throw new InsufficientAddressCapacityException("Insufficient address capacity", Pod.class, podId);
|
||||
}
|
||||
s_logger.warn(errorMessage.toString());
|
||||
throw new InsufficientAddressCapacityException("Insufficient address capacity", DataCenter.class, dcId);
|
||||
@ -815,7 +814,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
NicForTrafficTypeSearch.done();
|
||||
|
||||
_executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("Network-Scavenger"));
|
||||
|
||||
|
||||
_allowSubdomainNetworkAccess = Boolean.valueOf(_configs.get(Config.SubDomainNetworkAccess.key()));
|
||||
_supportDomainLevelVirtualNetwork = Boolean.valueOf(_configs.get(Config.DomainVirtualNetgwork.key()));
|
||||
|
||||
@ -866,7 +865,7 @@ 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 {
|
||||
throws ConcurrentOperationException {
|
||||
return setupNetwork(owner, offering, null, plan, name, displayText, isShared, isDefault, false, null, null);
|
||||
}
|
||||
|
||||
@ -1768,7 +1767,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
if (!NetUtils.verifyDomainName(networkDomain)) {
|
||||
throw new InvalidParameterValueException(
|
||||
"Invalid network domain. Total length shouldn't exceed 190 chars. Each domain label must be between 1 and 63 characters long, can contain ASCII letters 'a' through 'z', the digits '0' through '9', "
|
||||
+ "and the hyphen ('-'); can't start or end with \"-\"");
|
||||
+ "and the hyphen ('-'); can't start or end with \"-\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1848,7 +1847,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
Long accountId = null;
|
||||
String path = null;
|
||||
Long sharedNetworkDomainId = null;
|
||||
|
||||
|
||||
//1) default is system to false if not specified
|
||||
//2) reset parameter to false if it's specified by the regular user
|
||||
if ((isSystem == null || caller.getType() == Account.ACCOUNT_TYPE_NORMAL) && id == null) {
|
||||
@ -1883,7 +1882,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
} else {
|
||||
accountId = caller.getId();
|
||||
}
|
||||
|
||||
|
||||
if ((isSystem == null || !isSystem) && (isShared == null || isShared)) {
|
||||
sharedNetworkDomainId = domainId;
|
||||
}
|
||||
@ -1902,7 +1901,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
SearchBuilder<DataCenterVO> zoneSearch = _dcDao.createSearchBuilder();
|
||||
zoneSearch.and("networkType", zoneSearch.entity().getNetworkType(), SearchCriteria.Op.EQ);
|
||||
sb.join("zoneSearch", zoneSearch, sb.entity().getDataCenterId(), zoneSearch.entity().getId(), JoinBuilder.JoinType.INNER);
|
||||
|
||||
|
||||
//domain level networks
|
||||
if (sharedNetworkDomainId != null) {
|
||||
SearchBuilder<NetworkDomainVO> domainNetworkSearch = _networkDomainDao.createSearchBuilder();
|
||||
@ -1912,9 +1911,9 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
sb.and("removed", sb.entity().getRemoved(), Op.NULL);
|
||||
|
||||
if (isSystem == null || !isSystem) {
|
||||
//Get domain level + account/zone level networks
|
||||
//Get domain level + account/zone level networks
|
||||
List<NetworkVO> networksToReturn = new ArrayList<NetworkVO>();
|
||||
|
||||
|
||||
if (sharedNetworkDomainId != null) {
|
||||
networksToReturn.addAll(listDomainLevelNetworks(buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, type, isDefault, trafficType, isShared), searchFilter, sharedNetworkDomainId, GuestIpType.Virtual));
|
||||
networksToReturn.addAll(listDomainLevelNetworks(buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, type, isDefault, trafficType, isShared), searchFilter, sharedNetworkDomainId, GuestIpType.Direct));
|
||||
@ -1925,22 +1924,20 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
sb.join("domainSearch", domainSearch, sb.entity().getDomainId(), domainSearch.entity().getId(), JoinBuilder.JoinType.INNER);
|
||||
networksToReturn.addAll(listDomainSpecificNetworks(buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, type, isDefault, trafficType, isShared), searchFilter, path));
|
||||
}
|
||||
|
||||
|
||||
if (accountId != null || (domainId == null && accountName == null)) {
|
||||
networksToReturn.addAll(listAccountSpecificAndZoneLevelNetworks(buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, type, isDefault, trafficType, isShared), searchFilter, accountId, path));
|
||||
}
|
||||
|
||||
|
||||
return networksToReturn;
|
||||
|
||||
|
||||
} else {
|
||||
return _networksDao.search(buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, type, isDefault, trafficType, isShared), searchFilter);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private SearchCriteria<NetworkVO> buildNetworkSearchCriteria(SearchBuilder<NetworkVO> sb, String keyword, Long id, Boolean isSystem, Long zoneId, String type, Boolean isDefault, String trafficType, Boolean isShared) {
|
||||
SearchCriteria<NetworkVO> sc = sb.create();
|
||||
|
||||
|
||||
if (isSystem != null) {
|
||||
sc.setJoinParameters("networkOfferingSearch", "systemOnly", isSystem);
|
||||
}
|
||||
@ -1966,15 +1963,15 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
if (isDefault != null) {
|
||||
sc.addAnd("isDefault", SearchCriteria.Op.EQ, isDefault);
|
||||
}
|
||||
|
||||
|
||||
if (trafficType != null) {
|
||||
sc.addAnd("trafficType", SearchCriteria.Op.EQ, trafficType);
|
||||
}
|
||||
|
||||
|
||||
if (isShared != null) {
|
||||
sc.addAnd("isShared", SearchCriteria.Op.EQ, isShared);
|
||||
}
|
||||
|
||||
|
||||
return sc;
|
||||
}
|
||||
|
||||
@ -1996,46 +1993,46 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
return _networksDao.search(sc, searchFilter);
|
||||
|
||||
}
|
||||
|
||||
|
||||
private List<NetworkVO> listAccountSpecificAndZoneLevelNetworks(SearchCriteria<NetworkVO> sc, Filter searchFilter, Long accountId, String path) {
|
||||
|
||||
|
||||
|
||||
SearchCriteria<NetworkVO> ssc = _networksDao.createSearchCriteria();
|
||||
|
||||
|
||||
//account level networks
|
||||
SearchCriteria<NetworkVO> accountSC = _networksDao.createSearchCriteria();
|
||||
if (accountId != null) {
|
||||
accountSC.addAnd("accountId", SearchCriteria.Op.EQ, accountId);
|
||||
}
|
||||
|
||||
|
||||
accountSC.addAnd("isShared", SearchCriteria.Op.EQ, false);
|
||||
if (path != null) {
|
||||
Set<Long> allowedDomains = _accountMgr.getDomainChildrenIds(path);
|
||||
accountSC.addAnd("domainId", SearchCriteria.Op.IN, allowedDomains.toArray());
|
||||
}
|
||||
|
||||
|
||||
ssc.addOr("id", SearchCriteria.Op.SC, accountSC);
|
||||
|
||||
|
||||
//zone level networks
|
||||
SearchCriteria<NetworkVO> zoneSC = _networksDao.createSearchCriteria();
|
||||
zoneSC.addAnd("isDomainSpecific", SearchCriteria.Op.EQ, false);
|
||||
zoneSC.addAnd("isShared", SearchCriteria.Op.EQ, true);
|
||||
ssc.addOr("id", SearchCriteria.Op.SC, zoneSC);
|
||||
|
||||
|
||||
sc.addAnd("id", SearchCriteria.Op.SC, ssc);
|
||||
|
||||
|
||||
return _networksDao.search(sc, searchFilter);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private List<NetworkVO> listDomainSpecificNetworks(SearchCriteria<NetworkVO> sc, Filter searchFilter, String path) {
|
||||
|
||||
|
||||
if (path != null) {
|
||||
sc.addAnd("isShared", SearchCriteria.Op.EQ, true);
|
||||
sc.addAnd("isDomainSpecific", SearchCriteria.Op.EQ, true);
|
||||
sc.setJoinParameters("domainSearch", "path", path + "%");
|
||||
}
|
||||
|
||||
|
||||
return _networksDao.search(sc, searchFilter);
|
||||
}
|
||||
|
||||
@ -2050,7 +2047,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
if (network == null) {
|
||||
throw new InvalidParameterValueException("unable to find network " + networkId);
|
||||
}
|
||||
|
||||
|
||||
//don't allow to delete system network
|
||||
NetworkOffering offering = _networkOfferingDao.findByIdIncludingRemoved(network.getNetworkOfferingId());
|
||||
if (offering.isSystemOnly()) {
|
||||
@ -2549,11 +2546,11 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
|
||||
@Override
|
||||
public Map<Capability, String> getServiceCapabilities(long zoneId, Long networkOfferingId, Service service) {
|
||||
|
||||
|
||||
if (!isServiceSupported(networkOfferingId, service)) {
|
||||
throw new UnsupportedServiceException("Service " + service.getName() + " is not by the network offering id=" + networkOfferingId);
|
||||
}
|
||||
|
||||
|
||||
Map<Service, Map<Capability, String>> networkCapabilities = getZoneCapabilities(zoneId);
|
||||
if (networkCapabilities.get(service) == null) {
|
||||
throw new UnsupportedServiceException("Service " + service.getName() + " is not supported in zone id=" + zoneId);
|
||||
@ -2895,7 +2892,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
|
||||
IPAddressVO ip = _ipAddressDao.findById(addrId);
|
||||
|
||||
|
||||
if (ip.getAllocatedToAccountId() == null && ip.getAllocatedTime() == null) {
|
||||
s_logger.trace("Ip address id=" + addrId + " is already released");
|
||||
return ip;
|
||||
@ -2938,8 +2935,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
|
||||
@Override
|
||||
public boolean isNetworkAvailableInDomain(long networkId, long domainId) {
|
||||
|
||||
|
||||
|
||||
|
||||
Long networkDomainId = null;
|
||||
Network network = getNetwork(networkId);
|
||||
if (!network.getIsShared()) {
|
||||
@ -2959,19 +2956,19 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
} else {
|
||||
networkDomainId = networkDomainMap.get(0).getDomainId();
|
||||
}
|
||||
|
||||
|
||||
if (domainId == networkDomainId.longValue()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_allowSubdomainNetworkAccess && network.getGuestType() == GuestIpType.Direct) {
|
||||
Set<Long> parentDomains = _accountMgr.getDomainParentIds(domainId);
|
||||
|
||||
|
||||
if (parentDomains.contains(domainId)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2995,7 +2992,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
if (network == null) {
|
||||
throw new InvalidParameterValueException("Network id=" + networkId + "doesn't exist in the system");
|
||||
}
|
||||
|
||||
|
||||
if (tags != null && tags.size() > 1) {
|
||||
throw new InvalidParameterException("Unable to support more than one tag on network yet");
|
||||
}
|
||||
@ -3007,29 +3004,26 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
if (offering.isSystemOnly() && network.getTrafficType() != TrafficType.Guest) {
|
||||
throw new InvalidParameterValueException("Can't update system networks");
|
||||
}
|
||||
|
||||
|
||||
//don't allow to modify network domain if the service is not supported
|
||||
if (domainSuffix != null) {
|
||||
// validate network domain
|
||||
if (!NetUtils.verifyDomainName(domainSuffix)) {
|
||||
throw new InvalidParameterValueException(
|
||||
"Invalid network domain. Total length shouldn't exceed 190 chars. Each domain label must be between 1 and 63 characters long, can contain ASCII letters 'a' through 'z', the digits '0' through '9', "
|
||||
+ "and the hyphen ('-'); can't start or end with \"-\"");
|
||||
+ "and the hyphen ('-'); can't start or end with \"-\"");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Map<Network.Capability, String> dnsCapabilities = getServiceCapabilities(network.getDataCenterId(), network.getNetworkOfferingId(), Service.Dns);
|
||||
String isUpdateDnsSupported = dnsCapabilities.get(Capability.AllowDnsSuffixModification);
|
||||
if (isUpdateDnsSupported == null || !Boolean.valueOf(isUpdateDnsSupported)) {
|
||||
throw new InvalidParameterValueException("Domain name change is not supported for network id=" + network.getNetworkOfferingId() + " in zone id=" + network.getDataCenterId());
|
||||
}
|
||||
|
||||
//restart network if it has active network elements
|
||||
List<DomainRouterVO> routers = _routerDao.listActive(networkId);
|
||||
if (!routers.isEmpty()) {
|
||||
restartNetwork = true;
|
||||
}
|
||||
|
||||
network.setNetworkDomain(domainSuffix);
|
||||
}
|
||||
|
||||
@ -3040,7 +3034,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
if (displayText != null) {
|
||||
network.setDisplayText(displayText);
|
||||
}
|
||||
|
||||
|
||||
if (tags != null) {
|
||||
network.setTags(tags);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user