feat: Allow deletion of Volume on Instance Delete setting

This feature allows the user to check whether the selected Volume should be deleted along with the instance
when the user selected the Bootable Volume Start Source via Instance creation module.

Change-Id: Ib7e7da84de8e884e2cec65fa9747f04551e2de96
This commit is contained in:
Elly Murillo 2023-11-20 16:57:16 +08:00
parent 23bc6f8e21
commit 639bcedd7d
7 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,6 @@
---
features:
- |
Allow deletion of Volume on Instance Delete setting
* Allows the user to check whether the selected Volume should be deleted along with the instance when the user selected the Bootable Volume Start Source via Instance creation module.

View File

@ -744,6 +744,7 @@
"Delete Volume Backup": "Delete Volume Backup", "Delete Volume Backup": "Delete Volume Backup",
"Delete Volume Snapshot": "Delete Volume Snapshot", "Delete Volume Snapshot": "Delete Volume Snapshot",
"Delete Volume Type": "Delete Volume Type", "Delete Volume Type": "Delete Volume Type",
"Delete Volume on Instance Delete": "Delete Volume on Instance Delete",
"Delete Zone": "Delete Zone", "Delete Zone": "Delete Zone",
"Delete metadata": "Delete metadata", "Delete metadata": "Delete metadata",
"Deleted": "Deleted", "Deleted": "Deleted",

View File

@ -744,6 +744,7 @@
"Delete Volume Backup": "Volume Backup 삭제", "Delete Volume Backup": "Volume Backup 삭제",
"Delete Volume Snapshot": "Volume Snapshot 삭제", "Delete Volume Snapshot": "Volume Snapshot 삭제",
"Delete Volume Type": "Volume Type 삭제", "Delete Volume Type": "Volume Type 삭제",
"Delete Volume on Instance Delete": "인스턴스 삭제 시 볼륨 삭제",
"Delete Zone": "Zone 삭제", "Delete Zone": "Zone 삭제",
"Delete metadata": "Metadata 삭제", "Delete metadata": "Metadata 삭제",
"Deleted": "삭제됨", "Deleted": "삭제됨",

View File

@ -744,6 +744,7 @@
"Delete Volume Backup": "删除云硬盘备份", "Delete Volume Backup": "删除云硬盘备份",
"Delete Volume Snapshot": "删除云硬盘快照", "Delete Volume Snapshot": "删除云硬盘快照",
"Delete Volume Type": "删除云硬盘类型", "Delete Volume Type": "删除云硬盘类型",
"Delete Volume on Instance Delete": "在实例删除时删除卷",
"Delete Zone": "删除区域", "Delete Zone": "删除区域",
"Delete metadata": "删除元数据", "Delete metadata": "删除元数据",
"Deleted": "已删除", "Deleted": "已删除",

View File

@ -802,6 +802,12 @@ export class BaseStep extends Base {
onChange: this.onSystemDiskChange, onChange: this.onSystemDiskChange,
dependencies: ['flavor', 'image', 'instanceSnapshot', 'bootFromVolume'], dependencies: ['flavor', 'image', 'instanceSnapshot', 'bootFromVolume'],
}, },
{
name: 'deleteVolumeInstance',
label: 'Delete Volume on Instance Delete',
type: 'check',
hidden: !this.sourceTypeIsVolume,
},
{ {
name: 'instanceSnapshotDisk', name: 'instanceSnapshotDisk',
label: t('System Disk'), label: t('System Disk'),

View File

@ -50,6 +50,11 @@ export class ConfirmStep extends Base {
return `${volume_type} ${size}GiB`; return `${volume_type} ${size}GiB`;
} }
getDeleteVolumeInstance() {
const { deleteVolumeInstance } = this.props?.context;
return deleteVolumeInstance ? t('Yes') : t('No');
}
getSystemDisk() { getSystemDisk() {
if (!this.enableCinder) return null; if (!this.enableCinder) return null;
const { context } = this.props; const { context } = this.props;
@ -218,6 +223,11 @@ export class ConfirmStep extends Base {
label: t('System Disk'), label: t('System Disk'),
value: this.getSystemDisk(), value: this.getSystemDisk(),
}, },
{
label: t('Delete Volume on Instance Delete'),
value: this.getDeleteVolumeInstance(),
key: 'deleteVolume',
},
{ {
label: t('Available Zone'), label: t('Available Zone'),
value: context.availableZone.label, value: context.availableZone.label,
@ -245,6 +255,9 @@ export class ConfirmStep extends Base {
(it) => ![t('System Disk'), t('Data Disk')].includes(it.label) (it) => ![t('System Disk'), t('Data Disk')].includes(it.label)
); );
} }
if (context.source.value.toUpperCase() !== 'BOOTABLEVOLUME') {
baseItems = baseItems.filter((it) => it?.key !== 'deleteVolume');
}
return [ return [
{ {
name: 'confirm-count', name: 'confirm-count',

View File

@ -579,6 +579,7 @@ export class StepCreate extends StepAction {
source, source,
systemDisk, systemDisk,
bootFromVolume = true, bootFromVolume = true,
deleteVolumeInstance,
} = values; } = values;
const { value: sourceValue } = source; const { value: sourceValue } = source;
const imageRef = const imageRef =
@ -619,6 +620,7 @@ export class StepCreate extends StepAction {
uuid: bootableVolume.selectedRowKeys[0], uuid: bootableVolume.selectedRowKeys[0],
source_type: 'volume', source_type: 'volume',
destination_type: 'volume', destination_type: 'volume',
delete_on_termination: deleteVolumeInstance,
}; };
} }
const dataVolumes = dataDisk const dataVolumes = dataDisk