This is an automated email from the ASF dual-hosted git repository.
dahn pushed a commit to branch 4.22
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.22 by this push:
new 1ff9eec9977 Load arch data for backup from template during create
instance from backup (#12801)
1ff9eec9977 is described below
commit 1ff9eec9977fc68f59e11644b9543177df403ab5
Author: Manoj Kumar <[email protected]>
AuthorDate: Thu Apr 9 13:19:49 2026 +0530
Load arch data for backup from template during create instance from backup
(#12801)
---
ui/src/components/view/DeployVMFromBackup.vue | 46 ++-------------------------
ui/src/views/storage/CreateVMFromBackup.vue | 25 +++++++++++++--
2 files changed, 24 insertions(+), 47 deletions(-)
diff --git a/ui/src/components/view/DeployVMFromBackup.vue
b/ui/src/components/view/DeployVMFromBackup.vue
index 55808db291c..888d29509e1 100644
--- a/ui/src/components/view/DeployVMFromBackup.vue
+++ b/ui/src/components/view/DeployVMFromBackup.vue
@@ -1451,7 +1451,7 @@ export default {
this.initForm()
this.dataPreFill = this.preFillContent &&
Object.keys(this.preFillContent).length > 0 ? this.preFillContent : {}
this.showOverrideDiskOfferingOption = this.dataPreFill.overridediskoffering
-
+ this.selectedArchitecture = this.dataPreFill.backupArch ?
this.dataPreFill.backupArch : this.architectureTypes.opts[0].id
if (this.dataPreFill.isIso) {
this.tabKey = 'isoid'
} else {
@@ -1540,46 +1540,6 @@ export default {
fillValue (field) {
this.form[field] = this.dataPreFill[field]
},
- fetchZoneByQuery () {
- return new Promise(resolve => {
- let zones = []
- let apiName = ''
- const params = {}
- if (this.templateId) {
- apiName = 'listTemplates'
- params.listall = true
- params.templatefilter = this.isNormalAndDomainUser ? 'executable' :
'all'
- params.id = this.templateId
- } else if (this.isoId) {
- apiName = 'listIsos'
- params.listall = true
- params.isofilter = this.isNormalAndDomainUser ? 'executable' : 'all'
- params.id = this.isoId
- } else if (this.networkId) {
- params.listall = true
- params.id = this.networkId
- apiName = 'listNetworks'
- }
- if (!apiName) return resolve(zones)
-
- getAPI(apiName, params).then(json => {
- let objectName
- const responseName = [apiName.toLowerCase(), 'response'].join('')
- for (const key in json[responseName]) {
- if (key === 'count') {
- continue
- }
- objectName = key
- break
- }
- const data = json?.[responseName]?.[objectName] || []
- zones = data.map(item => item.zoneid)
- return resolve(zones)
- }).catch(() => {
- return resolve(zones)
- })
- })
- },
async fetchData () {
this.fetchZones(null, null)
_.each(this.params, (param, name) => {
@@ -1718,6 +1678,7 @@ export default {
if (template.details['vmware-to-kvm-mac-addresses']) {
this.dataPreFill.macAddressArray =
JSON.parse(template.details['vmware-to-kvm-mac-addresses'])
}
+ this.selectedArchitecture = template?.arch || 'x86_64'
}
} else if (name === 'isoid') {
this.templateConfigurations = []
@@ -2344,9 +2305,6 @@ export default {
this.clusterId = null
this.zone = _.find(this.options.zones, (option) => option.id === value)
this.isZoneSelectedMultiArch = this.zone.ismultiarch
- if (this.isZoneSelectedMultiArch) {
- this.selectedArchitecture = this.architectureTypes.opts[0].id
- }
this.zoneSelected = true
this.form.startvm = true
this.selectedZone = this.zoneId
diff --git a/ui/src/views/storage/CreateVMFromBackup.vue
b/ui/src/views/storage/CreateVMFromBackup.vue
index 8d29397e45a..891e8fe9642 100644
--- a/ui/src/views/storage/CreateVMFromBackup.vue
+++ b/ui/src/views/storage/CreateVMFromBackup.vue
@@ -92,10 +92,11 @@ export default {
}
},
async created () {
- await Promise.all[(
+ await Promise.all([
this.fetchServiceOffering(),
- this.fetchBackupOffering()
- )]
+ this.fetchBackupOffering(),
+ this.fetchBackupArch()
+ ])
this.loading = false
},
methods: {
@@ -118,6 +119,23 @@ export default {
this.backupOffering = backupOfferings[0]
})
},
+ fetchBackupArch () {
+ const isIso = this.resource.vmdetails.isiso === 'true'
+ const api = isIso ? 'listIsos' : 'listTemplates'
+ const responseKey = isIso ? 'listisosresponse' : 'listtemplatesresponse'
+ const itemKey = isIso ? 'iso' : 'template'
+
+ return getAPI(api, {
+ id: this.resource.vmdetails.templateid,
+ listall: true,
+ ...(isIso ? {} : { templatefilter: 'all' })
+ }).then(response => {
+ const items = response?.[responseKey]?.[itemKey] || []
+ this.backupArch = items[0]?.arch || 'x86_64'
+ }).catch(() => {
+ this.backupArch = 'x86_64'
+ })
+ },
populatePreFillData () {
this.vmdetails = this.resource.vmdetails
this.dataPreFill.zoneid = this.resource.zoneid
@@ -128,6 +146,7 @@ export default {
this.dataPreFill.backupid = this.resource.id
this.dataPreFill.computeofferingid = this.vmdetails.serviceofferingid
this.dataPreFill.templateid = this.vmdetails.templateid
+ this.dataPreFill.backupArch = this.backupArch
this.dataPreFill.allowtemplateisoselection = true
this.dataPreFill.isoid = this.vmdetails.templateid
this.dataPreFill.allowIpAddressesFetch = this.resource.isbackupvmexpunged