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:
Pearl Dsilva 2021-09-02 10:58:58 +05:30 committed by GitHub
parent 8998479606
commit 557dc5e1a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 3 deletions

View File

@ -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);

View File

@ -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);
}

View File

@ -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) {