|
44 | 44 | import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; |
45 | 45 | import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; |
46 | 46 | import org.apache.cloudstack.utils.identity.ManagementServerNode; |
47 | | - |
48 | 47 | import org.apache.log4j.Logger; |
49 | 48 |
|
50 | | - |
51 | | - |
52 | | - |
53 | | - |
54 | | - |
55 | 49 | import com.cloud.capacity.CapacityManager; |
56 | 50 | import com.cloud.capacity.dao.CapacityDao; |
57 | 51 | import com.cloud.configuration.Config; |
|
61 | 55 | import com.cloud.dc.DataCenter; |
62 | 56 | import com.cloud.dc.DataCenterVO; |
63 | 57 | import com.cloud.dc.DedicatedResourceVO; |
64 | | -import com.cloud.dc.HostPodVO; |
65 | 58 | import com.cloud.dc.Pod; |
66 | 59 | import com.cloud.dc.dao.ClusterDao; |
67 | 60 | import com.cloud.dc.dao.DataCenterDao; |
|
100 | 93 | import com.cloud.utils.component.Manager; |
101 | 94 | import com.cloud.utils.component.ManagerBase; |
102 | 95 | import com.cloud.utils.db.DB; |
103 | | -import com.cloud.utils.db.JoinBuilder; |
104 | | -import com.cloud.utils.db.SearchBuilder; |
105 | 96 | import com.cloud.utils.db.SearchCriteria; |
106 | 97 | import com.cloud.utils.db.Transaction; |
107 | 98 | import com.cloud.utils.exception.CloudRuntimeException; |
@@ -466,39 +457,22 @@ private void checkForNonDedicatedResources(VirtualMachineProfile vmProfile, Data |
466 | 457 | DedicatedResourceVO dedicatedZone = _dedicatedDao.findByZoneId(dc.getId()); |
467 | 458 | if (dedicatedZone != null && dedicatedZone.getDomainId() != null) { |
468 | 459 | throw new CloudRuntimeException("Failed to deploy VM. Zone " + dc.getName() + " is dedicated . Please use Explicit Dedication Affinity Group"); |
469 | | - } |
470 | | - |
471 | | - List<HostPodVO> podsInDc = _podDao.listByDataCenterId(dc.getId()); |
472 | | - for (HostPodVO pod : podsInDc) { |
473 | | - DedicatedResourceVO dedicatedPod = _dedicatedDao.findByPodId(pod.getId()); |
474 | | - if (dedicatedPod != null) { |
475 | | - avoids.addPod(dedicatedPod.getPodId()); |
476 | | - if (s_logger.isDebugEnabled()) { |
477 | | - s_logger.debug("Cannot use this dedicated pod " + pod.getName() + "."); |
478 | | - } |
479 | | - } |
480 | | - } |
| 460 | + } |
481 | 461 |
|
482 | | - List<ClusterVO> clusterInDc = _clusterDao.listClustersByDcId(dc.getId()); |
483 | | - for (ClusterVO cluster : clusterInDc) { |
484 | | - DedicatedResourceVO dedicatedCluster = _dedicatedDao.findByClusterId(cluster.getId()); |
485 | | - if (dedicatedCluster != null) { |
486 | | - avoids.addCluster(dedicatedCluster.getClusterId()); |
487 | | - if (s_logger.isDebugEnabled()) { |
488 | | - s_logger.debug("Cannot use this dedicated Cluster " + cluster.getName() + "."); |
489 | | - } |
490 | | - } |
491 | | - } |
492 | | - List<HostVO> hostInDc = _hostDao.listByDataCenterId(dc.getId()); |
493 | | - for (HostVO host : hostInDc) { |
494 | | - DedicatedResourceVO dedicatedHost = _dedicatedDao.findByHostId(host.getId()); |
495 | | - if (dedicatedHost != null) { |
496 | | - avoids.addHost(dedicatedHost.getHostId()); |
497 | | - if (s_logger.isDebugEnabled()) { |
498 | | - s_logger.debug("Cannot use this dedicated host " + host.getName() + "."); |
499 | | - } |
500 | | - } |
501 | | - } |
| 462 | + List<Long> allPodsInDc = _podDao.listAllPods(dc.getId()); |
| 463 | + List<Long> allDedicatedPods = _dedicatedDao.listAllPods(); |
| 464 | + allPodsInDc.retainAll(allDedicatedPods); |
| 465 | + avoids.addPodList(allPodsInDc); |
| 466 | + |
| 467 | + List<Long> allClustersInDc = _clusterDao.listAllCusters(dc.getId()); |
| 468 | + List<Long> allDedicatedClusters = _dedicatedDao.listAllClusters(); |
| 469 | + allClustersInDc.retainAll(allDedicatedClusters); |
| 470 | + avoids.addClusterList(allClustersInDc); |
| 471 | + |
| 472 | + List<Long> allHostsInDc = _hostDao.listAllHosts(dc.getId()); |
| 473 | + List<Long> allDedicatedHosts = _dedicatedDao.listAllHosts(); |
| 474 | + allHostsInDc.retainAll(allDedicatedHosts); |
| 475 | + avoids.addHostList(allHostsInDc); |
502 | 476 | } |
503 | 477 | } |
504 | 478 |
|
|
0 commit comments