mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-4104: VM Creation should fail if a zone is dedicated to a domain and user of the same domain deploys vm without using affinity group "Explicit Dedication".
This commit is contained in:
parent
78d344b849
commit
61c7aa7afe
@ -462,24 +462,8 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
|
|||||||
if (!isExplicit && vm.getType() == VirtualMachine.Type.User) {
|
if (!isExplicit && vm.getType() == VirtualMachine.Type.User) {
|
||||||
//add explicitly dedicated resources in avoidList
|
//add explicitly dedicated resources in avoidList
|
||||||
DedicatedResourceVO dedicatedZone = _dedicatedDao.findByZoneId(dc.getId());
|
DedicatedResourceVO dedicatedZone = _dedicatedDao.findByZoneId(dc.getId());
|
||||||
if (dedicatedZone != null) {
|
if (dedicatedZone != null && dedicatedZone.getDomainId() != null) {
|
||||||
long accountDomainId = vmProfile.getOwner().getDomainId();
|
throw new CloudRuntimeException("Failed to deploy VM. Zone " + dc.getName() + " is dedicated . Please use Explicit Dedication Affinity Group");
|
||||||
long accountId = vmProfile.getOwner().getAccountId();
|
|
||||||
if (dedicatedZone.getDomainId() != null && !dedicatedZone.getDomainId().equals(accountDomainId)) {
|
|
||||||
throw new CloudRuntimeException("Failed to deploy VM. Zone " + dc.getName() + " is dedicated.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// If a zone is dedicated to an account then all hosts in this zone will be explicitly dedicated to
|
|
||||||
// that account. So there won't be any shared hosts in the zone, the only way to deploy vms from that
|
|
||||||
// account will be to use explicit dedication affinity group.
|
|
||||||
if (dedicatedZone.getAccountId() != null) {
|
|
||||||
if (dedicatedZone.getAccountId().equals(accountId)) {
|
|
||||||
throw new CloudRuntimeException("Failed to deploy VM. There are no shared hosts available in" +
|
|
||||||
" this dedicated zone.");
|
|
||||||
} else {
|
|
||||||
throw new CloudRuntimeException("Failed to deploy VM. Zone " + dc.getName() + " is dedicated.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<HostPodVO> podsInDc = _podDao.listByDataCenterId(dc.getId());
|
List<HostPodVO> podsInDc = _podDao.listByDataCenterId(dc.getId());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user