mirror of
https://github.com/certd/certd.git
synced 2026-07-10 23:27:34 +08:00
chore: format
This commit is contained in:
+54
-54
@@ -3,11 +3,11 @@ import { createRemoteSelectInputDefine } from "@certd/plugin-lib";
|
||||
import { TencentAccess } from "../../../plugin-lib/tencent/access.js";
|
||||
|
||||
@IsTaskPlugin({
|
||||
name: 'TencentActionInstancesPlugin',
|
||||
title: '腾讯云-实例开关机',
|
||||
icon: 'svg:icon-tencentcloud',
|
||||
name: "TencentActionInstancesPlugin",
|
||||
title: "腾讯云-实例开关机",
|
||||
icon: "svg:icon-tencentcloud",
|
||||
group: pluginGroups.tencent.key,
|
||||
desc: '腾讯云实例开关机',
|
||||
desc: "腾讯云实例开关机",
|
||||
default: {
|
||||
strategy: {
|
||||
runStrategy: RunStrategy.AlwaysRun,
|
||||
@@ -17,46 +17,46 @@ import { TencentAccess } from "../../../plugin-lib/tencent/access.js";
|
||||
})
|
||||
export class TencentActionInstancesPlugin extends AbstractTaskPlugin {
|
||||
@TaskInput({
|
||||
title: 'Access提供者',
|
||||
helper: 'access 授权',
|
||||
title: "Access提供者",
|
||||
helper: "access 授权",
|
||||
component: {
|
||||
name: 'access-selector',
|
||||
type: 'tencent',
|
||||
name: "access-selector",
|
||||
type: "tencent",
|
||||
},
|
||||
required: true,
|
||||
})
|
||||
accessId!: string;
|
||||
|
||||
@TaskInput({
|
||||
title: '所在地域',
|
||||
helper: '实例所在地域',
|
||||
title: "所在地域",
|
||||
helper: "实例所在地域",
|
||||
component: {
|
||||
name: 'a-auto-complete',
|
||||
vModel: 'value',
|
||||
name: "a-auto-complete",
|
||||
vModel: "value",
|
||||
options: [
|
||||
{ value: '', label: '--------中国大陆地区-------', disabled: true },
|
||||
{ value: 'ap-beijing-1', label: '北京1区' },
|
||||
{ value: 'ap-beijing', label: '北京' },
|
||||
{ value: 'ap-nanjing', label: '南京' },
|
||||
{ value: 'ap-shanghai', label: '上海' },
|
||||
{ value: 'ap-guangzhou', label: '广州' },
|
||||
{ value: 'ap-chengdu', label: '成都' },
|
||||
{ value: 'ap-chongqing', label: '重庆' },
|
||||
{ value: 'ap-shenzhen-fsi', label: '深圳金融' },
|
||||
{ value: 'ap-shanghai-fsi', label: '上海金融' },
|
||||
{ value: 'ap-beijing-fsi', label: '北京金融' },
|
||||
{ value: '', label: '--------中国香港及境外-------', disabled: true },
|
||||
{ value: 'ap-hongkong', label: '中国香港' },
|
||||
{ value: 'ap-singapore', label: '新加坡' },
|
||||
{ value: 'ap-mumbai', label: '孟买' },
|
||||
{ value: 'ap-jakarta', label: '雅加达' },
|
||||
{ value: 'ap-seoul', label: '首尔' },
|
||||
{ value: 'ap-bangkok', label: '曼谷' },
|
||||
{ value: 'ap-tokyo', label: '东京' },
|
||||
{ value: 'na-siliconvalley', label: '硅谷' },
|
||||
{ value: 'na-ashburn', label: '弗吉尼亚' },
|
||||
{ value: 'sa-saopaulo', label: '圣保罗' },
|
||||
{ value: 'eu-frankfurt', label: '法兰克福' },
|
||||
{ value: "", label: "--------中国大陆地区-------", disabled: true },
|
||||
{ value: "ap-beijing-1", label: "北京1区" },
|
||||
{ value: "ap-beijing", label: "北京" },
|
||||
{ value: "ap-nanjing", label: "南京" },
|
||||
{ value: "ap-shanghai", label: "上海" },
|
||||
{ value: "ap-guangzhou", label: "广州" },
|
||||
{ value: "ap-chengdu", label: "成都" },
|
||||
{ value: "ap-chongqing", label: "重庆" },
|
||||
{ value: "ap-shenzhen-fsi", label: "深圳金融" },
|
||||
{ value: "ap-shanghai-fsi", label: "上海金融" },
|
||||
{ value: "ap-beijing-fsi", label: "北京金融" },
|
||||
{ value: "", label: "--------中国香港及境外-------", disabled: true },
|
||||
{ value: "ap-hongkong", label: "中国香港" },
|
||||
{ value: "ap-singapore", label: "新加坡" },
|
||||
{ value: "ap-mumbai", label: "孟买" },
|
||||
{ value: "ap-jakarta", label: "雅加达" },
|
||||
{ value: "ap-seoul", label: "首尔" },
|
||||
{ value: "ap-bangkok", label: "曼谷" },
|
||||
{ value: "ap-tokyo", label: "东京" },
|
||||
{ value: "na-siliconvalley", label: "硅谷" },
|
||||
{ value: "na-ashburn", label: "弗吉尼亚" },
|
||||
{ value: "sa-saopaulo", label: "圣保罗" },
|
||||
{ value: "eu-frankfurt", label: "法兰克福" },
|
||||
],
|
||||
},
|
||||
required: true,
|
||||
@@ -65,23 +65,23 @@ export class TencentActionInstancesPlugin extends AbstractTaskPlugin {
|
||||
|
||||
@TaskInput(
|
||||
createRemoteSelectInputDefine({
|
||||
title: '实列ID',
|
||||
helper: '请选择实列',
|
||||
typeName: 'TencentStartInstancesPlugin',
|
||||
title: "实列ID",
|
||||
helper: "请选择实列",
|
||||
typeName: "TencentStartInstancesPlugin",
|
||||
action: TencentActionInstancesPlugin.prototype.onGetInstanceList.name,
|
||||
watches: ['region'],
|
||||
watches: ["region"],
|
||||
})
|
||||
)
|
||||
instanceId!: string[];
|
||||
|
||||
@TaskInput({
|
||||
title: '操作',
|
||||
title: "操作",
|
||||
component: {
|
||||
name: 'a-radio-group',
|
||||
vModel: 'value',
|
||||
name: "a-radio-group",
|
||||
vModel: "value",
|
||||
options: [
|
||||
{ value: 'start', label: '开机' },
|
||||
{ value: 'stop', label: '关机' },
|
||||
{ value: "start", label: "开机" },
|
||||
{ value: "stop", label: "关机" },
|
||||
],
|
||||
},
|
||||
required: true,
|
||||
@@ -89,11 +89,11 @@ export class TencentActionInstancesPlugin extends AbstractTaskPlugin {
|
||||
action!: string;
|
||||
|
||||
@TaskInput({
|
||||
title: '实例关机不收费',
|
||||
title: "实例关机不收费",
|
||||
value: true,
|
||||
component: {
|
||||
name: 'a-switch',
|
||||
vModel: 'checked',
|
||||
name: "a-switch",
|
||||
vModel: "checked",
|
||||
placeholder: `按量计费实例关机不收费`,
|
||||
},
|
||||
required: false,
|
||||
@@ -115,13 +115,13 @@ export class TencentActionInstancesPlugin extends AbstractTaskPlugin {
|
||||
InstanceIds: this.instanceId,
|
||||
};
|
||||
let res: any;
|
||||
if (this.action === 'start') {
|
||||
if (this.action === "start") {
|
||||
res = await cvmClient.StartInstances(params);
|
||||
} else {
|
||||
res = await cvmClient.StopInstances(
|
||||
Object.assign(params, {
|
||||
StopType: 'SOFT_FIRST',
|
||||
StoppedMode: this.charging ? 'STOP_CHARGING' : 'KEEP_CHARGING',
|
||||
StopType: "SOFT_FIRST",
|
||||
StoppedMode: this.charging ? "STOP_CHARGING" : "KEEP_CHARGING",
|
||||
})
|
||||
);
|
||||
}
|
||||
@@ -131,17 +131,17 @@ export class TencentActionInstancesPlugin extends AbstractTaskPlugin {
|
||||
|
||||
checkRet(ret: any) {
|
||||
if (!ret || ret.Error) {
|
||||
throw new Error('执行失败:' + ret.Error.Code + ',' + ret.Error.Message);
|
||||
throw new Error("执行失败:" + ret.Error.Code + "," + ret.Error.Message);
|
||||
}
|
||||
}
|
||||
|
||||
async getCvmClient() {
|
||||
const accessProvider = await this.getAccess<TencentAccess>(this.accessId);
|
||||
const sdk = await import('tencentcloud-sdk-nodejs/tencentcloud/services/cvm/v20170312/index.js');
|
||||
const sdk = await import("tencentcloud-sdk-nodejs/tencentcloud/services/cvm/v20170312/index.js");
|
||||
const CvmClient = sdk.v20170312.Client;
|
||||
|
||||
if (!this.region) {
|
||||
throw new Error('所在地域不能为空');
|
||||
throw new Error("所在地域不能为空");
|
||||
}
|
||||
|
||||
const clientConfig = {
|
||||
@@ -167,7 +167,7 @@ export class TencentActionInstancesPlugin extends AbstractTaskPlugin {
|
||||
});
|
||||
this.checkRet(res);
|
||||
|
||||
this.ctx.logger.info('获取实列列表:', res);
|
||||
this.ctx.logger.info("获取实列列表:", res);
|
||||
return res.InstanceSet.map((item: any) => {
|
||||
return {
|
||||
label: item.InstanceName,
|
||||
|
||||
Reference in New Issue
Block a user