Bug CS-14447: set crossZones attribute for the template before persisting it to the db

This commit is contained in:
Alena Prokharchyk 2012-04-13 14:15:18 -07:00
parent b2be0039cb
commit 76c7c22b34
2 changed files with 4 additions and 3 deletions

View File

@ -691,7 +691,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
}
}
VMTemplateZoneVO tmpltZoneVO = _templateZoneDao.findByZoneTemplate(zoneId, tmplt.getId());
if ( tmpltZoneVO == null ) {
if (tmpltZoneVO == null ) {
tmpltZoneVO = new VMTemplateZoneVO(zoneId, tmplt.getId(), new Date());
_templateZoneDao.persist(tmpltZoneVO);
} else {

View File

@ -246,17 +246,18 @@ public abstract class TemplateAdapterBase implements TemplateAdapter {
profile.getPasswordEnabled(), profile.getGuestOsId(), profile.getBootable(), profile.getHypervisorType(), profile.getTemplateTag(),
profile.getDetails(), profile.getSshKeyEnabled());
if (zoneId == null || zoneId == -1) {
if (zoneId == null || zoneId.longValue() == -1) {
List<DataCenterVO> dcs = _dcDao.listAll();
if (dcs.isEmpty()) {
throw new CloudRuntimeException("No zones are present in the system, can't add template");
}
template.setCrossZones(true);
for (DataCenterVO dc: dcs) {
_tmpltDao.addTemplateToZone(template, dc.getId());
}
template.setCrossZones(true);
} else {
_tmpltDao.addTemplateToZone(template, zoneId);
}