Skip to content

Commit d25717c

Browse files
committed
fix for template listing in list API
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
1 parent 5210c66 commit d25717c

1 file changed

Lines changed: 5 additions & 14 deletions

File tree

server/src/main/java/org/apache/cloudstack/ingestion/VmIngestionManagerImpl.java

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@
7474
import com.cloud.service.dao.ServiceOfferingDao;
7575
import com.cloud.storage.StoragePool;
7676
import com.cloud.storage.VMTemplateStoragePoolVO;
77-
import com.cloud.storage.VMTemplateVO;
7877
import com.cloud.storage.Volume;
7978
import com.cloud.storage.dao.DiskOfferingDao;
8079
import com.cloud.storage.dao.VMTemplateDao;
@@ -157,27 +156,19 @@ public ListResponse<UnmanagedInstanceResponse> listUnmanagedInstances(ListUnmana
157156

158157
List<HostVO> hosts = resourceManager.listHostsInClusterByStatus(clusterId, Status.Up);
159158

160-
List<VMTemplateVO> templates = new ArrayList<>();
159+
List<String> templatesFilterList = new ArrayList<>();
161160

162161
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());
167165
}
168166
}
169167

170168
List<UnmanagedInstanceResponse> responses = new ArrayList<>();
171169
for (HostVO host : hosts) {
172170
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);
181172
try {
182173
ListVMsCmdByAdmin vmsCmd = new ListVMsCmdByAdmin();
183174
vmsCmd = ComponentContext.inject(vmsCmd);

0 commit comments

Comments
 (0)