private void checkForNonDedicatedResources(VirtualMachineProfile<? extends VirtualMachine> vmProfile, DataCenter dc, ExcludeList avoids) {
boolean isExplicit = false;
VirtualMachine vm = vmProfile.getVirtualMachine();
// check if zone is dedicated. if yes check if vm owner has acess to it.
DedicatedResourceVO dedicatedZone = _dedicatedDao.findByZoneId(dc.getId());
if (dedicatedZone != null) {
long accountDomainId = vmProfile.getOwner().getDomainId();
long accountId = vmProfile.getOwner().getAccountId();
// 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)) {
return;
} else {
throw new CloudRuntimeException("Failed to deploy VM, Zone " + dc.getName()
+ " not available for the user account " + vmProfile.getOwner());
}
}
// if zone is dedicated to a domain. Check owner's access to the
// domain level dedication group
if (!_affinityGroupService.isAffinityGroupAvailableInDomain(dedicatedZone.getAffinityGroupId(),
accountDomainId)) {
throw new CloudRuntimeException("Failed to deploy VM, Zone " + dc.getName()
+ " not available for the user domain " + vmProfile.getOwner());
}