✨ 主机配置添加系统类型.
This commit is contained in:
@@ -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;
|
||||
```
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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<HostSshConfigModel
|
||||
.port(SSH_PORT)
|
||||
.username(USERNAME)
|
||||
.authType(HostSshAuthTypeEnum.PASSWORD.name())
|
||||
.osType(HostSshOsTypeEnum.LINUX.name())
|
||||
.connectTimeout(Const.MS_S_10)
|
||||
.charset(Const.UTF_8)
|
||||
.fileNameCharset(Const.UTF_8)
|
||||
@@ -56,6 +58,8 @@ public class HostSshConfigStrategy implements MapDataStrategy<HostSshConfigModel
|
||||
public void preValid(HostSshConfigModel model) {
|
||||
// 验证认证类型
|
||||
Valid.valid(HostSshAuthTypeEnum::of, model.getAuthType());
|
||||
// 验证系统版本
|
||||
Valid.valid(HostSshOsTypeEnum::of, model.getOsType());
|
||||
// 验证编码格式
|
||||
this.validCharset(model.getCharset());
|
||||
this.validCharset(model.getFileNameCharset());
|
||||
|
||||
@@ -21,7 +21,7 @@ import lombok.NoArgsConstructor;
|
||||
@Schema(name = "HostExtraSshModel", description = "主机拓展信息 - color 模型")
|
||||
public class HostColorExtraModel implements GenericsDataModel {
|
||||
|
||||
@Schema(description = "颜色")
|
||||
@Schema(description = "标签 tab 颜色")
|
||||
private String color;
|
||||
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
<a-switch v-model="config.status"
|
||||
:disabled="loading"
|
||||
type="round"
|
||||
:checked-value="1"
|
||||
:unchecked-value="0"
|
||||
:checked-value="EnabledStatus.ENABLED"
|
||||
:unchecked-value="EnabledStatus.DISABLED"
|
||||
:before-change="s => updateStatus(s as number)" />
|
||||
</div>
|
||||
</template>
|
||||
@@ -18,14 +18,20 @@
|
||||
<a-form :model="formModel"
|
||||
ref="formRef"
|
||||
label-align="right"
|
||||
:label-col-props="{ span: 6 }"
|
||||
:wrapper-col-props="{ span: 18 }"
|
||||
:auto-label-width="true"
|
||||
:rules="rules">
|
||||
<!-- 系统类型 -->
|
||||
<a-form-item field="osType"
|
||||
label="系统类型"
|
||||
:hide-asterisk="true">
|
||||
<a-select v-model="formModel.osType"
|
||||
:options="toOptions(sshOsTypeKey)"
|
||||
placeholder="请选择系统类型" />
|
||||
</a-form-item>
|
||||
<!-- 用户名 -->
|
||||
<a-form-item field="username"
|
||||
label="用户名"
|
||||
:rules="usernameRules"
|
||||
label-col-flex="60px"
|
||||
:help="SshAuthType.IDENTITY === formModel.authType ? '将使用主机身份的用户名' : undefined">
|
||||
<a-input v-model="formModel.username"
|
||||
:disabled="SshAuthType.IDENTITY === formModel.authType"
|
||||
@@ -34,8 +40,7 @@
|
||||
<!-- SSH 端口 -->
|
||||
<a-form-item field="port"
|
||||
label="SSH端口"
|
||||
:hide-asterisk="true"
|
||||
label-col-flex="60px">
|
||||
:hide-asterisk="true">
|
||||
<a-input-number v-model="formModel.port"
|
||||
placeholder="请输入SSH端口"
|
||||
hide-button />
|
||||
@@ -43,8 +48,7 @@
|
||||
<!-- 验证方式 -->
|
||||
<a-form-item field="authType"
|
||||
label="验证方式"
|
||||
:hide-asterisk="true"
|
||||
label-col-flex="60px">
|
||||
:hide-asterisk="true">
|
||||
<a-radio-group type="button"
|
||||
class="auth-type-group usn"
|
||||
v-model="formModel.authType"
|
||||
@@ -54,8 +58,7 @@
|
||||
<a-form-item v-if="SshAuthType.PASSWORD === formModel.authType"
|
||||
field="password"
|
||||
label="主机密码"
|
||||
:rules="passwordRules"
|
||||
label-col-flex="60px">
|
||||
:rules="passwordRules">
|
||||
<a-input-password v-model="formModel.password"
|
||||
:disabled="!formModel.useNewPassword && formModel.hasPassword"
|
||||
placeholder="主机密码" />
|
||||
@@ -70,23 +73,20 @@
|
||||
<a-form-item v-if="SshAuthType.KEY === formModel.authType"
|
||||
field="keyId"
|
||||
label="主机秘钥"
|
||||
:hide-asterisk="true"
|
||||
label-col-flex="60px">
|
||||
:hide-asterisk="true">
|
||||
<host-key-selector v-model="formModel.keyId" />
|
||||
</a-form-item>
|
||||
<!-- 主机身份 -->
|
||||
<a-form-item v-if="SshAuthType.IDENTITY === formModel.authType"
|
||||
field="identityId"
|
||||
label="主机身份"
|
||||
:hide-asterisk="true"
|
||||
label-col-flex="60px">
|
||||
:hide-asterisk="true">
|
||||
<host-identity-selector v-model="formModel.identityId" />
|
||||
</a-form-item>
|
||||
<!-- 用户名 -->
|
||||
<a-form-item field="connectTimeout"
|
||||
label="连接超时时间"
|
||||
:hide-asterisk="true"
|
||||
label-col-flex="86px">
|
||||
:hide-asterisk="true">
|
||||
<a-input-number v-model="formModel.connectTimeout"
|
||||
placeholder="请输入连接超时时间"
|
||||
hide-button>
|
||||
@@ -98,22 +98,19 @@
|
||||
<!-- SSH输出编码 -->
|
||||
<a-form-item field="charset"
|
||||
label="SSH输出编码"
|
||||
:hide-asterisk="true"
|
||||
label-col-flex="86px">
|
||||
:hide-asterisk="true">
|
||||
<a-input v-model="formModel.charset" placeholder="请输入 SSH 输出编码" />
|
||||
</a-form-item>
|
||||
<!-- 文件名称编码 -->
|
||||
<a-form-item field="fileNameCharset"
|
||||
label="文件名称编码"
|
||||
:hide-asterisk="true"
|
||||
label-col-flex="86px">
|
||||
:hide-asterisk="true">
|
||||
<a-input v-model="formModel.fileNameCharset" placeholder="请输入 SFTP 文件名称编码" />
|
||||
</a-form-item>
|
||||
<!-- 文件内容编码 -->
|
||||
<a-form-item field="fileContentCharset"
|
||||
label="文件内容编码"
|
||||
:hide-asterisk="true"
|
||||
label-col-flex="86px">
|
||||
:hide-asterisk="true">
|
||||
<a-input v-model="formModel.fileContentCharset" placeholder="请输入 SFTP 文件内容编码" />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
@@ -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<HostSshConfig>({
|
||||
osType: SshOsType.LINUX,
|
||||
username: undefined,
|
||||
port: undefined,
|
||||
password: undefined,
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<a-drawer v-model:visible="visible"
|
||||
class="host-group-drawer"
|
||||
:width="1120"
|
||||
width="70%"
|
||||
title="主机分组配置"
|
||||
:esc-to-close="false"
|
||||
:mask-closable="false"
|
||||
@@ -131,7 +131,7 @@
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
@tree-width: 30%;
|
||||
@tree-width: 33%;
|
||||
|
||||
.host-group-container {
|
||||
width: 100%;
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
:bordered="false">
|
||||
<!-- 配置项 -->
|
||||
<template #keyName="{ record }">
|
||||
<span class="text-copy" @click="copy(record.keyName)">{{ record.keyName }}</span>
|
||||
<span class="text-copy span-blue" @click="copy(record.keyName)">{{ record.keyName }}</span>
|
||||
</template>
|
||||
<!-- 配置值类型 -->
|
||||
<template #valueType="{ record }">
|
||||
|
||||
@@ -7,17 +7,18 @@
|
||||
<a-form :model="formModel"
|
||||
ref="formRef"
|
||||
label-align="left"
|
||||
:auto-label-width="true"
|
||||
@keyup.enter="loadMenuData">
|
||||
<a-row :gutter="32">
|
||||
<!-- 菜单名称 -->
|
||||
<a-col :span="12">
|
||||
<a-form-item field="name" label="菜单名称" label-col-flex="60px">
|
||||
<a-form-item field="name" label="菜单名称">
|
||||
<a-input v-model="formModel.name" placeholder="请输入菜单名称" allow-clear />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<!-- 菜单状态 -->
|
||||
<a-col :span="12">
|
||||
<a-form-item field="status" label="菜单状态" label-col-flex="60px">
|
||||
<a-form-item field="status" label="菜单状态">
|
||||
<a-select v-model="formModel.status"
|
||||
:options="toOptions(menuStatusKey)"
|
||||
placeholder="请选择菜单状态"
|
||||
|
||||
Reference in New Issue
Block a user