Skip to content

Commit 666a362

Browse files
committed
ui: allow assigning backup offring during instance deploy
Add backup offering selection to Deploy VM wizard and assign selected backup offering to the VM after successful deployment. This enables users to choose a backup offering during VM creation, and the VM is automatically associated with the selected offering post-deployment. Signed-off-by: Abhishek Kumar <[email protected]>
1 parent 3d6ec29 commit 666a362

File tree

3 files changed

+56
-3
lines changed

3 files changed

+56
-3
lines changed

ui/public/locales/en.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,9 @@
447447
"label.backup.configure.schedule": "Configure Backup Schedule",
448448
"label.backup.offering.assign": "Assign Instance to backup offering",
449449
"label.backup.offering.remove": "Remove Instance from backup offering",
450+
"label.backup.offering": "Backup Offering",
450451
"label.backup.offerings": "Backup Offerings",
452+
"label.backup.offering.assign.failed": "Failed to assign Backup Offering",
451453
"label.backup.repository": "Backup Repository",
452454
"label.backup.restore": "Restore Instance backup",
453455
"label.backuplimit": "Backup Limits",
@@ -2189,6 +2191,7 @@
21892191
"label.select.all": "Select all",
21902192
"label.select.columns": "Select columns",
21912193
"label.select.a.zone": "Select a Zone",
2194+
"label.select.backup.offering": "Select Backup Offering",
21922195
"label.select.deployment.infrastructure": "Select deployment infrastructure",
21932196
"label.select.guest.os.type": "Please select the guest OS type",
21942197
"label.select.network": "Select Network",
@@ -3062,6 +3065,7 @@
30623065
"message.backup.attach.restore": "Please confirm that you want to restore and attach the volume from the backup?",
30633066
"message.backup.create": "Are you sure you want to create an Instance backup?",
30643067
"message.backup.offering.remove": "Are you sure you want to remove Instance from backup offering and delete the backup chain?",
3068+
"message.backup.offering.select.assign.instance": "Select a backup offering to assign to the Instance. Assigning a backup offering helps protect your data by enabling automated backups.",
30653069
"message.backup.restore": "Please confirm that you want to restore the Instance backup?",
30663070
"message.cancel.shutdown": "Please confirm that you would like to cancel the shutdown on this Management Server. It will resume accepting any new Async Jobs.",
30673071
"message.cancel.maintenance": "Please confirm that you would like to cancel the maintenance on this Management Server. It will resume accepting any new Async Jobs.",

ui/src/components/widgets/InfiniteScrollSelect.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
</template>
7878
<a-select-option v-for="option in options" :key="option.id" :value="option[optionValueKey]">
7979
<span>
80-
<span v-if="showIcon">
80+
<span v-if="showIcon && option.showicon !== false">
8181
<resource-icon v-if="option.icon && option.icon.base64image" :image="option.icon.base64image" size="1x" style="margin-right: 5px"/>
8282
<render-icon v-else :icon="defaultIcon" style="margin-right: 5px" />
8383
</span>

ui/src/views/compute/DeployVM.vue

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,25 @@
540540
</div>
541541
</template>
542542
</a-step>
543+
<a-step
544+
v-if="isUserAllowedToListBackupOfferings"
545+
:title="$t('label.backup.offering')"
546+
:status="zoneSelected ? 'process' : 'wait'">
547+
<template #description>
548+
<div v-if="zoneSelected" style="margin-top: 15px">
549+
<div>{{ $t('message.backup.offering.select.assign.instance') }}</div>
550+
<infinite-scroll-select
551+
style="margin-top: 10px; width: 100%;"
552+
v-model:value="selectedBackupOfferingId"
553+
placeholder="Select backup offering"
554+
api="listBackupOfferings"
555+
:apiParams="listBackupOfferingApiParams"
556+
resourceType="backupoffering"
557+
defaultIcon="cloud-upload-outlined"
558+
:defaultOption="backupOfferingDefaultOption" />
559+
</div>
560+
</template>
561+
</a-step>
543562
<a-step
544563
:title="$t('label.advanced.mode')"
545564
:status="zoneSelected ? 'process' : 'wait'">
@@ -930,6 +949,7 @@ import SecurityGroupSelection from '@views/compute/wizard/SecurityGroupSelection
930949
import TooltipLabel from '@/components/widgets/TooltipLabel'
931950
import InstanceNicsNetworkSelectListView from '@/components/view/InstanceNicsNetworkSelectListView'
932951
import DetailsInput from '@/components/widgets/DetailsInput'
952+
import InfiniteScrollSelect from '@/components/widgets/InfiniteScrollSelect'
933953
934954
export default {
935955
name: 'Wizard',
@@ -955,7 +975,8 @@ export default {
955975
SecurityGroupSelection,
956976
TooltipLabel,
957977
InstanceNicsNetworkSelectListView,
958-
DetailsInput
978+
DetailsInput,
979+
InfiniteScrollSelect
959980
},
960981
props: {
961982
visible: {
@@ -1135,7 +1156,8 @@ export default {
11351156
opts: []
11361157
},
11371158
externalDetailsEnabled: false,
1138-
selectedExtensionId: null
1159+
selectedExtensionId: null,
1160+
selectedBackupOfferingId: null
11391161
}
11401162
},
11411163
computed: {
@@ -1515,6 +1537,17 @@ export default {
15151537
},
15161538
isTemplateHypervisorExternal () {
15171539
return !!this.template && this.template.hypervisor === 'External'
1540+
},
1541+
isUserAllowedToListBackupOfferings () {
1542+
return Boolean('listBackupOfferings' in this.$store.getters.apis)
1543+
},
1544+
listBackupOfferingApiParams () {
1545+
return {
1546+
zoneid: this.zone?.id
1547+
}
1548+
},
1549+
backupOfferingDefaultOption () {
1550+
return { id: null, name: '', showicon: false }
15181551
}
15191552
},
15201553
watch: {
@@ -2507,6 +2540,7 @@ export default {
25072540
duration: 0
25082541
})
25092542
}
2543+
this.assigneVirtualMachineToBackupOfferingIfNeeded(vm)
25102544
eventBus.emit('vm-refresh-data')
25112545
},
25122546
loadingMessage: `${title} ${this.$t('label.in.progress')}`,
@@ -3004,6 +3038,7 @@ export default {
30043038
this.resetTemplatesList()
30053039
this.resetIsosList()
30063040
this.imageType = this.queryIsoId ? 'isoid' : 'templateid'
3041+
this.selectedBackupOfferingId = undefined
30073042
this.fetchZoneOptions()
30083043
},
30093044
onSelectPodId (value) {
@@ -3395,6 +3430,20 @@ export default {
33953430
return
33963431
}
33973432
this.form.externaldetails = undefined
3433+
},
3434+
assigneVirtualMachineToBackupOfferingIfNeeded (vm) {
3435+
if (!this.selectedBackupOfferingId || !vm || !vm.id) {
3436+
return
3437+
}
3438+
postAPI('assignVirtualMachineToBackupOffering', {
3439+
virtualmachineid: vm.id,
3440+
backupofferingid: this.selectedBackupOfferingId
3441+
}).catch(error => {
3442+
this.$notification.error({
3443+
message: this.$t('label.backup.offering.assign.failed'),
3444+
description: error.message || error
3445+
})
3446+
})
33983447
}
33993448
}
34003449
}

0 commit comments

Comments
 (0)