Skip to content

Commit 8d1128e

Browse files
committed
fix
Signed-off-by: Abhishek Kumar <[email protected]>
1 parent 7221a96 commit 8d1128e

File tree

2 files changed

+52
-19
lines changed

2 files changed

+52
-19
lines changed

ui/src/views/compute/DeployVM.vue

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3446,29 +3446,55 @@ export default {
34463446
}
34473447
const assigned = await this.assignVirtualMachineToBackupOfferingIfNeeded(vm)
34483448
if (assigned) {
3449+
// wait for 200ms
3450+
await new Promise(resolve => setTimeout(resolve, 200))
34493451
await this.createVirtualMachineBackupSchedulesIfNeeded(vm)
34503452
}
34513453
},
34523454
assignVirtualMachineToBackupOfferingIfNeeded (vm) {
34533455
if (!this.form.backupofferingid || !vm || !vm.id) {
34543456
return Promise.resolve(false)
34553457
}
3456-
return postAPI('assignVirtualMachineToBackupOffering', {
3458+
const params = {
34573459
virtualmachineid: vm.id,
34583460
backupofferingid: this.form.backupofferingid
3459-
}).then(() => true).catch(error => {
3460-
this.$notification.error({
3461-
message: this.$t('label.backup.offering.assign.failed'),
3462-
description: error.message || error
3461+
}
3462+
return new Promise((resolve, reject) => {
3463+
postAPI('assignVirtualMachineToBackupOffering', params).then(json => {
3464+
const jobId = json.assignvirtualmachinetobackupofferingresponse?.jobid
3465+
if (!jobId) {
3466+
resolve(false)
3467+
return
3468+
}
3469+
this.$pollJob({
3470+
jobId,
3471+
loadingMessage: `${this.$t('label.backup.offering.assign')} ${this.$t('label.in.progress')}`,
3472+
successMethod: () => {
3473+
resolve(true)
3474+
},
3475+
errorMethod: (result) => {
3476+
this.$notification.error({
3477+
message: this.$t('label.backup.offering.assign.failed'),
3478+
description: result?.jobresult?.errortext || this.$t('error.fetching.async.job.result')
3479+
})
3480+
resolve(false)
3481+
},
3482+
catchMessage: this.$t('error.fetching.async.job.result')
3483+
})
3484+
}).catch(error => {
3485+
this.$notification.error({
3486+
message: this.$t('label.backup.offering.assign.failed'),
3487+
description: error.message || error
3488+
})
3489+
resolve(false)
34633490
})
3464-
return false
34653491
})
34663492
},
34673493
createVirtualMachineBackupSchedulesIfNeeded (vm) {
3468-
if (!vm || !vm.id || !this.backupSchedules || this.backupSchedules.length === 0) {
3494+
if (!vm || !vm.id || !this.backupSchedules) {
34693495
return Promise.resolve()
34703496
}
3471-
const promises = (this.form.backupSchedules).map(item =>
3497+
const promises = (this.backupSchedules || []).map(item =>
34723498
this.createVirtualMachineBackupSchedule(vm, item)
34733499
)
34743500
return Promise.all(promises)
@@ -3484,10 +3510,15 @@ export default {
34843510
if (item.quiescevm) {
34853511
params.quiescevm = item.quiescevm
34863512
}
3487-
return postAPI('createBackupSchedule', params).catch(error => {
3488-
this.$notification.error({
3489-
message: this.$t('label.backup.schedule.create.failed'),
3490-
description: error.message || error
3513+
return new Promise((resolve, reject) => {
3514+
postAPI('createBackupSchedule', params).then(response => {
3515+
resolve(response)
3516+
}).catch(error => {
3517+
this.$notification.error({
3518+
message: this.$t('label.backup.schedule.create.failed'),
3519+
description: error.message || error
3520+
})
3521+
reject(error)
34913522
})
34923523
})
34933524
}

ui/src/views/compute/wizard/DeployInstanceBackupSelection.vue

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,15 @@
3030
@change-option="handleChangeBackupOffering" />
3131

3232
<div v-if="backupOfferingId && 'createBackupSchedule' in $store.getters.apis" style="margin-top: 15px">
33-
<a-button
34-
type="dashed"
35-
style="width: 100%"
36-
@click="onShowAddBackupSchedule">
37-
<template #icon><plus-outlined /></template>
38-
{{ $t('label.add.backup.schedule') }}
39-
</a-button>
33+
<a-form-item :label="$t('label.schedule')">
34+
<a-button
35+
type="dashed"
36+
style="width: 100%"
37+
@click="onShowAddBackupSchedule">
38+
<template #icon><plus-outlined /></template>
39+
{{ $t('label.add.backup.schedule') }}
40+
</a-button>
41+
</a-form-item>
4042
<backup-schedule
4143
style="margin-top: 10px;"
4244
:dataSource="backupSchedules"

0 commit comments

Comments
 (0)