mirror of https://github.com/apache/cloudstack.git
Load arch data for backup from template during create instance from backup (#12801)
This commit is contained in:
parent
7ba5240b31
commit
1ff9eec997
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue