mirror of https://github.com/apache/cloudstack.git
Bug CS-14447: set crossZones attribute for the template before persisting it to the db
This commit is contained in:
parent
b2be0039cb
commit
76c7c22b34
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue