mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Fix CLOUDSTACK-2469: default template is not downloaded.
This commit is contained in:
parent
bbdab9806d
commit
2102ede2e7
@ -340,11 +340,15 @@ public class TemplateServiceImpl implements TemplateService {
|
|||||||
}
|
}
|
||||||
if (tmpltStore != null && tmpltStore.getDownloadState() != Status.DOWNLOADED) {
|
if (tmpltStore != null && tmpltStore.getDownloadState() != Status.DOWNLOADED) {
|
||||||
s_logger.info("Template Sync did not find " + uniqueName + " ready on image store " + storeId + ", will request download to start/resume shortly");
|
s_logger.info("Template Sync did not find " + uniqueName + " ready on image store " + storeId + ", will request download to start/resume shortly");
|
||||||
|
s_logger.info("Removing template " + uniqueName + " from template store table");
|
||||||
|
// remove those leftover entries
|
||||||
|
_vmTemplateStoreDao.remove(tmpltStore.getId());
|
||||||
|
|
||||||
} else if (tmpltStore == null) {
|
} else if (tmpltStore == null) {
|
||||||
s_logger.info("Template Sync did not find " + uniqueName + " on the image store " + storeId + ", will request download shortly");
|
s_logger.info("Template Sync did not find " + uniqueName + " on the image store " + storeId + ", will request download shortly");
|
||||||
TemplateDataStoreVO templtStore = new TemplateDataStoreVO(storeId, tmplt.getId(), new Date(), 0, Status.NOT_DOWNLOADED, null, null, null, null, tmplt.getUrl());
|
// persist template_zone_ref table
|
||||||
_vmTemplateStoreDao.persist(templtStore);
|
// TODO: we may have some bugs in removing these entries in case of failure, maybe we should pass another callback below in invoking createTemplateAsync
|
||||||
|
// to just clear those entries.
|
||||||
associateTemplateToZone(tmplt.getId(), zoneId);
|
associateTemplateToZone(tmplt.getId(), zoneId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -370,20 +374,21 @@ public class TemplateServiceImpl implements TemplateService {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// check if there is a record for this template in this store
|
// check if there is a record for this template in this store
|
||||||
TemplateDataStoreVO tmpltHost = _vmTemplateStoreDao.findByStoreTemplate(storeId, tmplt.getId());
|
TemplateDataStoreVO tmpltStoreVO = _vmTemplateStoreDao.findByStoreTemplate(storeId, tmplt.getId());
|
||||||
|
|
||||||
// if this is private template, and there is no record for this
|
// if this is private template, and there is no record for this
|
||||||
// template in this store, skip
|
// template in this store, skip
|
||||||
|
// TODO: don't understand this logic. What happens if we have a record for this template, still download?
|
||||||
if (!tmplt.isPublicTemplate() && !tmplt.isFeatured()) {
|
if (!tmplt.isPublicTemplate() && !tmplt.isFeatured()) {
|
||||||
if (tmpltHost == null) {
|
if (tmpltStoreVO == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (availHypers.contains(tmplt.getHypervisorType())) {
|
if (availHypers.contains(tmplt.getHypervisorType())) {
|
||||||
if (tmpltHost != null ) {
|
if (tmpltStoreVO != null && tmpltStoreVO.getDownloadState() == Status.DOWNLOADED) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
s_logger.debug("Template " + tmplt.getName() + " needs to be downloaded to " + store.getName());
|
s_logger.info("Downloading template " + tmplt.getUniqueName() + " to image store " + store.getName());
|
||||||
TemplateInfo tmpl = _templateFactory.getTemplate(tmplt.getId(), DataStoreRole.Image);
|
TemplateInfo tmpl = _templateFactory.getTemplate(tmplt.getId(), DataStoreRole.Image);
|
||||||
createTemplateAsync(tmpl, store, null);
|
createTemplateAsync(tmpl, store, null);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -169,7 +169,7 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VMTemplateVO create(TemplateProfile profile) {
|
public VMTemplateVO create(TemplateProfile profile) {
|
||||||
// persist entry in vm_template, vm_template_details and template_zone_ref tables
|
// persist entry in vm_template, vm_template_details and template_zone_ref tables, not that entry at template_store_ref is not created here, and created in createTemplateAsync.
|
||||||
VMTemplateVO template = persistTemplate(profile);
|
VMTemplateVO template = persistTemplate(profile);
|
||||||
|
|
||||||
if (template == null) {
|
if (template == null) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user