Skip to content

Commit e62326e

Browse files
committed
handle selectedarch for iso
1 parent 1cf0ce6 commit e62326e

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

ui/src/components/view/DeployVMFromBackup.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,12 +1451,11 @@ export default {
14511451
this.initForm()
14521452
this.dataPreFill = this.preFillContent && Object.keys(this.preFillContent).length > 0 ? this.preFillContent : {}
14531453
this.showOverrideDiskOfferingOption = this.dataPreFill.overridediskoffering
1454-
1454+
this.selectedArchitecture = this.dataPreFill.backupArch ? this.dataPreFill.backupArch : this.architectureTypes.opts[0].id
14551455
if (this.dataPreFill.isIso) {
14561456
this.tabKey = 'isoid'
14571457
} else {
14581458
this.tabKey = 'templateid'
1459-
this.selectedArchitecture = this.dataPreFill.templateArch ? this.dataPreFill.templateArch : this.architectureTypes.opts[0].id
14601459
}
14611460
14621461
this.fetchData()

ui/src/views/storage/CreateVMFromBackup.vue

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ export default {
9292
}
9393
},
9494
async created () {
95-
await Promise.all[(
95+
await Promise.all([
9696
this.fetchServiceOffering(),
9797
this.fetchBackupOffering(),
98-
this.fetchTemplateArch()
99-
)]
98+
this.fetchBackupArch()
99+
])
100100
this.loading = false
101101
},
102102
methods: {
@@ -119,16 +119,21 @@ export default {
119119
this.backupOffering = backupOfferings[0]
120120
})
121121
},
122-
fetchTemplateArch () {
123-
return getAPI('listTemplates', {
122+
fetchBackupArch () {
123+
const isIso = this.resource.vmdetails.isiso === 'true'
124+
const api = isIso ? 'listIsos' : 'listTemplates'
125+
const responseKey = isIso ? 'listisosresponse' : 'listtemplatesresponse'
126+
const itemKey = isIso ? 'iso' : 'template'
127+
128+
return getAPI(api, {
124129
id: this.resource.vmdetails.templateid,
125130
listall: true,
126-
templatefilter: 'all'
131+
...(isIso ? {} : { templatefilter: 'all' })
127132
}).then(response => {
128-
const templates = response.listtemplatesresponse.template || []
129-
this.templateArch = templates[0]?.arch || 'x86_64'
133+
const items = response?.[responseKey]?.[itemKey] || []
134+
this.backupArch = items[0]?.arch || 'x86_64'
130135
}).catch(() => {
131-
this.templateArch = 'x86_64'
136+
this.backupArch = 'x86_64'
132137
})
133138
},
134139
populatePreFillData () {
@@ -141,7 +146,7 @@ export default {
141146
this.dataPreFill.backupid = this.resource.id
142147
this.dataPreFill.computeofferingid = this.vmdetails.serviceofferingid
143148
this.dataPreFill.templateid = this.vmdetails.templateid
144-
this.dataPreFill.templateArch = this.templateArch
149+
this.dataPreFill.backupArch = this.backupArch
145150
this.dataPreFill.allowtemplateisoselection = true
146151
this.dataPreFill.isoid = this.vmdetails.templateid
147152
this.dataPreFill.allowIpAddressesFetch = this.resource.isbackupvmexpunged

0 commit comments

Comments
 (0)