Skip to content

Commit 5b5d078

Browse files
committed
review comments
1 parent c3d5fec commit 5b5d078

3 files changed

Lines changed: 10 additions & 16 deletions

File tree

server/src/main/java/org/apache/cloudstack/backup/BackupManagerImpl.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ public Map<String, String> getBackupDetailsFromVM(VirtualMachine vm) {
389389
GuestOSVO guestOS = _guestOSDao.findById(guestOSId);
390390
if (guestOS != null) {
391391
details.put(ApiConstants.OS_TYPE_ID, guestOS.getUuid());
392+
details.put(ApiConstants.OS_NAME, guestOS.getDisplayName());
392393
}
393394
}
394395

@@ -2108,21 +2109,13 @@ Map<String, String> getDetailsFromBackupDetails(Long backupId) {
21082109
if (details.containsKey(ApiConstants.TEMPLATE_ID)) {
21092110
VirtualMachineTemplate template = vmTemplateDao.findByUuid(details.get(ApiConstants.TEMPLATE_ID));
21102111
if (template != null) {
2111-
details.put(ApiConstants.TEMPLATE_ID, template.getUuid());
21122112
details.put(ApiConstants.TEMPLATE_NAME, template.getName());
21132113
details.put(ApiConstants.IS_ISO, String.valueOf(template.getFormat().equals(Storage.ImageFormat.ISO)));
21142114
}
21152115
}
2116-
if (details.containsKey(ApiConstants.OS_TYPE_ID)) {
2117-
GuestOSVO guestOS = _guestOSDao.findByUuid(details.get(ApiConstants.OS_TYPE_ID));
2118-
if (guestOS != null) {
2119-
details.put(ApiConstants.OS_NAME, guestOS.getDisplayName());
2120-
}
2121-
}
21222116
if (details.containsKey(ApiConstants.SERVICE_OFFERING_ID)) {
21232117
ServiceOffering serviceOffering = serviceOfferingDao.findByUuid(details.get(ApiConstants.SERVICE_OFFERING_ID));
21242118
if (serviceOffering != null) {
2125-
details.put(ApiConstants.SERVICE_OFFERING_ID, serviceOffering.getUuid());
21262119
details.put(ApiConstants.SERVICE_OFFERING_NAME, serviceOffering.getName());
21272120
}
21282121
}
@@ -2201,7 +2194,9 @@ public BackupResponse createBackupResponse(Backup backup, Boolean listVmDetails)
22012194

22022195
if (Boolean.TRUE.equals(listVmDetails)) {
22032196
Map<String, String> vmDetails = new HashMap<>();
2204-
vmDetails.put(ApiConstants.HYPERVISOR, vm.getHypervisorType().toString());
2197+
if (vm != null) {
2198+
vmDetails.put(ApiConstants.HYPERVISOR, vm.getHypervisorType().toString());
2199+
}
22052200
Map<String, String> details = getDetailsFromBackupDetails(backup.getId());
22062201
vmDetails.putAll(details);
22072202
response.setVmDetails(vmDetails);

server/src/test/java/org/apache/cloudstack/backup/BackupManagerTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,14 +1573,12 @@ public void testNewBackupResponse() {
15731573

15741574
VMTemplateVO template = mock(VMTemplateVO.class);
15751575
when(template.getFormat()).thenReturn(Storage.ImageFormat.QCOW2);
1576-
when(template.getUuid()).thenReturn(templateUuid);
15771576
when(template.getName()).thenReturn("template1");
15781577
when(vmTemplateDao.findByUuid(templateUuid)).thenReturn(template);
15791578
Map<String, String> details = new HashMap<>();
15801579
details.put(ApiConstants.TEMPLATE_ID, templateUuid);
15811580

15821581
ServiceOfferingVO serviceOffering = mock(ServiceOfferingVO.class);
1583-
when(serviceOffering.getUuid()).thenReturn(serviceOfferingUuid);
15841582
when(serviceOffering.getName()).thenReturn("service-offering1");
15851583
when(serviceOfferingDao.findByUuid(serviceOfferingUuid)).thenReturn(serviceOffering);
15861584
details.put(ApiConstants.SERVICE_OFFERING_ID, serviceOfferingUuid);

ui/src/components/view/DeployVMFromBackup.vue

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,11 @@
168168
:tabList="tabList"
169169
:activeTabKey="tabKey"
170170
@tabChange="key => onTabChange(key, 'tabKey')">
171-
<a-alert v-if="showOsTypeWarning">
171+
<a-alert
172+
v-if="showOsTypeWarning && selectedTemplateIso"
173+
style="margin-bottom: 10px">
172174
<template #message>
173-
<div v-if="selectedTemplateIso && dataPreFill.ostypename">
175+
<div>
174176
{{ selectedTemplateIso.message }}<br>
175177
{{ selectedTemplateIso.label }} :
176178
<router-link :to="{ path: '/guestos/' + selectedTemplateIso.item.ostypeid }">
@@ -183,7 +185,6 @@
183185
</div>
184186
</template>
185187
</a-alert>
186-
<br v-if="showOsTypeWarning"/>
187188
<div v-if="tabKey === 'templateid'">
188189
{{ $t('message.template.desc') }}
189190
<div v-if="isZoneSelectedMultiArch" style="width: 100%; margin-top: 5px">
@@ -1713,7 +1714,7 @@ export default {
17131714
this.form.iothreadsenabled = template.details && Object.prototype.hasOwnProperty.call(template.details, 'iothreads')
17141715
this.form.iodriverpolicy = template.details?.['io.policy']
17151716
this.form.keyboard = template.details?.keyboard
1716-
this.showOsTypeWarning = template.ostypeid !== this.dataPreFill.ostypeid
1717+
this.showOsTypeWarning = this.dataPreFill.ostypeid && template.ostypeid !== this.dataPreFill.ostypeid
17171718
if (template.details['vmware-to-kvm-mac-addresses']) {
17181719
this.dataPreFill.macAddressArray = JSON.parse(template.details['vmware-to-kvm-mac-addresses'])
17191720
}
@@ -1730,7 +1731,7 @@ export default {
17301731
for (const key in this.options.isos) {
17311732
var iso = _.find(_.get(this.options.isos[key], 'iso', []), (option) => option.id === value)
17321733
if (iso) {
1733-
this.showOsTypeWarning = iso.ostypeid !== this.dataPreFill.ostypeid
1734+
this.showOsTypeWarning = this.dataPreFill.ostypeid && iso.ostypeid !== this.dataPreFill.ostypeid
17341735
break
17351736
}
17361737
}

0 commit comments

Comments
 (0)