fix: Fix extend volume when instance is locked

fix extend volume when instance is locked

Change-Id: Ib5333ee118cf95d46790ed8548a172845d2b4a23
This commit is contained in:
zhuyue 2021-09-02 14:39:24 +08:00 committed by zhu yue
parent fd6340c84d
commit 101025eaac
5 changed files with 45 additions and 2 deletions

View File

@ -930,6 +930,7 @@
"Lock": "Lock", "Lock": "Lock",
"Lock Instance": "Lock Instance", "Lock Instance": "Lock Instance",
"Lock Status": "Lock Status", "Lock Status": "Lock Status",
"Lock instance will lock the operations that have a direct impact on the operation of the instance, such as shutdown, restart, delete, etc. It does not involve the mounting, unmounting and capacity expansion of volumn.": "Lock instance will lock the operations that have a direct impact on the operation of the instance, such as shutdown, restart, delete, etc. It does not involve the mounting, unmounting and capacity expansion of volumn.",
"Locked": "Locked", "Locked": "Locked",
"Log in": "Log in", "Log in": "Log in",
"Login Name": "Login Name", "Login Name": "Login Name",
@ -1584,6 +1585,7 @@
"The security group is similar to the firewall function for setting up network access control, or you can go to the console and create a new security group. (Note: The security group you selected will work on all virtual LANS on the instances.)": "The security group is similar to the firewall function for setting up network access control, or you can go to the console and create a new security group. (Note: The security group you selected will work on all virtual LANS on the instances.)", "The security group is similar to the firewall function for setting up network access control, or you can go to the console and create a new security group. (Note: The security group you selected will work on all virtual LANS on the instances.)": "The security group is similar to the firewall function for setting up network access control, or you can go to the console and create a new security group. (Note: The security group you selected will work on all virtual LANS on the instances.)",
"The selected VPC/ subnet does not have IPv6 enabled.": "The selected VPC/ subnet does not have IPv6 enabled.", "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 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 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 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 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", "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",
@ -1675,6 +1677,7 @@
"Used by tunnel(s): {names}. ID(s): {ids}": "Used by tunnel(s): {names}. ID(s): {ids}", "Used by tunnel(s): {names}. ID(s): {ids}": "Used by tunnel(s): {names}. ID(s): {ids}",
"User": "User", "User": "User",
"User Account": "User Account", "User Account": "User Account",
"User Center": "User Center",
"User Data": "User Data", "User Data": "User Data",
"User Detail": "User Detail", "User Detail": "User Detail",
"User Edit": "User Edit", "User Edit": "User Edit",

View File

@ -930,6 +930,7 @@
"Lock": "锁定", "Lock": "锁定",
"Lock Instance": "锁定云主机", "Lock Instance": "锁定云主机",
"Lock Status": "锁定状态", "Lock Status": "锁定状态",
"Lock instance will lock the operations that have a direct impact on the operation of the instance, such as shutdown, restart, delete, etc. It does not involve the mounting, unmounting and capacity expansion of volumn.": "云主机锁定操作会锁定对云主机运行有直接影响的操作, 例如: 关机, 重启, 删除等,不涉及云硬盘的挂载卸载和扩容。",
"Locked": "锁定", "Locked": "锁定",
"Log in": "登录", "Log in": "登录",
"Login Name": "登录名", "Login Name": "登录名",
@ -1584,6 +1585,7 @@
"The security group is similar to the firewall function for setting up network access control, or you can go to the console and create a new security group. (Note: The security group you selected will work on all virtual LANS on the instances.)": "安全组类似防火墙功能,用于设置网络访问控制,您也可以前往控制台新建安全组。(注:您所选的安全组将作用于云主机的全部虚拟网卡。)", "The security group is similar to the firewall function for setting up network access control, or you can go to the console and create a new security group. (Note: The security group you selected will work on all virtual LANS on the instances.)": "安全组类似防火墙功能,用于设置网络访问控制,您也可以前往控制台新建安全组。(注:您所选的安全组将作用于云主机的全部虚拟网卡。)",
"The selected VPC/ subnet does not have IPv6 enabled.": "所选的VPC/子网未开通IPv6", "The selected VPC/ subnet does not have IPv6 enabled.": "所选的VPC/子网未开通IPv6",
"The selected network has no subnet": "选择的网络没有子网", "The selected network has no subnet": "选择的网络没有子网",
"The server {name} is locked. Please unlock first.": "云主机{name}已被锁定,请先解锁。",
"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": "等待健康检查请求返回的超时时间,检查超时将会被判定为一次检查失败",
@ -1675,6 +1677,7 @@
"Used by tunnel(s): {names}. ID(s): {ids}": "被隧道使用中:{names}。 ID{ids}", "Used by tunnel(s): {names}. ID(s): {ids}": "被隧道使用中:{names}。 ID{ids}",
"User": "用户", "User": "用户",
"User Account": "用户账户", "User Account": "用户账户",
"User Center": "用户中心",
"User Data": "用户数据", "User Data": "用户数据",
"User Detail": "用户详情", "User Detail": "用户详情",
"User Edit": "编辑用户", "User Edit": "编辑用户",

View File

@ -57,6 +57,24 @@ export default class LockAction extends ConfirmAction {
return errorMsg; return errorMsg;
}; };
confirmContext = (data) => {
if (!this.messageHasItemName) {
return t('Are you sure to {action}?', {
action: this.actionNameDisplay || this.title,
});
}
const name = this.getName(data);
return (
t('Are you sure to {action} (instance: {name})?', {
action: this.actionNameDisplay || this.title,
name,
}) +
t(
'Lock instance will lock the operations that have a direct impact on the operation of the instance, such as shutdown, restart, delete, etc. It does not involve the mounting, unmounting and capacity expansion of volumn.'
)
);
};
onSubmit = () => { onSubmit = () => {
const { id } = this.item; const { id } = this.item;
return globalServerStore.lock({ id }); return globalServerStore.lock({ id });

View File

@ -16,6 +16,9 @@ import { inject, observer } from 'mobx-react';
import { ModalAction } from 'containers/Action'; import { ModalAction } from 'containers/Action';
import globalVolumeStore from 'stores/cinder/volume'; import globalVolumeStore from 'stores/cinder/volume';
import { isAvailableOrInUse } from 'resources/volume'; import { isAvailableOrInUse } from 'resources/volume';
import { get } from 'lodash';
import client from 'client';
import Notify from 'components/Notify';
export class ExtendVolume extends ModalAction { export class ExtendVolume extends ModalAction {
static id = 'extend-snapshot'; static id = 'extend-snapshot';
@ -69,9 +72,25 @@ export class ExtendVolume extends ModalAction {
this.store = globalVolumeStore; this.store = globalVolumeStore;
} }
onSubmit = (values) => { onSubmit = async (values) => {
const { volume, ...rest } = values; const { volume, ...rest } = values;
const { id } = this.item; const { id } = this.item;
const instanceId = get(this.item, 'attachments[0].server_id');
if (instanceId) {
const { server } = await client.nova.servers.show(instanceId);
if (server.locked) {
Notify.errorWithDetail(
t('The server {name} is locked. Please unlock first.', {
name: server.name,
}),
t('The server {name} is locked. Please unlock first.', {
name: server.name,
})
);
return Promise.reject();
}
}
return this.store.extendSize(id, rest); return this.store.extendSize(id, rest);
}; };
} }

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import BaseLayout from '@/layouts/Basic'; import BaseLayout from 'layouts/Basic';
import E404 from 'pages/base/containers/404'; import E404 from 'pages/base/containers/404';
import UserCenter from '../containers/UserCenter'; import UserCenter from '../containers/UserCenter';