feat: support stop action in trove instance

Support stop database service in trove instance

Change-Id: I3dfa3e8242f45c689ffba171d7ecff629e2c1573
This commit is contained in:
xusongfu 2022-07-22 15:52:09 +08:00
parent 9597ed1516
commit 4d27908ce5
7 changed files with 79 additions and 2 deletions

View File

@ -97,6 +97,17 @@ export class TroveClient extends Base {
}, },
], ],
}, },
{
name: 'instancesAdmin',
key: 'mgmt/instances',
responseKey: 'instance',
extendOperations: [
{
key: 'action',
method: 'post',
},
],
},
]; ];
} }
} }

View File

@ -1905,6 +1905,7 @@
"Resource Type": "Resource Type", "Resource Type": "Resource Type",
"Resource Types": "Resource Types", "Resource Types": "Resource Types",
"Resources Synced": "Resources Synced", "Resources Synced": "Resources Synced",
"Restart": "Restart",
"Restart Database Service": "Restart Database Service", "Restart Database Service": "Restart Database Service",
"Restart Policy": "Restart Policy", "Restart Policy": "Restart Policy",
"Restarting": "Restarting", "Restarting": "Restarting",
@ -2136,6 +2137,7 @@
"Status Reason": "Status Reason", "Status Reason": "Status Reason",
"Stop": "Stop", "Stop": "Stop",
"Stop Container": "Stop Container", "Stop Container": "Stop Container",
"Stop Database Service": "Stop Database Service",
"Stop Instance": "Stop Instance", "Stop Instance": "Stop Instance",
"Stop auto refreshing data": "Stop auto refreshing data", "Stop auto refreshing data": "Stop auto refreshing data",
"Stop refreshing data every {num} seconds": "Stop refreshing data every {num} seconds", "Stop refreshing data every {num} seconds": "Stop refreshing data every {num} seconds",

View File

@ -1905,6 +1905,7 @@
"Resource Type": "资源类型", "Resource Type": "资源类型",
"Resource Types": "资源类型", "Resource Types": "资源类型",
"Resources Synced": "资源同步", "Resources Synced": "资源同步",
"Restart": "重启",
"Restart Database Service": "重启数据库服务", "Restart Database Service": "重启数据库服务",
"Restart Policy": "重启策略", "Restart Policy": "重启策略",
"Restarting": "重启中", "Restarting": "重启中",
@ -2136,6 +2137,7 @@
"Status Reason": "状态原因", "Status Reason": "状态原因",
"Stop": "关闭", "Stop": "关闭",
"Stop Container": "关闭容器", "Stop Container": "关闭容器",
"Stop Database Service": "停止数据库服务",
"Stop Instance": "关闭云主机", "Stop Instance": "关闭云主机",
"Stop auto refreshing data": "关闭自动刷新数据", "Stop auto refreshing data": "关闭自动刷新数据",
"Stop refreshing data every {num} seconds": "关闭每{num}秒自动刷新数据", "Stop refreshing data every {num} seconds": "关闭每{num}秒自动刷新数据",

View File

@ -30,7 +30,7 @@ export default class StartAction extends ConfirmAction {
} }
get buttonText() { get buttonText() {
return t('Restart Database Service'); return t('Restart');
} }
get actionName() { get actionName() {

View File

@ -0,0 +1,52 @@
// Copyright 2021 99cloud
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import { ConfirmAction } from 'containers/Action';
import { checkStatus } from 'resources/nova/instance';
import globalTroveInstanceStore from 'stores/trove/instances';
export default class StartAction extends ConfirmAction {
get id() {
return 'stop';
}
get title() {
return t('Stop Database Service');
}
get isDanger() {
return true;
}
get buttonText() {
return t('Stop');
}
get actionName() {
return t('Stop Database Service');
}
get isAsyncAction() {
return true;
}
policy = 'instance:stop';
allowedCheckFunc = (item) => checkStatus(['active'], item);
onSubmit = (item) => {
const { id } = item || this.item;
return globalTroveInstanceStore.stop({ id });
};
}

View File

@ -16,6 +16,7 @@ import Delete from './Delete';
import Create from './StepCreate'; import Create from './StepCreate';
import Edit from './Edit'; import Edit from './Edit';
import Restart from './Restart'; import Restart from './Restart';
import Stop from './Stop';
const actionConfigs = { const actionConfigs = {
rowActions: { rowActions: {
@ -26,7 +27,7 @@ const actionConfigs = {
}, },
{ {
title: t('Database Instance Status'), title: t('Database Instance Status'),
actions: [Restart], actions: [Restart, Stop],
}, },
], ],
}, },

View File

@ -32,6 +32,10 @@ export class InstancesStore extends Base {
return client.trove.configurations; return client.trove.configurations;
} }
get adminClient() {
return client.trove.instancesAdmin;
}
@action @action
async create(newbody) { async create(newbody) {
return this.submitting(this.client.create(newbody)); return this.submitting(this.client.create(newbody));
@ -62,6 +66,11 @@ export class InstancesStore extends Base {
return this.operation({ key: 'restart', id }); return this.operation({ key: 'restart', id });
} }
@action
async stop({ id }) {
return this.submitting(this.adminClient.action(id, { stop: {} }));
}
@action @action
async listDatastores() { async listDatastores() {
const result = await this.clientDatastore.list(); const result = await this.clientDatastore.list();