Skip to content

Commit 76c7c22

Browse files
author
Alena Prokharchyk
committed
Bug CS-14447: set crossZones attribute for the template before persisting it to the db
1 parent b2be003 commit 76c7c22

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

‎server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ public long addTemplateToZone(VMTemplateVO tmplt, long zoneId) {
691691
}
692692
}
693693
VMTemplateZoneVO tmpltZoneVO = _templateZoneDao.findByZoneTemplate(zoneId, tmplt.getId());
694-
if ( tmpltZoneVO == null ) {
694+
if (tmpltZoneVO == null ) {
695695
tmpltZoneVO = new VMTemplateZoneVO(zoneId, tmplt.getId(), new Date());
696696
_templateZoneDao.persist(tmpltZoneVO);
697697
} else {

‎server/src/com/cloud/template/TemplateAdapterBase.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,17 +246,18 @@ protected VMTemplateVO persistTemplate(TemplateProfile profile) {
246246
profile.getPasswordEnabled(), profile.getGuestOsId(), profile.getBootable(), profile.getHypervisorType(), profile.getTemplateTag(),
247247
profile.getDetails(), profile.getSshKeyEnabled());
248248

249-
if (zoneId == null || zoneId == -1) {
249+
if (zoneId == null || zoneId.longValue() == -1) {
250250
List<DataCenterVO> dcs = _dcDao.listAll();
251251

252252
if (dcs.isEmpty()) {
253253
throw new CloudRuntimeException("No zones are present in the system, can't add template");
254254
}
255255

256+
template.setCrossZones(true);
256257
for (DataCenterVO dc: dcs) {
257258
_tmpltDao.addTemplateToZone(template, dc.getId());
258259
}
259-
template.setCrossZones(true);
260+
260261
} else {
261262
_tmpltDao.addTemplateToZone(template, zoneId);
262263
}

0 commit comments

Comments
 (0)