fix: Fix delete shelved instance

Fix delete shelved instance

Change-Id: I696be27bcb25b765c1f57ca10be51404cddc1722
This commit is contained in:
Jingwei.Zhang 2021-09-17 13:58:46 +08:00
parent 8622cb97eb
commit 62234626f5
3 changed files with 82 additions and 29 deletions

View File

@ -68,7 +68,6 @@
"After attaching interface, you may need to login the instance to update the network interface configuration and restart the network service.": "After attaching interface, you may need to login the instance to update the network interface configuration and restart the network service.",
"After disable the compute service, the new instance will not schedule to the compute node.": "After disable the compute service, the new instance will not schedule to the compute node.",
"After shelving, the instance will be shut down, resources will be released, and the snapshot will be saved to Glance. This will take about a few minutes, please be patient. You also can choose to unshelve to restore the instance.": "After shelving, the instance will be shut down, resources will be released, and the snapshot will be saved to Glance. This will take about a few minutes, please be patient. You also can choose to unshelve to restore the instance.",
"After the instance is deleted, the instance root disk data will be lost. ": "After the instance is deleted, the instance root disk data will be lost. ",
"After the volume is expanded, the volume cannot be reduced.": "After the volume is expanded, the volume cannot be reduced.",
"Agent": "Agent",
"Agree to force shutdown": "Agree to force shutdown",
@ -1548,7 +1547,6 @@
"The instance architecture diagram mainly shows the overall architecture composition of the instance. If you need to view the network topology of the instance, please go to: ": "The instance architecture diagram mainly shows the overall architecture composition of the instance. If you need to view the network topology of the instance, please go to: ",
"The instance deleted immediately cannot be restored": "The instance deleted immediately cannot be restored",
"The instance is not shut down, unable to restore.": "The instance is not shut down, unable to restore.",
"The instance root volume and snapshot will be removed.": "The instance root volume and snapshot will be removed.",
"The instances in the affinity group are allocated to the same physical machine as much as possible, and when there are no more physical machines to allocate, the normal allocation strategy is returned.": "The instances in the affinity group are allocated to the same physical machine as much as possible, and when there are no more physical machines to allocate, the normal allocation strategy is returned.",
"The instances in the affinity group are strictly allocated to the same physical machine. When there are no more physical machines to allocate, the allocation fails.": "The instances in the affinity group are strictly allocated to the same physical machine. When there are no more physical machines to allocate, the allocation fails.",
"The instances in the anti-affinity group are allocated to different physical machines as much as possible. When there are no more physical machines to allocate, the normal allocation strategy is returned.": "The instances in the anti-affinity group are allocated to different physical machines as much as possible. When there are no more physical machines to allocate, the normal allocation strategy is returned.",
@ -1578,6 +1576,7 @@
"The selected VPC/ subnet does not have IPv6 enabled.": "The selected VPC/ subnet does not have IPv6 enabled.",
"The selected network has no subnet": "The selected network has no subnet",
"The server {name} is locked. Please unlock first.": "The server {name} is locked. Please unlock first.",
"The shelved offloaded instance only supports immediate deletion": "The shelved offloaded instance only supports immediate deletion",
"The start source is a template used to create an instance. You can choose an image or a bootable volume.": "The start source is a template used to create an instance. You can choose an image or a bootable volume.",
"The starting number must be less than the ending number": "The starting number must be less than the ending number",
"The timeout period of waiting for the return of the health check request, the check timeout will be judged as a check failure": "The timeout period of waiting for the return of the health check request, the check timeout will be judged as a check failure",

View File

@ -68,7 +68,6 @@
"After attaching interface, you may need to login the instance to update the network interface configuration and restart the network service.": "挂载网卡后,您可能需要登录到云主机更新网卡配置并且重启网络服务。",
"After disable the compute service, the new instance will not schedule to the compute node.": "禁用计算服务之后,新的云主机不会调度到该计算节点。",
"After shelving, the instance will be shut down, resources will be released, and the snapshot will be saved to Glance. This will take about a few minutes, please be patient. You also can choose to unshelve to restore the instance.": "归档后会关闭云主机,释放资源,并将快照保存到 Glance ,这大约需要数分钟时间,请耐心等待。在归档之后您也可以选择取消归档来恢复这台云主机。",
"After the instance is deleted, the instance root disk data will be lost. ": "删除云主机后,云主机根硬盘数据将丢失。",
"After the volume is expanded, the volume cannot be reduced.": "扩容云硬盘后,云硬盘不可再缩小。",
"Agent": "",
"Agree to force shutdown": "同意强制关机",
@ -1548,7 +1547,6 @@
"The instance architecture diagram mainly shows the overall architecture composition of the instance. If you need to view the network topology of the instance, please go to: ": "云主机架构图主要展示云主机的总体架构组成。如果需要查看云主机的网络拓扑,请转到:",
"The instance deleted immediately cannot be restored": "立即删除的云主机无法恢复",
"The instance is not shut down, unable to restore.": "云主机不处于关机状态,不支持恢复备份操作。",
"The instance root volume and snapshot will be removed.": "云主机根硬盘和快照将随之删除。",
"The instances in the affinity group are allocated to the same physical machine as much as possible, and when there are no more physical machines to allocate, the normal allocation strategy is returned.": "将亲和组内的云主机尽量分配到不同物理机上,当没有更多物理机可分配时,回归普通分配策略。",
"The instances in the affinity group are strictly allocated to the same physical machine. When there are no more physical machines to allocate, the allocation fails.": "将亲和组内的云主机严格分配到同一物理机上,当没有更多物理机可分配时,则分配失败。",
"The instances in the anti-affinity group are allocated to different physical machines as much as possible. When there are no more physical machines to allocate, the normal allocation strategy is returned.": "将反亲和组内的云主机尽量分配到不同物理机上,当没有更多物理机可分配时,回归普通分配策略。",
@ -1578,6 +1576,7 @@
"The selected VPC/ subnet does not have IPv6 enabled.": "所选的VPC/子网未开通IPv6",
"The selected network has no subnet": "选择的网络没有子网",
"The server {name} is locked. Please unlock first.": "云主机{name}已被锁定,请先解锁。",
"The shelved offloaded instance only supports immediate deletion": "已归档的云主机仅支持立即删除",
"The start source is a template used to create an instance. You can choose an image or a bootable volume.": "启动源是用来创建云主机的模板, 您可以选择镜像或者可启动的卷。",
"The starting number must be less than the ending number": "起始数字必须小于结束数字",
"The timeout period of waiting for the return of the health check request, the check timeout will be judged as a check failure": "等待健康检查请求返回的超时时间,检查超时将会被判定为一次检查失败",

View File

@ -65,9 +65,70 @@ export default class SoftDelete extends ConfirmAction {
}
}
confirmContext = (data) => {
const name = this.getName(data);
isShelved = (item) => item.status === 'shelved_offloaded';
hasShelvedItem = (data) => {
const items = isArray(data) ? data : [data];
const item = items.find(this.isShelved);
return !!item;
};
allShelvedItem = (data) => {
const items = isArray(data) ? data : [data];
return items.every(this.isShelved);
};
initChangeType = (data) => {
if (this.allShelvedItem(data)) {
this.onChangeType(true, data);
this.initCheckedValue = true;
return;
}
this.initCheckedValue = false;
this.onChangeType(false, data);
};
renderExtra(data) {
if (this.hasShelvedItem(data)) {
return (
<div style={{ color: 'rgba(0, 0, 0, 0.45)' }}>
{t('The shelved offloaded instance only supports immediate deletion')}
</div>
);
}
return null;
}
renderCheckbox(data) {
const checkbox = this.initCheckedValue ? (
<Checkbox checked={this.initCheckedValue} disabled>
{t('Immediately delete')}
</Checkbox>
) : (
<Checkbox
onChange={(e) => {
this.onChangeType(e.target.checked, data);
}}
>
{t('Immediately delete')}
</Checkbox>
);
return checkbox;
}
get deleteTip() {
return t(
'When the computing service starts the recycling instance interval, the instance will be stored in the recycling bin after deletion, and will be retained according to the corresponding time interval. You can choose to restore it within this period. After successful recovery, the status of the instance is running and related resources remain unchanged.'
);
}
get snapshotTip() {
return t(
'If you still want to keep the disk data, it is recommended that you create a snapshot for the disk before deleting.'
);
}
renderCheckboxTip() {
const tip = (
<div className={styles.tip}>
<h4 className={styles['tip-title']}>
@ -78,16 +139,20 @@ export default class SoftDelete extends ConfirmAction {
{t(
'The associated floating IP, virtual adapter, volume and other resources will be automatically disassociated.'
)}
{/* {t('The instance root volume and snapshot will be removed.')} */}
</p>
<p className={styles['tip-content']}>
{/* {t('After the instance is deleted, the instance root disk data will be lost. ')} */}
{t(
'If you still want to keep the disk data, it is recommended that you create a snapshot for the disk before deleting.'
)}
</p>
<p className={styles['tip-content']}>{this.snapshotTip}</p>
</div>
);
return (
<Tooltip title={tip} color="white">
<QuestionCircleOutlined />
</Tooltip>
);
}
confirmContext = (data) => {
const name = this.getName(data);
this.initChangeType(data);
return (
<div>
<p className={styles.mb16}>
@ -95,23 +160,12 @@ export default class SoftDelete extends ConfirmAction {
t('Are you sure to delete instance { name }? ', { name })
)}
</p>
<p className={styles.mb16}>
{t(
'When the computing service starts the recycling instance interval, the instance will be stored in the recycling bin after deletion, and will be retained according to the corresponding time interval. You can choose to restore it within this period. After successful recovery, the status of the instance is running and related resources remain unchanged.'
)}
</p>
<p className={styles.mb16}>{this.deleteTip}</p>
<div>
<Checkbox
onChange={(e) => {
this.onChangeType(e.target.checked, data);
}}
>
{t('Immediately delete')}
</Checkbox>
<Tooltip title={tip} color="white">
<QuestionCircleOutlined />
</Tooltip>
{this.renderCheckbox(data)}
{this.renderCheckboxTip()}
</div>
{this.renderExtra(data)}
</div>
);
};
@ -141,7 +195,8 @@ export default class SoftDelete extends ConfirmAction {
onSubmit = (item) => {
const { id, isHardDeleted = false } = item || this.item;
if (isHardDeleted) {
const isShelved = this.isShelved(item || this.item);
if (isHardDeleted || isShelved) {
return globalServerStore.forceDelete({ id });
}
return globalServerStore.delete({ id });