mirror of https://github.com/apache/cloudstack.git
api: List details of template download state for stores corresponding to a zone (#5379)
* api: List details of template download state for stores corresponding to a zone * fix test
This commit is contained in:
parent
8998479606
commit
557dc5e1a0
|
|
@ -66,7 +66,7 @@ public interface TemplateDataStoreDao extends GenericDao<TemplateDataStoreVO, Lo
|
|||
|
||||
List<TemplateDataStoreVO> listByTemplate(long templateId);
|
||||
|
||||
List<TemplateDataStoreVO> listByTemplateNotBypassed(long templateId);
|
||||
List<TemplateDataStoreVO> listByTemplateNotBypassed(long templateId, Long... storeIds);
|
||||
|
||||
TemplateDataStoreVO findByTemplateZoneReady(long templateId, Long zoneId);
|
||||
|
||||
|
|
|
|||
|
|
@ -99,6 +99,7 @@ public class TemplateDataStoreDaoImpl extends GenericDaoBase<TemplateDataStoreVO
|
|||
templateSearch.and("template_id", templateSearch.entity().getTemplateId(), SearchCriteria.Op.EQ);
|
||||
templateSearch.and("download_state", templateSearch.entity().getDownloadState(), SearchCriteria.Op.NEQ);
|
||||
templateSearch.and("destroyed", templateSearch.entity().getDestroyed(), SearchCriteria.Op.EQ);
|
||||
templateSearch.and("storeids", templateSearch.entity().getDataStoreId(), Op.IN);
|
||||
templateSearch.done();
|
||||
|
||||
templateRoleSearch = createSearchBuilder();
|
||||
|
|
@ -421,11 +422,12 @@ public class TemplateDataStoreDaoImpl extends GenericDaoBase<TemplateDataStoreVO
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<TemplateDataStoreVO> listByTemplateNotBypassed(long templateId) {
|
||||
public List<TemplateDataStoreVO> listByTemplateNotBypassed(long templateId, Long... storeIds) {
|
||||
SearchCriteria<TemplateDataStoreVO> sc = templateSearch.create();
|
||||
sc.setParameters("template_id", templateId);
|
||||
sc.setParameters("download_state", Status.BYPASSED);
|
||||
sc.setParameters("destroyed", false);
|
||||
sc.setParameters("storeids", storeIds);
|
||||
return search(sc, null);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -156,7 +156,9 @@ public class TemplateJoinDaoImpl extends GenericDaoBaseWithTagInformation<Templa
|
|||
|
||||
@Override
|
||||
public TemplateResponse newTemplateResponse(EnumSet<ApiConstants.DomainDetails> detailsView, ResponseView view, TemplateJoinVO template) {
|
||||
List<TemplateDataStoreVO> templatesInStore = _templateStoreDao.listByTemplateNotBypassed(template.getId());
|
||||
List<ImageStoreVO> storesInZone = dataStoreDao.listStoresByZoneId(template.getDataCenterId());
|
||||
Long[] storeIds = storesInZone.stream().map(ImageStoreVO::getId).toArray(Long[]::new);
|
||||
List<TemplateDataStoreVO> templatesInStore = _templateStoreDao.listByTemplateNotBypassed(template.getId(), storeIds);
|
||||
List<Map<String, String>> downloadProgressDetails = new ArrayList();
|
||||
HashMap<String, String> downloadDetailInImageStores = null;
|
||||
for (TemplateDataStoreVO templateInStore : templatesInStore) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue