CLOUDSTACK-4600:Registered Cross-zone template does not populate

template_zone_ref for later added zones.
This commit is contained in:
Min Chen 2013-09-03 16:31:40 -07:00
parent bf967eb622
commit e92d46bfd4
3 changed files with 21 additions and 0 deletions

View File

@ -61,4 +61,6 @@ public interface TemplateService {
void downloadBootstrapSysTemplate(DataStore store);
void addSystemVMTemplatesToSecondary(DataStore store);
void associateCrosszoneTemplatesToZone(long dcId);
}

View File

@ -488,6 +488,23 @@ public class TemplateServiceImpl implements TemplateService {
}
}
// update template_zone_ref for cross-zone template for newly added zone
@Override
public void associateCrosszoneTemplatesToZone(long dcId){
VMTemplateZoneVO tmpltZone;
List<VMTemplateVO> allTemplates = _templateDao.listAll();
for (VMTemplateVO vt: allTemplates){
if (vt.isCrossZones()) {
tmpltZone = _vmTemplateZoneDao.findByZoneTemplate(dcId, vt.getId());
if (tmpltZone == null) {
VMTemplateZoneVO vmTemplateZone = new VMTemplateZoneVO(dcId, vt.getId(), new Date());
_vmTemplateZoneDao.persist(vmTemplateZone);
}
}
}
}
private Map<String, TemplateProp> listTemplate(DataStore ssStore) {
ListTemplateCommand cmd = new ListTemplateCommand(ssStore.getTO());
EndPoint ep = _epSelector.select(ssStore);

View File

@ -289,6 +289,8 @@ public class DownloadListener implements Listener {
return;
}
_imageSrv.handleSysTemplateDownload(hostHyper, agent.getDataCenterId());
// update template_zone_ref for cross-zone templates
_imageSrv.associateCrosszoneTemplatesToZone(agent.getDataCenterId());
}
/* This can be removed
else if ( cmd instanceof StartupStorageCommand) {