Skip to content

Commit 6ed643e

Browse files
weizhouapacheGlover, Rene (rg9975)
authored andcommitted
upgrade: consider multiple hypervisors and secondary storages (apache#10046)
1 parent 82c0630 commit 6ed643e

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

engine/schema/src/main/java/com/cloud/upgrade/SystemVmTemplateRegistration.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -794,12 +794,16 @@ public void doInTransactionWithoutResult(final TransactionStatus status) {
794794
Long templateId = getRegisteredTemplateId(hypervisorAndTemplateName);
795795
if (templateId != null) {
796796
VMTemplateVO templateVO = vmTemplateDao.findById(templateId);
797-
TemplateDataStoreVO templateDataStoreVO = templateDataStoreDao.findByTemplate(templateId, DataStoreRole.Image);
798-
String installPath = templateDataStoreVO.getInstallPath();
799-
if (validateIfSeeded(storeUrlAndId.first(), installPath, nfsVersion)) {
800-
continue;
801-
} else if (templateVO != null) {
797+
TemplateDataStoreVO templateDataStoreVO = templateDataStoreDao.findByStoreTemplate(storeUrlAndId.second(), templateId);
798+
if (templateDataStoreVO != null) {
799+
String installPath = templateDataStoreVO.getInstallPath();
800+
if (validateIfSeeded(storeUrlAndId.first(), installPath, nfsVersion)) {
801+
continue;
802+
}
803+
}
804+
if (templateVO != null) {
802805
registerTemplate(hypervisorAndTemplateName, storeUrlAndId, templateVO, templateDataStoreVO, filePath);
806+
updateRegisteredTemplateDetails(templateId, hypervisorAndTemplateName);
803807
continue;
804808
}
805809
}
@@ -823,6 +827,11 @@ public void doInTransactionWithoutResult(final TransactionStatus status) {
823827
}
824828

825829
private void updateRegisteredTemplateDetails(Long templateId, Map.Entry<Hypervisor.HypervisorType, String> hypervisorAndTemplateName) {
830+
Pair<Hypervisor.HypervisorType, String> entry = new Pair<>(hypervisorAndTemplateName.getKey(), hypervisorAndTemplateName.getValue());
831+
updateRegisteredTemplateDetails(templateId, entry);
832+
}
833+
834+
private void updateRegisteredTemplateDetails(Long templateId, Pair<Hypervisor.HypervisorType, String> hypervisorAndTemplateName) {
826835
VMTemplateVO templateVO = vmTemplateDao.findById(templateId);
827836
templateVO.setTemplateType(Storage.TemplateType.SYSTEM);
828837
boolean updated = vmTemplateDao.update(templateVO.getId(), templateVO);
@@ -832,11 +841,11 @@ private void updateRegisteredTemplateDetails(Long templateId, Map.Entry<Hypervis
832841
throw new CloudRuntimeException(errMsg);
833842
}
834843

835-
updateSystemVMEntries(templateId, hypervisorAndTemplateName.getKey());
844+
updateSystemVMEntries(templateId, hypervisorAndTemplateName.first());
836845

837846
// Change value of global configuration parameter router.template.* for the corresponding hypervisor and minreq.sysvmtemplate.version for the ACS version
838847
Map<String, String> configParams = new HashMap<>();
839-
configParams.put(RouterTemplateConfigurationNames.get(hypervisorAndTemplateName.getKey()), hypervisorAndTemplateName.getValue());
848+
configParams.put(RouterTemplateConfigurationNames.get(hypervisorAndTemplateName.first()), hypervisorAndTemplateName.second());
840849
configParams.put("minreq.sysvmtemplate.version", getSystemVmTemplateVersion());
841850
updateConfigurationParams(configParams);
842851
}

server/src/main/java/com/cloud/storage/StorageManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3441,7 +3441,7 @@ public void doInTransactionWithoutResult(final TransactionStatus status) {
34413441
TemplateDataStoreVO templateVO = null;
34423442
if (templateId != null) {
34433443
vmTemplateVO = _templateDao.findById(templateId);
3444-
templateVO = _templateStoreDao.findByTemplate(templateId, DataStoreRole.Image);
3444+
templateVO = _templateStoreDao.findByStoreTemplate(store.getId(), templateId);
34453445
if (templateVO != null) {
34463446
try {
34473447
if (SystemVmTemplateRegistration.validateIfSeeded(

0 commit comments

Comments
 (0)