From 7f1f286a7dc95696ac1f78e9ea5e0e1807583095 Mon Sep 17 00:00:00 2001 From: lijiahangmax Date: Wed, 17 Apr 2024 00:10:44 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E4=B8=BB=E6=9C=BA=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=B7=BB=E5=8A=A0=E7=B3=BB=E7=BB=9F=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/update/v1.0.6.md | 13 +++++ .../module/asset/enums/HostSshOsTypeEnum.java | 44 +++++++++++++++++ .../host/config/model/HostSshConfigModel.java | 6 +++ .../strategy/HostSshConfigStrategy.java | 4 ++ .../host/extra/model/HostColorExtraModel.java | 2 +- .../components/config/ssh/ssh-config-form.vue | 48 +++++++++---------- .../components/config/ssh/types/const.ts | 14 +++++- .../components/config/ssh/types/form.rules.ts | 6 +++ .../components/group/host-group-drawer.vue | 4 +- .../dict-key/components/dict-key-table.vue | 2 +- .../system/menu/components/menu-table.vue | 5 +- 11 files changed, 115 insertions(+), 33 deletions(-) create mode 100644 orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/enums/HostSshOsTypeEnum.java diff --git a/docs/update/v1.0.6.md b/docs/update/v1.0.6.md index c1a85c78..a3ece676 100644 --- a/docs/update/v1.0.6.md +++ b/docs/update/v1.0.6.md @@ -3,9 +3,22 @@ > sql 脚本 - DDL ```sql +ALTER TABLE `exec_log` +ADD COLUMN `script_exec` tinyint(0) NULL DEFAULT 0 COMMENT '是否使用脚本执行' AFTER `timeout`; + +ALTER TABLE `exec_job` +ADD COLUMN `script_exec` tinyint(0) NULL DEFAULT 0 COMMENT '是否使用脚本执行' AFTER `timeout`; + +ALTER TABLE `exec_template` +ADD COLUMN `script_exec` tinyint(0) NULL DEFAULT 0 COMMENT '是否使用脚本执行' AFTER `timeout`; + +ALTER TABLE `exec_host_log` +ADD COLUMN `script_path` varchar(512) NULL COMMENT '脚本路径' AFTER `log_path`; ``` > sql 脚本 - DML ```sql +-- 设置主机配置中的 osType +UPDATE host_config SET config = JSON_SET(config, '$.osType', 'LINUX') WHERE type = 'ssh' AND deleted = 0; ``` diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/enums/HostSshOsTypeEnum.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/enums/HostSshOsTypeEnum.java new file mode 100644 index 00000000..c9273989 --- /dev/null +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/enums/HostSshOsTypeEnum.java @@ -0,0 +1,44 @@ +package com.orion.ops.module.asset.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * 主机系统类型 + * + * @author Jiahang Li + * @version 1.0.0 + * @since 2024/4/16 21:58 + */ +@Getter +@AllArgsConstructor +public enum HostSshOsTypeEnum { + + /** + * linux + */ + LINUX(".sh"), + + /** + * windows + */ + WINDOWS(".cmd"), + + ; + + private final String scriptSuffix; + + public static HostSshOsTypeEnum of(String type) { + if (type == null) { + return null; + } + for (HostSshOsTypeEnum value : values()) { + if (value.name().equals(type)) { + return value; + } + } + return null; + } + + +} diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/handler/host/config/model/HostSshConfigModel.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/handler/host/config/model/HostSshConfigModel.java index 9d9c9330..413c13fa 100644 --- a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/handler/host/config/model/HostSshConfigModel.java +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/handler/host/config/model/HostSshConfigModel.java @@ -38,8 +38,14 @@ public class HostSshConfigModel implements GenericsDataModel, UpdatePasswordActi @NotBlank @Size(max = 12) + @Schema(description = "认证方式") private String authType; + @NotBlank + @Size(max = 12) + @Schema(description = "系统类型") + private String osType; + @Schema(description = "密码") private String password; diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/handler/host/config/strategy/HostSshConfigStrategy.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/handler/host/config/strategy/HostSshConfigStrategy.java index 3ad6d3ee..2fdd1533 100644 --- a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/handler/host/config/strategy/HostSshConfigStrategy.java +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/handler/host/config/strategy/HostSshConfigStrategy.java @@ -12,6 +12,7 @@ import com.orion.ops.framework.common.security.PasswordModifier; import com.orion.ops.framework.common.utils.Valid; import com.orion.ops.module.asset.dao.HostIdentityDAO; import com.orion.ops.module.asset.dao.HostKeyDAO; +import com.orion.ops.module.asset.enums.HostSshOsTypeEnum; import com.orion.ops.module.asset.enums.HostSshAuthTypeEnum; import com.orion.ops.module.asset.handler.host.config.model.HostSshConfigModel; import org.springframework.stereotype.Component; @@ -45,6 +46,7 @@ public class HostSshConfigStrategy implements MapDataStrategy @@ -18,14 +18,20 @@ + + + + + :hide-asterisk="true"> @@ -43,8 +48,7 @@ + :hide-asterisk="true"> + :rules="passwordRules"> @@ -70,23 +73,20 @@ + :hide-asterisk="true"> + :hide-asterisk="true"> + :hide-asterisk="true"> @@ -98,22 +98,19 @@ + :hide-asterisk="true"> + :hide-asterisk="true"> + :hide-asterisk="true"> @@ -146,7 +143,7 @@ import type { HostSshConfig } from './types/const'; import { reactive, ref, watch } from 'vue'; import { updateHostConfigStatus, updateHostConfig } from '@/api/asset/host-config'; - import { sshAuthTypeKey, SshAuthType } from './types/const'; + import { sshAuthTypeKey, sshOsTypeKey, SshAuthType, SshOsType } from './types/const'; import rules from './types/form.rules'; import { Message } from '@arco-design/web-vue'; import useLoading from '@/hooks/loading'; @@ -157,7 +154,7 @@ import HostIdentitySelector from '@/components/asset/host-identity/selector/index.vue'; const { loading, setLoading } = useLoading(); - const { toRadioOptions } = useDictStore(); + const { toOptions, toRadioOptions } = useDictStore(); const props = defineProps<{ content: any; @@ -173,6 +170,7 @@ const formRef = ref(); const formModel = ref({ + osType: SshOsType.LINUX, username: undefined, port: undefined, password: undefined, diff --git a/orion-ops-ui/src/views/asset/host-list/components/config/ssh/types/const.ts b/orion-ops-ui/src/views/asset/host-list/components/config/ssh/types/const.ts index ac58cf5b..39c79db7 100644 --- a/orion-ops-ui/src/views/asset/host-list/components/config/ssh/types/const.ts +++ b/orion-ops-ui/src/views/asset/host-list/components/config/ssh/types/const.ts @@ -1,5 +1,6 @@ // 主机 SSH 配置 export interface HostSshConfig { + osType?: string; port?: number; username?: string; password?: string; @@ -14,7 +15,7 @@ export interface HostSshConfig { hasPassword?: boolean; } -// 主机 ssh 验证方式 +// 主机验证方式 export const SshAuthType = { // 密码验证 PASSWORD: 'PASSWORD', @@ -24,8 +25,17 @@ export const SshAuthType = { IDENTITY: 'IDENTITY' }; +// 主机系统版本 +export const SshOsType = { + LINUX: 'LINUX', + WINDOWS: 'WINDOWS', +}; + // 主机验证方式 字典项 export const sshAuthTypeKey = 'hostSshAuthType'; +// 主机系统类型 字典项 +export const sshOsTypeKey = 'hostSshOsType'; + // 加载的字典值 -export const dictKeys = [sshAuthTypeKey]; +export const dictKeys = [sshAuthTypeKey, sshOsTypeKey]; diff --git a/orion-ops-ui/src/views/asset/host-list/components/config/ssh/types/form.rules.ts b/orion-ops-ui/src/views/asset/host-list/components/config/ssh/types/form.rules.ts index 7d08b595..3577d496 100644 --- a/orion-ops-ui/src/views/asset/host-list/components/config/ssh/types/form.rules.ts +++ b/orion-ops-ui/src/views/asset/host-list/components/config/ssh/types/form.rules.ts @@ -1,5 +1,10 @@ import type { FieldRule } from '@arco-design/web-vue'; +export const osType = [{ + required: true, + message: '请选择系统类型' +}] as FieldRule[]; + export const port = [{ required: true, message: '请输入SSH端口' @@ -60,6 +65,7 @@ export const fileContentCharset = [{ }] as FieldRule[]; export default { + osType, port, authType, keyId, diff --git a/orion-ops-ui/src/views/asset/host-list/components/group/host-group-drawer.vue b/orion-ops-ui/src/views/asset/host-list/components/group/host-group-drawer.vue index c3181b4d..e85b44bf 100644 --- a/orion-ops-ui/src/views/asset/host-list/components/group/host-group-drawer.vue +++ b/orion-ops-ui/src/views/asset/host-list/components/group/host-group-drawer.vue @@ -1,7 +1,7 @@