|
24 | 24 | import javax.inject.Inject; |
25 | 25 | import javax.naming.ConfigurationException; |
26 | 26 |
|
| 27 | +import org.apache.cloudstack.extension.ExtensionResourceMap; |
27 | 28 | import org.apache.cloudstack.framework.extensions.dao.ExtensionDao; |
28 | 29 | import org.apache.cloudstack.framework.extensions.dao.ExtensionResourceMapDao; |
29 | 30 | import org.apache.cloudstack.framework.extensions.vo.ExtensionVO; |
30 | 31 | import org.apache.commons.collections.CollectionUtils; |
31 | 32 |
|
32 | | -import com.cloud.dc.ClusterVO; |
33 | 33 | import com.cloud.dc.DataCenter; |
34 | 34 | import com.cloud.dc.Pod; |
35 | 35 | import com.cloud.dc.dao.ClusterDao; |
|
39 | 39 | import com.cloud.deploy.DeploymentPlan; |
40 | 40 | import com.cloud.deploy.DeploymentPlanner; |
41 | 41 | import com.cloud.exception.InsufficientServerCapacityException; |
42 | | -import org.apache.cloudstack.extension.ExtensionResourceMap; |
43 | 42 | import com.cloud.host.Host; |
44 | 43 | import com.cloud.host.HostVO; |
45 | 44 | import com.cloud.host.dao.HostDao; |
@@ -103,22 +102,24 @@ public DeployDestination plan(VirtualMachineProfile vmProfile, DeploymentPlan pl |
103 | 102 | } |
104 | 103 | } |
105 | 104 |
|
106 | | - List<ClusterVO> clusters = clusterDao.listByDcHyType(vm.getDataCenterId(), HypervisorType.External.name()); |
| 105 | + List<Long> clusterIds = clusterDao.listEnabledClusterIdsByZoneHypervisorArch(vm.getDataCenterId(), |
| 106 | + HypervisorType.External, vmProfile.getTemplate().getArch()); |
107 | 107 | List<Long> extensionClusterIds = extensionResourceMapDao.listResourceIdsByExtensionIdAndType(extensionId, |
108 | 108 | ExtensionResourceMap.ResourceType.Cluster); |
109 | 109 | if (CollectionUtils.isEmpty(extensionClusterIds)) { |
110 | 110 | logger.error("No clusters associated with {} to plan deployment of external instance {}", |
111 | 111 | vmProfile.getInstanceName()); |
112 | 112 | return null; |
113 | 113 | } |
114 | | - clusters = clusters.stream() |
115 | | - .filter(c -> extensionClusterIds.contains(c.getId())) |
| 114 | + clusterIds = clusterIds.stream() |
| 115 | + .filter(extensionClusterIds::contains) |
116 | 116 | .collect(Collectors.toList()); |
117 | | - logger.debug("Found {} clusters associated with {}", clusters.size(), extensionVO); |
| 117 | + logger.debug("Found {} clusters associated with {}", clusterIds.size(), extensionVO); |
118 | 118 | HostVO target = null; |
119 | 119 | List<HostVO> hosts; |
120 | | - for (ClusterVO cluster : clusters) { |
121 | | - hosts = resourceMgr.listAllUpAndEnabledHosts(Host.Type.Routing, cluster.getId(), cluster.getPodId(), cluster.getDataCenterId()); |
| 120 | + for (Long clusterId : clusterIds) { |
| 121 | + hosts = resourceMgr.listAllUpAndEnabledHosts(Host.Type.Routing, clusterId, null, |
| 122 | + vm.getDataCenterId()); |
122 | 123 | if (hostTag != null) { |
123 | 124 | for (HostVO host : hosts) { |
124 | 125 | hostDao.loadHostTags(host); |
|
0 commit comments