Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -482,19 +482,19 @@ private VMTemplateZoneVO createOrUpdateTemplateZoneEntry(long zoneId, long templ
templateZoneVO = vmTemplateZoneDao.persist(templateZoneVO);
} else {
templateZoneVO.setLastUpdated(new java.util.Date());
if (vmTemplateZoneDao.update(templateZoneVO.getId(), templateZoneVO)) {
if (!vmTemplateZoneDao.update(templateZoneVO.getId(), templateZoneVO)) {
templateZoneVO = null;
}
}
return templateZoneVO;
}

private void createCrossZonesTemplateZoneRefEntries(VMTemplateVO template) {
private void createCrossZonesTemplateZoneRefEntries(Long templateId) {
List<DataCenterVO> dcs = dataCenterDao.listAll();
for (DataCenterVO dc : dcs) {
VMTemplateZoneVO templateZoneVO = createOrUpdateTemplateZoneEntry(dc.getId(), template.getId());
VMTemplateZoneVO templateZoneVO = createOrUpdateTemplateZoneEntry(dc.getId(), templateId);
if (templateZoneVO == null) {
throw new CloudRuntimeException(String.format("Failed to create template_zone_ref record for the systemVM template for hypervisor: %s and zone: %s", template.getHypervisorType().name(), dc));
throw new CloudRuntimeException(String.format("Failed to create template_zone_ref record for the systemVM template (id: %s) and zone: %s", templateId, dc));
}
}
}
Expand Down Expand Up @@ -624,8 +624,9 @@ private Long performTemplateRegistrationOperations(Pair<Hypervisor.HypervisorTyp
throw new CloudRuntimeException(String.format("Failed to register template for hypervisor: %s", hypervisor.name()));
}
templateId = template.getId();
createCrossZonesTemplateZoneRefEntries(template);
}
createCrossZonesTemplateZoneRefEntries(templateId);

details.setId(templateId);
String destTempFolderName = String.valueOf(templateId);
String destTempFolder = filePath + PARTIAL_TEMPLATE_FOLDER + destTempFolderName;
Expand Down