|
74 | 74 | import com.cloud.service.dao.ServiceOfferingDao; |
75 | 75 | import com.cloud.storage.StoragePool; |
76 | 76 | import com.cloud.storage.VMTemplateStoragePoolVO; |
77 | | -import com.cloud.storage.VMTemplateVO; |
78 | 77 | import com.cloud.storage.Volume; |
79 | 78 | import com.cloud.storage.dao.DiskOfferingDao; |
80 | 79 | import com.cloud.storage.dao.VMTemplateDao; |
@@ -157,27 +156,19 @@ public ListResponse<UnmanagedInstanceResponse> listUnmanagedInstances(ListUnmana |
157 | 156 |
|
158 | 157 | List<HostVO> hosts = resourceManager.listHostsInClusterByStatus(clusterId, Status.Up); |
159 | 158 |
|
160 | | - List<VMTemplateVO> templates = new ArrayList<>(); |
| 159 | + List<String> templatesFilterList = new ArrayList<>(); |
161 | 160 |
|
162 | 161 | if (cluster.getHypervisorType() == Hypervisor.HypervisorType.VMware) { // Add filter for templates for VMware |
163 | | - try { |
164 | | - templates.addAll(templateDao.listAll()); |
165 | | - } catch (Exception e) { |
166 | | - LOGGER.warn(String.format("Unable to retrieve vm templates for cluster's zone ID: %s", cluster.getDataCenterId())); |
| 162 | + List<VMTemplateStoragePoolVO> templates = templatePoolDao.listAll(); |
| 163 | + for (VMTemplateStoragePoolVO template : templates) { |
| 164 | + templatesFilterList.add(template.getInstallPath()); |
167 | 165 | } |
168 | 166 | } |
169 | 167 |
|
170 | 168 | List<UnmanagedInstanceResponse> responses = new ArrayList<>(); |
171 | 169 | for (HostVO host : hosts) { |
172 | 170 | List<String> managedVms = new ArrayList<>(); |
173 | | - if (cluster.getHypervisorType() == Hypervisor.HypervisorType.VMware) { // Add filter for templates for VMware |
174 | | - for (VMTemplateVO template : templates) { |
175 | | - VMTemplateStoragePoolVO templateStoragePoolVO = templatePoolDao.findByPoolTemplate(host.getId(), template.getId()); |
176 | | - if (templateStoragePoolVO != null) { |
177 | | - managedVms.add(templateStoragePoolVO.getInstallPath()); |
178 | | - } |
179 | | - } |
180 | | - } |
| 171 | + managedVms.addAll(templatesFilterList); |
181 | 172 | try { |
182 | 173 | ListVMsCmdByAdmin vmsCmd = new ListVMsCmdByAdmin(); |
183 | 174 | vmsCmd = ComponentContext.inject(vmsCmd); |
|
0 commit comments