mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
systemvm: add template_zone_ref record when add a new zone with same hypervisor type (#8395)
This commit is contained in:
parent
77df9ad4d7
commit
0e08a126df
@ -482,19 +482,19 @@ public class SystemVmTemplateRegistration {
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -624,8 +624,9 @@ public class SystemVmTemplateRegistration {
|
||||
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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user