mirror of https://github.com/apache/cloudstack.git
template list fix
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
This commit is contained in:
parent
99115b9f09
commit
33321f00ce
|
|
@ -175,7 +175,7 @@ public interface HostDao extends GenericDao<HostVO, Long>, StateDao<Status, Stat
|
|||
|
||||
List<Long> listAllIds();
|
||||
|
||||
List<HypervisorType> findDistinctHypervisorTypesForZone(final long zoneId);
|
||||
List<HypervisorType> listDistinctHypervisorTypes(final Long zoneId);
|
||||
|
||||
List<Long> listAllHostIdsInCluster(final long clusterId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1562,14 +1562,16 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<HypervisorType> findDistinctHypervisorTypesForZone(long zoneId) {
|
||||
public List<HypervisorType> listDistinctHypervisorTypes(final Long zoneId) {
|
||||
GenericSearchBuilder<HostVO, HypervisorType> sb = createSearchBuilder(HypervisorType.class);
|
||||
sb.and("zoneId", sb.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
sb.and("type", sb.entity().getType(), SearchCriteria.Op.EQ);
|
||||
sb.select(null, Func.DISTINCT, sb.entity().getHypervisorType());
|
||||
sb.done();
|
||||
SearchCriteria<HypervisorType> sc = sb.create();
|
||||
sc.setParameters("zoneId", zoneId);
|
||||
if (zoneId != null) {
|
||||
sc.setParameters("zoneId", zoneId);
|
||||
}
|
||||
sc.setParameters("type", Type.Routing);
|
||||
return customSearch(sc, null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -546,19 +546,14 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||
|
||||
@Override
|
||||
public List<VMTemplateVO> listAllReadySystemVMTemplates(Long zoneId) {
|
||||
List<HypervisorType> availableHypervisors = null;
|
||||
if (zoneId != null) {
|
||||
availableHypervisors = _hostDao.findDistinctHypervisorTypesForZone(zoneId);
|
||||
if (CollectionUtils.isEmpty(availableHypervisors)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<HypervisorType> availableHypervisors = _hostDao.listDistinctHypervisorTypes(zoneId);
|
||||
if (CollectionUtils.isEmpty(availableHypervisors)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
SearchCriteria<VMTemplateVO> sc = readySystemTemplateSearch.create();
|
||||
sc.setParameters("templateType", Storage.TemplateType.SYSTEM);
|
||||
sc.setParameters("state", VirtualMachineTemplate.State.Active);
|
||||
if (CollectionUtils.isNotEmpty(availableHypervisors)) {
|
||||
sc.setParameters("hypervisorType", availableHypervisors.toArray());
|
||||
}
|
||||
sc.setParameters("hypervisorType", availableHypervisors.toArray());
|
||||
sc.setJoinParameters("vmTemplateJoinTemplateStoreRef", "downloadState",
|
||||
List.of(VMTemplateStorageResourceAssoc.Status.DOWNLOADED,
|
||||
VMTemplateStorageResourceAssoc.Status.BYPASSED).toArray());
|
||||
|
|
|
|||
Loading…
Reference in New Issue