Skip to content

Commit 1ff9eec

Browse files
authored
Load arch data for backup from template during create instance from backup (#12801)
1 parent 7ba5240 commit 1ff9eec

File tree

2 files changed

+24
-47
lines changed

2 files changed

+24
-47
lines changed

ui/src/components/view/DeployVMFromBackup.vue

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,7 +1451,7 @@ 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 {
@@ -1540,46 +1540,6 @@ export default {
15401540
fillValue (field) {
15411541
this.form[field] = this.dataPreFill[field]
15421542
},
1543-
fetchZoneByQuery () {
1544-
return new Promise(resolve => {
1545-
let zones = []
1546-
let apiName = ''
1547-
const params = {}
1548-
if (this.templateId) {
1549-
apiName = 'listTemplates'
1550-
params.listall = true
1551-
params.templatefilter = this.isNormalAndDomainUser ? 'executable' : 'all'
1552-
params.id = this.templateId
1553-
} else if (this.isoId) {
1554-
apiName = 'listIsos'
1555-
params.listall = true
1556-
params.isofilter = this.isNormalAndDomainUser ? 'executable' : 'all'
1557-
params.id = this.isoId
1558-
} else if (this.networkId) {
1559-
params.listall = true
1560-
params.id = this.networkId
1561-
apiName = 'listNetworks'
1562-
}
1563-
if (!apiName) return resolve(zones)
1564-
1565-
getAPI(apiName, params).then(json => {
1566-
let objectName
1567-
const responseName = [apiName.toLowerCase(), 'response'].join('')
1568-
for (const key in json[responseName]) {
1569-
if (key === 'count') {
1570-
continue
1571-
}
1572-
objectName = key
1573-
break
1574-
}
1575-
const data = json?.[responseName]?.[objectName] || []
1576-
zones = data.map(item => item.zoneid)
1577-
return resolve(zones)
1578-
}).catch(() => {
1579-
return resolve(zones)
1580-
})
1581-
})
1582-
},
15831543
async fetchData () {
15841544
this.fetchZones(null, null)
15851545
_.each(this.params, (param, name) => {
@@ -1718,6 +1678,7 @@ export default {
17181678
if (template.details['vmware-to-kvm-mac-addresses']) {
17191679
this.dataPreFill.macAddressArray = JSON.parse(template.details['vmware-to-kvm-mac-addresses'])
17201680
}
1681+
this.selectedArchitecture = template?.arch || 'x86_64'
17211682
}
17221683
} else if (name === 'isoid') {
17231684
this.templateConfigurations = []
@@ -2344,9 +2305,6 @@ export default {
23442305
this.clusterId = null
23452306
this.zone = _.find(this.options.zones, (option) => option.id === value)
23462307
this.isZoneSelectedMultiArch = this.zone.ismultiarch
2347-
if (this.isZoneSelectedMultiArch) {
2348-
this.selectedArchitecture = this.architectureTypes.opts[0].id
2349-
}
23502308
this.zoneSelected = true
23512309
this.form.startvm = true
23522310
this.selectedZone = this.zoneId

ui/src/views/storage/CreateVMFromBackup.vue

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,11 @@ export default {
9292
}
9393
},
9494
async created () {
95-
await Promise.all[(
95+
await Promise.all([
9696
this.fetchServiceOffering(),
97-
this.fetchBackupOffering()
98-
)]
97+
this.fetchBackupOffering(),
98+
this.fetchBackupArch()
99+
])
99100
this.loading = false
100101
},
101102
methods: {
@@ -118,6 +119,23 @@ export default {
118119
this.backupOffering = backupOfferings[0]
119120
})
120121
},
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, {
129+
id: this.resource.vmdetails.templateid,
130+
listall: true,
131+
...(isIso ? {} : { templatefilter: 'all' })
132+
}).then(response => {
133+
const items = response?.[responseKey]?.[itemKey] || []
134+
this.backupArch = items[0]?.arch || 'x86_64'
135+
}).catch(() => {
136+
this.backupArch = 'x86_64'
137+
})
138+
},
121139
populatePreFillData () {
122140
this.vmdetails = this.resource.vmdetails
123141
this.dataPreFill.zoneid = this.resource.zoneid
@@ -128,6 +146,7 @@ export default {
128146
this.dataPreFill.backupid = this.resource.id
129147
this.dataPreFill.computeofferingid = this.vmdetails.serviceofferingid
130148
this.dataPreFill.templateid = this.vmdetails.templateid
149+
this.dataPreFill.backupArch = this.backupArch
131150
this.dataPreFill.allowtemplateisoselection = true
132151
this.dataPreFill.isoid = this.vmdetails.templateid
133152
this.dataPreFill.allowIpAddressesFetch = this.resource.isbackupvmexpunged

0 commit comments

Comments
 (0)