feat: support restart for trove instance

support restart for trove instance

Change-Id: I016b87cdb31cf6c45a1befd0d4191b24fb9344de
This commit is contained in:
xusongfu 2022-07-20 16:52:21 +08:00
parent f4e3b66a67
commit bcda6b2cd9
7 changed files with 87 additions and 0 deletions

View File

@ -61,6 +61,10 @@ export class TroveClient extends Base {
);
},
},
{
key: 'action',
method: 'post',
},
],
},
{

View File

@ -586,6 +586,7 @@
"Database": "Database",
"Database Instance": "Database Instance",
"Database Instance Detail": "Database Instance Detail",
"Database Instance Status": "Database Instance Status",
"Database Name": "Database Name",
"Database Port": "Database Port",
"Database Service": "Database Service",
@ -1904,6 +1905,7 @@
"Resource Type": "Resource Type",
"Resource Types": "Resource Types",
"Resources Synced": "Resources Synced",
"Restart Database Service": "Restart Database Service",
"Restart Policy": "Restart Policy",
"Restarting": "Restarting",
"Restore Backup": "Restore Backup",

View File

@ -586,6 +586,7 @@
"Database": "数据库",
"Database Instance": "数据库实例",
"Database Instance Detail": "数据库实例详情",
"Database Instance Status": "数据库实例状态",
"Database Name": "数据库名称",
"Database Port": "数据库端口",
"Database Service": "数据库服务",
@ -1904,6 +1905,7 @@
"Resource Type": "资源类型",
"Resource Types": "资源类型",
"Resources Synced": "资源同步",
"Restart Database Service": "重启数据库服务",
"Restart Policy": "重启策略",
"Restarting": "重启中",
"Restore Backup": "恢复备份",

View File

@ -0,0 +1,53 @@
// 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 'restart';
}
get title() {
return t('Restart Database Service');
}
get isDanger() {
return true;
}
get buttonText() {
return t('Restart Database Service');
}
get actionName() {
return t('Restart Database Service');
}
get isAsyncAction() {
return true;
}
policy = 'instance:restart';
allowedCheckFunc = (item) =>
checkStatus(['active', 'shutoff', 'shutdown'], item);
onSubmit = (item) => {
const { id } = item || this.item;
return globalTroveInstanceStore.restart({ id });
};
}

View File

@ -15,6 +15,7 @@
import Delete from './Delete';
import Create from './StepCreate';
import Edit from './Edit';
import Restart from './Restart';
const actionConfigs = {
rowActions: {
@ -23,6 +24,10 @@ const actionConfigs = {
{
action: Edit,
},
{
title: t('Database Instance Status'),
actions: [Restart],
},
],
},
primaryActions: [Create],

View File

@ -79,6 +79,7 @@ export const policyMap = {
'instance:delete',
'instance:update',
'instance:backups',
'instance:restart',
'instance:resize',
'instance:extension',
'instance:guest_log_list',

View File

@ -42,6 +42,26 @@ export class InstancesStore extends Base {
return this.client.delete(params, newbody);
}
@action
update(id, body) {
return this.submitting(this.client.action(id, body));
}
@action
async operation({ body, id, key = '' }) {
let requestBody = body;
if (!requestBody) {
requestBody = {};
requestBody[key] = {};
}
return this.update(id, requestBody);
}
@action
async restart({ id }) {
return this.operation({ key: 'restart', id });
}
@action
async listDatastores() {
const result = await this.clientDatastore.list();