diff --git a/agent-go/executor/CommandExecutor.go b/agent-go/executor/CommandExecutor.go
index 1b28c13..66df740 100644
--- a/agent-go/executor/CommandExecutor.go
+++ b/agent-go/executor/CommandExecutor.go
@@ -67,9 +67,9 @@ func Execute(em *ExecutionMessage) ([]string, error) {
resultLog = append(resultLog, "↓↓↓ 命令 Error 如下 ↓↓↓", err.Error())
}
+ // debug
commandResult := fmt.Sprintf("Excution Comand are=> %v, Executor Result: %v", realCommand, resultLog)
-
- log.Info(commandResult)
+ log.Debug(commandResult)
return resultLog, err
}
@@ -119,12 +119,10 @@ func MultiLineCommandExecutor(multiLineCommandExecutor [][]string) ([]string, er
for _, singleLineCommand := range multiLineCommandExecutor {
singleLogs, err := AllOutputCommandExecutor(singleLineCommand)
res = append(res, singleLogs...)
-
if err != nil {
log.Error(fmt.Sprintf("Execution error ! command is %v, error is %v", singleLineCommand, err))
return res, err
}
-
}
return res, nil
diff --git a/agent-go/executor/WindowsFunction.go b/agent-go/executor/WindowsFunction.go
index a8883f6..002d8f0 100644
--- a/agent-go/executor/WindowsFunction.go
+++ b/agent-go/executor/WindowsFunction.go
@@ -9,7 +9,8 @@ import (
)
var (
- user32DLL = syscall.NewLazyDLL("user32.dll")
+ user32DLL = syscall.NewLazyDLL("user32.dll")
+
messageBox = user32DLL.NewProc("MessageBoxW")
)
@@ -24,6 +25,8 @@ func FindPublicIpAddress() {
ip := strings.TrimSpace(string(output))
fmt.Println("公网IP地址:", ip)
+
+ fmt.Println("")
}
func CallAgent() {
@@ -46,4 +49,5 @@ func CallAgent() {
}
fmt.Println("MessageBox returned:", ret)
+
}
diff --git a/agent-go/rabbitmq/OctopusMessage.go b/agent-go/rabbitmq/OctopusMessage.go
index 1a3e3cf..27afdd8 100644
--- a/agent-go/rabbitmq/OctopusMessage.go
+++ b/agent-go/rabbitmq/OctopusMessage.go
@@ -117,8 +117,10 @@ func agentOMHandler(octopusMessage *OctopusMessage) {
func executorOMHandler(octopusMessage *OctopusMessage) {
+ // 转换类型
executionMsgString := octopusMessage.Content.(string)
+ // 解析 ExecutionMessage
var executionMessage *executor.ExecutionMessage
err := json.Unmarshal([]byte(executionMsgString), &executionMessage)
if err != nil {
@@ -126,7 +128,7 @@ func executorOMHandler(octopusMessage *OctopusMessage) {
return
}
- // 交给后端的实际处理器处理, 再次策略
+ // 执行命令
resultLog, err := executor.Execute(executionMessage)
if err == nil {
octopusMessage.ResultCode = "200"
@@ -134,15 +136,15 @@ func executorOMHandler(octopusMessage *OctopusMessage) {
octopusMessage.ResultCode = "300"
}
- // 消息返回逻辑
+ // 返回结果
if executionMessage.NeedResultReplay {
// send back the result log
octopusMessage.Result = resultLog
}
-
+ // 返回时间
octopusMessage.ACTime = utils.ParseDateTimeTime()
- // Send
+ // 返回结果
octopusMessage.SendToOctopusServer()
}
diff --git a/server/pom.xml b/server/pom.xml
index dcdef3c..a45fbbc 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -54,6 +54,13 @@
1.9.4
+
+
+ org.mapstruct
+ mapstruct
+ 1.5.5.Final
+
+
org.springframework.cloud
diff --git a/server/src/main/java/io/wdd/func/script/service/FuncService.java b/server/src/main/java/io/wdd/func/auto/service/FuncService.java
similarity index 88%
rename from server/src/main/java/io/wdd/func/script/service/FuncService.java
rename to server/src/main/java/io/wdd/func/auto/service/FuncService.java
index 38cdf50..1543092 100644
--- a/server/src/main/java/io/wdd/func/script/service/FuncService.java
+++ b/server/src/main/java/io/wdd/func/auto/service/FuncService.java
@@ -1,4 +1,4 @@
-package io.wdd.func.script.service;
+package io.wdd.func.auto.service;
import java.util.List;
@@ -11,5 +11,4 @@ public interface FuncService {
List callAppFuncService(String agentTopicName, String appFunctionName, List funcArgs);
-
}
diff --git a/server/src/main/java/io/wdd/func/script/service/FuncServiceImpl.java b/server/src/main/java/io/wdd/func/auto/service/FuncServiceImpl.java
similarity index 93%
rename from server/src/main/java/io/wdd/func/script/service/FuncServiceImpl.java
rename to server/src/main/java/io/wdd/func/auto/service/FuncServiceImpl.java
index 41297b9..1a3817b 100644
--- a/server/src/main/java/io/wdd/func/script/service/FuncServiceImpl.java
+++ b/server/src/main/java/io/wdd/func/auto/service/FuncServiceImpl.java
@@ -1,4 +1,4 @@
-package io.wdd.func.script.service;
+package io.wdd.func.auto.service;
import io.wdd.rpc.execute.ExecutionMessageType;
import io.wdd.rpc.execute.service.ExecutionService;
@@ -40,9 +40,10 @@ public class FuncServiceImpl implements FuncService {
}
+ // 归一化调用
private List syncCallFunction(String agentTopicName, ExecutionMessageType emType, String funcName, List funcArgs) {
- // 重新构造内容
+ // 重新构造内容,增加Function Name
funcArgs.add(
0,
funcName
@@ -60,7 +61,6 @@ public class FuncServiceImpl implements FuncService {
false
);
-
return resultLog;
}
diff --git a/server/src/main/java/io/wdd/rpc/execute/ExecutionMessage.java b/server/src/main/java/io/wdd/rpc/execute/ExecutionMessage.java
index 03f8a3f..07188ee 100644
--- a/server/src/main/java/io/wdd/rpc/execute/ExecutionMessage.java
+++ b/server/src/main/java/io/wdd/rpc/execute/ExecutionMessage.java
@@ -34,13 +34,14 @@ public class ExecutionMessage {
/**
* 用于区分 ExecutionMessage的类型
- * BASE APP
+ * 执行预定义的脚本内容 BASE
+ * 执行k8s应用相关的内容 APP
*/
@Nullable
private String executionType;
/**
- * 执行功能脚本时需要的参数
+ * 执行 上述预定义脚本 时需要的参数
*/
@Nullable
private List funcContent;
@@ -50,6 +51,7 @@ public class ExecutionMessage {
*/
@Nullable
private List singleLineCommand;
+
/**
* add in 2023-1-17
* 页面定时脚本任务 需要传递完整的命令列表
diff --git a/server/src/main/java/io/wdd/rpc/execute/ExecutionMessageType.java b/server/src/main/java/io/wdd/rpc/execute/ExecutionMessageType.java
index 966166b..848c021 100644
--- a/server/src/main/java/io/wdd/rpc/execute/ExecutionMessageType.java
+++ b/server/src/main/java/io/wdd/rpc/execute/ExecutionMessageType.java
@@ -3,10 +3,10 @@ package io.wdd.rpc.execute;
public enum ExecutionMessageType {
- // 基础类型,执行基础脚本类
+ // 执行预定义的脚本内容 BASE
BASE,
- // 应用类,执行特定功能
+ // 执行k8s应用相关的内容 APP
APP,
diff --git a/server/src/main/java/io/wdd/rpc/execute/service/ExecutionService.java b/server/src/main/java/io/wdd/rpc/execute/service/ExecutionService.java
index d54827b..58e9b46 100644
--- a/server/src/main/java/io/wdd/rpc/execute/service/ExecutionService.java
+++ b/server/src/main/java/io/wdd/rpc/execute/service/ExecutionService.java
@@ -7,7 +7,10 @@ public interface ExecutionService {
/**
- * 发送 指令 给Agent, 正确错误信息全都会被接收
+ * ⭐⭐⭐⭐⭐
+ * 发送命令给Agent, 同步等待处理返回的消息
+ * 超时等待时间为 COMMAND_MAX_WAIT_TIMEOUT
+ * 如果为durationTask那么则没有返回结果
*/
ArrayList SendCommandToAgent(
String agentTopicName,
diff --git a/server/src/main/java/io/wdd/rpc/execute/service/ExecutionServiceImpl.java b/server/src/main/java/io/wdd/rpc/execute/service/ExecutionServiceImpl.java
index 6b084fd..474c331 100644
--- a/server/src/main/java/io/wdd/rpc/execute/service/ExecutionServiceImpl.java
+++ b/server/src/main/java/io/wdd/rpc/execute/service/ExecutionServiceImpl.java
@@ -63,6 +63,7 @@ public class ExecutionServiceImpl implements ExecutionService {
// send the message
oMessageToAgentSender.send(octopusMessage);
+ // debug
log.debug(
"发送的 matchKey为 {}, 内容为 {}",
GenerateOMessageMatchKey(
@@ -75,7 +76,7 @@ public class ExecutionServiceImpl implements ExecutionService {
// 需要返回结果
if (!durationTask) {
// 等待结果
- // countDownLatch的个数约定为1
+ // countDownLatch的个数约定为1, agent会合并多行命令的结果一并返回
OMessageReplayContent replayContent = WaitFromAgent(
octopusMessage,
1
@@ -85,8 +86,15 @@ public class ExecutionServiceImpl implements ExecutionService {
boolean waitOK = false;
try {
+
+ // 2023年10月8日 根据执行的命令数量设定超时等待时间
+ int commandMaxWaitTimeout = COMMAND_MAX_WAIT_TIMEOUT;
+ if (commandListComplete.size() > 0) {
+ commandMaxWaitTimeout = COMMAND_MAX_WAIT_TIMEOUT * commandListComplete.size();
+ }
+
waitOK = replayLatch.await(
- COMMAND_MAX_WAIT_TIMEOUT,
+ commandMaxWaitTimeout,
TimeUnit.SECONDS
);
diff --git a/server/src/main/java/io/wdd/rpc/message/handler/OMessageHandler.java b/server/src/main/java/io/wdd/rpc/message/handler/OMessageHandler.java
index b73c99f..5f0733c 100644
--- a/server/src/main/java/io/wdd/rpc/message/handler/OMessageHandler.java
+++ b/server/src/main/java/io/wdd/rpc/message/handler/OMessageHandler.java
@@ -65,7 +65,7 @@ public class OMessageHandler {
);
//debug
- log.info(
+ log.debug(
"wait from agent map is => {}",
FROM_AGENT_MATCH_TO_AGENT_MAP
);
@@ -141,7 +141,6 @@ public class OMessageHandler {
originOMessage.setResultCode(replayOMessage.getResultCode());
originOMessage.setResult(replayOMessage.getResult());
-
// 通知等待线程
oMessageReplayContent
.getCountDownLatch()
diff --git a/server/src/main/java/io/wdd/rpc/message/handler/OMessageToServerListener.java b/server/src/main/java/io/wdd/rpc/message/handler/OMessageToServerListener.java
index fdaa429..72489fd 100644
--- a/server/src/main/java/io/wdd/rpc/message/handler/OMessageToServerListener.java
+++ b/server/src/main/java/io/wdd/rpc/message/handler/OMessageToServerListener.java
@@ -49,8 +49,6 @@ public class OMessageToServerListener {
@Resource
RedisTemplate redisTemplate;
- @Resource
- OMessageHandler oMessageHandler;
@RabbitHandler
@RabbitListener(queues = "${octopus.message.octopus_to_server}"
@@ -99,5 +97,6 @@ public class OMessageToServerListener {
// 将收到的消息,直接存储到 缓存队列中
log.debug("cache the octopus message to inner cache list !");
OCTOPUS_MESSAGE_FROM_AGENT.offer(octopusMessage);
+
}
}
diff --git a/server/src/main/java/io/wdd/server/beans/mapper/ServerRoleDTOMapper.java b/server/src/main/java/io/wdd/server/beans/mapper/ServerRoleDTOMapper.java
new file mode 100644
index 0000000..3240d1a
--- /dev/null
+++ b/server/src/main/java/io/wdd/server/beans/mapper/ServerRoleDTOMapper.java
@@ -0,0 +1,17 @@
+package io.wdd.server.beans.mapper;
+
+import io.wdd.server.beans.po.ServerRolePO;
+import io.wdd.server.beans.vo.ServerRoleVO;
+import org.mapstruct.Mapper;
+import org.mapstruct.factory.Mappers;
+
+@Mapper
+public interface ServerRoleDTOMapper {
+
+ ServerRoleDTOMapper INSTANCE = Mappers.getMapper(ServerRoleDTOMapper.class);
+
+ ServerRolePO voToPo(ServerRoleVO serverRoleVO);
+
+ ServerRoleVO poToVo(ServerRolePO serverRolePO);
+
+}
diff --git a/server/src/main/java/io/wdd/server/beans/po/ServerInfoPO.java b/server/src/main/java/io/wdd/server/beans/po/ServerInfoPO.java
index 9ad670e..3514f09 100644
--- a/server/src/main/java/io/wdd/server/beans/po/ServerInfoPO.java
+++ b/server/src/main/java/io/wdd/server/beans/po/ServerInfoPO.java
@@ -1,7 +1,9 @@
package io.wdd.server.beans.po;
-import com.baomidou.mybatisplus.annotation.*;
-import com.fasterxml.jackson.annotation.JsonFormat;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
@@ -11,269 +13,180 @@ import java.time.LocalDateTime;
*
* @TableName server_info
*/
-@TableName(value ="server_info")
+@TableName(value = "server_info")
@Data
public class ServerInfoPO implements Serializable {
/**
* server primary key
*/
- @TableId(type = IdType.AUTO)
+ @TableId(value = "server_id", type = IdType.AUTO)
private Long serverId;
+ /**
+ * 建议合并至 provider
+ */
+ @TableField(value = "tenant_name")
+ private String tenantName;
+
+ /**
+ * octopus message unique key name
+ */
+ @TableField(value = "topic_name")
+ private String topicName;
+
/**
* server host name
*/
+ @TableField(value = "server_name")
private String serverName;
/**
* server public ipv4
*/
+ @TableField(value = "server_ip_pb_v4")
private String serverIpPbV4;
/**
* server inner ipv4
*/
+ @TableField(value = "server_ip_in_v4")
private String serverIpInV4;
/**
* server public ipv6
*/
+ @TableField(value = "server_ip_pb_v6")
private String serverIpPbV6;
/**
* server inner ipv6
-
*/
+ @TableField(value = "server_ip_in_v6")
private String serverIpInV6;
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ /**
+ * server register time
+ */
+ @TableField(value = "register_time")
private LocalDateTime registerTime;
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ /**
+ * expire time
+ */
+ @TableField(value = "expire_time")
private LocalDateTime expireTime;
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
- @TableField(fill = FieldFill.INSERT)
- private LocalDateTime createTime;
-
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
- @TableField(fill = FieldFill.INSERT_UPDATE)
+ /**
+ *
+ */
+ @TableField(value = "update_time")
private LocalDateTime updateTime;
/**
- * 服务器节点的代理类型,0代表INTERFACE, 1代表relay,2代表external
+ *
*/
- private Integer proxyType;
+ @TableField(value = "create_time")
+ private LocalDateTime createTime;
/**
* server location , type City Country
*/
+ @TableField(value = "location")
private String location;
/**
* server isp manager
*/
+ @TableField(value = "provider")
private String provider;
- /**
- * split by ,
- */
- private String managePort;
-
/**
*
*/
+ @TableField(value = "cpu_brand")
private String cpuBrand;
/**
*
*/
+ @TableField(value = "cpu_core")
private String cpuCore;
/**
*
*/
+ @TableField(value = "memory_total")
private String memoryTotal;
/**
*
*/
+ @TableField(value = "disk_total")
private String diskTotal;
/**
*
*/
+ @TableField(value = "disk_usage")
private String diskUsage;
/**
*
*/
+ @TableField(value = "io_speed")
private String ioSpeed;
/**
*
*/
+ @TableField(value = "tcp_control")
private String tcpControl;
/**
* server virtualization method
*/
+ @TableField(value = "virtualization")
private String virtualization;
/**
*
*/
+ @TableField(value = "os_info")
private String osInfo;
/**
*
*/
+ @TableField(value = "os_kernel_info")
private String osKernelInfo;
/**
* machine uuid from /etc/machineid
*/
+ @TableField(value = "machine_id")
private String machineId;
- /**
- * octopus message unique key name
- */
- private String topicName;
-
/**
*
*/
+ @TableField(value = "comment")
private String comment;
/**
* 0 alive || 1 deleted
*/
+ @TableField(value = "is_delete")
private Integer isDelete;
/**
* optimistic lock for concurrent
*/
+ @TableField(value = "version")
private Integer version;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
-
- @Override
- public boolean equals(Object that) {
- if (this == that) {
- return true;
- }
- if (that == null) {
- return false;
- }
- if (getClass() != that.getClass()) {
- return false;
- }
- ServerInfoPO other = (ServerInfoPO) that;
- return (this.getServerId() == null ? other.getServerId() == null : this.getServerId().equals(other.getServerId()))
- && (this.getServerName() == null ? other.getServerName() == null : this.getServerName().equals(other.getServerName()))
- && (this.getServerIpPbV4() == null ? other.getServerIpPbV4() == null : this.getServerIpPbV4().equals(other.getServerIpPbV4()))
- && (this.getServerIpInV4() == null ? other.getServerIpInV4() == null : this.getServerIpInV4().equals(other.getServerIpInV4()))
- && (this.getServerIpPbV6() == null ? other.getServerIpPbV6() == null : this.getServerIpPbV6().equals(other.getServerIpPbV6()))
- && (this.getServerIpInV6() == null ? other.getServerIpInV6() == null : this.getServerIpInV6().equals(other.getServerIpInV6()))
- && (this.getRegisterTime() == null ? other.getRegisterTime() == null : this.getRegisterTime().equals(other.getRegisterTime()))
- && (this.getExpireTime() == null ? other.getExpireTime() == null : this.getExpireTime().equals(other.getExpireTime()))
- && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
- && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
- && (this.getLocation() == null ? other.getLocation() == null : this.getLocation().equals(other.getLocation()))
- && (this.getProvider() == null ? other.getProvider() == null : this.getProvider().equals(other.getProvider()))
- && (this.getManagePort() == null ? other.getManagePort() == null : this.getManagePort().equals(other.getManagePort()))
- && (this.getCpuBrand() == null ? other.getCpuBrand() == null : this.getCpuBrand().equals(other.getCpuBrand()))
- && (this.getCpuCore() == null ? other.getCpuCore() == null : this.getCpuCore().equals(other.getCpuCore()))
- && (this.getMemoryTotal() == null ? other.getMemoryTotal() == null : this.getMemoryTotal().equals(other.getMemoryTotal()))
- && (this.getDiskTotal() == null ? other.getDiskTotal() == null : this.getDiskTotal().equals(other.getDiskTotal()))
- && (this.getDiskUsage() == null ? other.getDiskUsage() == null : this.getDiskUsage().equals(other.getDiskUsage()))
- && (this.getIoSpeed() == null ? other.getIoSpeed() == null : this.getIoSpeed().equals(other.getIoSpeed()))
- && (this.getTcpControl() == null ? other.getTcpControl() == null : this.getTcpControl().equals(other.getTcpControl()))
- && (this.getVirtualization() == null ? other.getVirtualization() == null : this.getVirtualization().equals(other.getVirtualization()))
- && (this.getOsInfo() == null ? other.getOsInfo() == null : this.getOsInfo().equals(other.getOsInfo()))
- && (this.getOsKernelInfo() == null ? other.getOsKernelInfo() == null : this.getOsKernelInfo().equals(other.getOsKernelInfo()))
- && (this.getMachineId() == null ? other.getMachineId() == null : this.getMachineId().equals(other.getMachineId()))
- && (this.getTopicName() == null ? other.getTopicName() == null : this.getTopicName().equals(other.getTopicName()))
- && (this.getComment() == null ? other.getComment() == null : this.getComment().equals(other.getComment()))
- && (this.getIsDelete() == null ? other.getIsDelete() == null : this.getIsDelete().equals(other.getIsDelete()))
- && (this.getVersion() == null ? other.getVersion() == null : this.getVersion().equals(other.getVersion()));
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((getServerId() == null) ? 0 : getServerId().hashCode());
- result = prime * result + ((getServerName() == null) ? 0 : getServerName().hashCode());
- result = prime * result + ((getServerIpPbV4() == null) ? 0 : getServerIpPbV4().hashCode());
- result = prime * result + ((getServerIpInV4() == null) ? 0 : getServerIpInV4().hashCode());
- result = prime * result + ((getServerIpPbV6() == null) ? 0 : getServerIpPbV6().hashCode());
- result = prime * result + ((getServerIpInV6() == null) ? 0 : getServerIpInV6().hashCode());
- result = prime * result + ((getRegisterTime() == null) ? 0 : getRegisterTime().hashCode());
- result = prime * result + ((getExpireTime() == null) ? 0 : getExpireTime().hashCode());
- result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
- result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
- result = prime * result + ((getLocation() == null) ? 0 : getLocation().hashCode());
- result = prime * result + ((getProvider() == null) ? 0 : getProvider().hashCode());
- result = prime * result + ((getManagePort() == null) ? 0 : getManagePort().hashCode());
- result = prime * result + ((getCpuBrand() == null) ? 0 : getCpuBrand().hashCode());
- result = prime * result + ((getCpuCore() == null) ? 0 : getCpuCore().hashCode());
- result = prime * result + ((getMemoryTotal() == null) ? 0 : getMemoryTotal().hashCode());
- result = prime * result + ((getDiskTotal() == null) ? 0 : getDiskTotal().hashCode());
- result = prime * result + ((getDiskUsage() == null) ? 0 : getDiskUsage().hashCode());
- result = prime * result + ((getIoSpeed() == null) ? 0 : getIoSpeed().hashCode());
- result = prime * result + ((getTcpControl() == null) ? 0 : getTcpControl().hashCode());
- result = prime * result + ((getVirtualization() == null) ? 0 : getVirtualization().hashCode());
- result = prime * result + ((getOsInfo() == null) ? 0 : getOsInfo().hashCode());
- result = prime * result + ((getOsKernelInfo() == null) ? 0 : getOsKernelInfo().hashCode());
- result = prime * result + ((getMachineId() == null) ? 0 : getMachineId().hashCode());
- result = prime * result + ((getTopicName() == null) ? 0 : getTopicName().hashCode());
- result = prime * result + ((getComment() == null) ? 0 : getComment().hashCode());
- result = prime * result + ((getIsDelete() == null) ? 0 : getIsDelete().hashCode());
- result = prime * result + ((getVersion() == null) ? 0 : getVersion().hashCode());
- return result;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append(getClass().getSimpleName());
- sb.append(" [");
- sb.append("Hash = ").append(hashCode());
- sb.append(", serverId=").append(serverId);
- sb.append(", serverName=").append(serverName);
- sb.append(", serverIpPbV4=").append(serverIpPbV4);
- sb.append(", serverIpInV4=").append(serverIpInV4);
- sb.append(", serverIpPbV6=").append(serverIpPbV6);
- sb.append(", serverIpInV6=").append(serverIpInV6);
- sb.append(", registerTime=").append(registerTime);
- sb.append(", expireTime=").append(expireTime);
- sb.append(", updateTime=").append(updateTime);
- sb.append(", createTime=").append(createTime);
- sb.append(", location=").append(location);
- sb.append(", provider=").append(provider);
- sb.append(", managePort=").append(managePort);
- sb.append(", cpuBrand=").append(cpuBrand);
- sb.append(", cpuCore=").append(cpuCore);
- sb.append(", memoryTotal=").append(memoryTotal);
- sb.append(", diskTotal=").append(diskTotal);
- sb.append(", diskUsage=").append(diskUsage);
- sb.append(", ioSpeed=").append(ioSpeed);
- sb.append(", tcpControl=").append(tcpControl);
- sb.append(", virtualization=").append(virtualization);
- sb.append(", osInfo=").append(osInfo);
- sb.append(", osKernelInfo=").append(osKernelInfo);
- sb.append(", machineId=").append(machineId);
- sb.append(", topicName=").append(topicName);
- sb.append(", comment=").append(comment);
- sb.append(", isDelete=").append(isDelete);
- sb.append(", version=").append(version);
- sb.append(", serialVersionUID=").append(serialVersionUID);
- sb.append("]");
- return sb.toString();
- }
}
\ No newline at end of file
diff --git a/server/src/main/java/io/wdd/server/beans/po/ServerRolePO.java b/server/src/main/java/io/wdd/server/beans/po/ServerRolePO.java
new file mode 100644
index 0000000..6dd6300
--- /dev/null
+++ b/server/src/main/java/io/wdd/server/beans/po/ServerRolePO.java
@@ -0,0 +1,33 @@
+package io.wdd.server.beans.po;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @TableName server_role
+ */
+@TableName(value = "server_role")
+@Data
+public class ServerRolePO implements Serializable {
+ @TableField(exist = false)
+ private static final long serialVersionUID = 1L;
+ /**
+ *
+ */
+ @TableId(value = "role_id")
+ private Long roleId;
+ /**
+ * 服务器角色名称
+ */
+ @TableField(value = "role_name")
+ private String roleName;
+ /**
+ * 服务器角色对应的序号
+ */
+ @TableField(value = "role_num")
+ private Integer roleNum;
+}
\ No newline at end of file
diff --git a/server/src/main/java/io/wdd/server/beans/vo/ServerRoleVO.java b/server/src/main/java/io/wdd/server/beans/vo/ServerRoleVO.java
new file mode 100644
index 0000000..417a891
--- /dev/null
+++ b/server/src/main/java/io/wdd/server/beans/vo/ServerRoleVO.java
@@ -0,0 +1,20 @@
+package io.wdd.server.beans.vo;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import lombok.Data;
+
+@Data
+public class ServerRoleVO {
+ /**
+ * 服务器角色名称
+ */
+ @TableField(value = "role_name")
+ private String roleName;
+
+ /**
+ * 服务器角色对应的序号
+ */
+ @TableField(value = "role_num")
+ private Integer roleNum;
+
+}
\ No newline at end of file
diff --git a/server/src/main/java/io/wdd/server/controller/RoleController.java b/server/src/main/java/io/wdd/server/controller/RoleController.java
new file mode 100644
index 0000000..6d55666
--- /dev/null
+++ b/server/src/main/java/io/wdd/server/controller/RoleController.java
@@ -0,0 +1,70 @@
+package io.wdd.server.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.wdd.common.response.R;
+import io.wdd.server.beans.po.ServerRolePO;
+import io.wdd.server.beans.vo.ServerRoleVO;
+import io.wdd.server.coreService.CoreRoleService;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@RestController
+@Api("Octopus Server - 服务器角色信息")
+@RequestMapping("/role")
+public class RoleController {
+
+ @Resource
+ CoreRoleService roleService;
+
+ @GetMapping("/all")
+ @ApiOperation("角色-获取全部角色信息")
+ public R> roleGetAll(
+ ) {
+ return R.ok(roleService.roleGetAll());
+ }
+
+ @PostMapping("/create")
+ @ApiOperation("角色-创建一个角色")
+ public R roleCreate(
+ @RequestBody ServerRoleVO serverRoleVO
+ ) {
+
+ String result = "创建角色成功!";
+ if (!roleService.roleCreate(serverRoleVO)) {
+ result = "创建角色失败!";
+ }
+ return R.ok(result);
+ }
+
+ @PostMapping("/update")
+ @ApiOperation("角色-更新一个角色")
+ public R roleUpdate(
+ @RequestBody ServerRolePO serverRolePO
+ ) {
+
+ String result = "更新角色成功!";
+ if (!roleService.roleUpdate(serverRolePO)) {
+ result = "更新角色失败!";
+ }
+ return R.ok(result);
+ }
+
+ @PostMapping("/delete")
+ @ApiOperation("角色-删除一个角色")
+ public R roleDelete(
+ @RequestParam(value = "roleId", name = "角色的Id") @ApiParam(value = "角色的Id") Long roleId
+ ) {
+
+ String result = "删除角色成功!";
+ if (!roleService.roleDelete(roleId)) {
+ result = "删除角色失败!";
+ }
+ return R.ok(result);
+ }
+
+
+}
diff --git a/server/src/main/java/io/wdd/server/coreService/CoreRoleService.java b/server/src/main/java/io/wdd/server/coreService/CoreRoleService.java
new file mode 100644
index 0000000..d905f2c
--- /dev/null
+++ b/server/src/main/java/io/wdd/server/coreService/CoreRoleService.java
@@ -0,0 +1,19 @@
+package io.wdd.server.coreService;
+
+import io.wdd.server.beans.po.ServerRolePO;
+import io.wdd.server.beans.vo.ServerRoleVO;
+
+import java.util.List;
+
+public interface CoreRoleService {
+
+ // 获取所有的角色
+ List roleGetAll();
+
+ boolean roleCreate(ServerRoleVO serverRoleVO);
+
+ boolean roleUpdate(ServerRolePO serverRolePO);
+
+ boolean roleDelete(Long roleId);
+
+}
diff --git a/server/src/main/java/io/wdd/server/coreService/CoreServerService.java b/server/src/main/java/io/wdd/server/coreService/CoreServerService.java
index f4d9ec1..5a2512b 100644
--- a/server/src/main/java/io/wdd/server/coreService/CoreServerService.java
+++ b/server/src/main/java/io/wdd/server/coreService/CoreServerService.java
@@ -31,22 +31,22 @@ public interface CoreServerService {
boolean serverDelete(Long serverId, String serverName);
+ /* app deprecated 2023年10月8日 */
List appGetAll(Long serverId);
AppInfoVO appCreate(Long serverId, AppInfoVO appInfoVO);
boolean appDelete(Long serverId, Long appId);
+ /* domain deprecated 2023年10月8日 */
List domainGetAll(Long serverId);
List domainGetSingle(Long serverId, String domainName, String dnsIP);
-
boolean domainCreate(Long serverId, DomainInfoVO domainInfoVO);
boolean domainUpdate(DomainInfoPO domainInfoPO);
-
boolean domainDelete(Long serverId, Long domainId);
}
diff --git a/server/src/main/java/io/wdd/server/coreService/impl/CoreRoleServiceImpl.java b/server/src/main/java/io/wdd/server/coreService/impl/CoreRoleServiceImpl.java
new file mode 100644
index 0000000..d23ad26
--- /dev/null
+++ b/server/src/main/java/io/wdd/server/coreService/impl/CoreRoleServiceImpl.java
@@ -0,0 +1,45 @@
+package io.wdd.server.coreService.impl;
+
+import io.wdd.server.beans.mapper.ServerRoleDTOMapper;
+import io.wdd.server.beans.po.ServerRolePO;
+import io.wdd.server.beans.vo.ServerRoleVO;
+import io.wdd.server.coreService.CoreRoleService;
+import io.wdd.server.service.ServerRoleService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@Service
+@Slf4j
+public class CoreRoleServiceImpl implements CoreRoleService {
+
+ @Resource
+ ServerRoleService serverRoleService;
+
+ @Resource
+ ServerRoleDTOMapper serverRoleDTOMapper;
+
+ @Override
+ public List roleGetAll() {
+ return serverRoleService.list();
+ }
+
+ @Override
+ public boolean roleCreate(ServerRoleVO serverRoleVO) {
+
+ ServerRolePO serverRolePO = serverRoleDTOMapper.voToPo(serverRoleVO);
+ return serverRoleService.save(serverRolePO);
+ }
+
+ @Override
+ public boolean roleUpdate(ServerRolePO serverRolePO) {
+ return serverRoleService.saveOrUpdate(serverRolePO);
+ }
+
+ @Override
+ public boolean roleDelete(Long roleId) {
+ return serverRoleService.removeById(roleId);
+ }
+}
diff --git a/server/src/main/java/io/wdd/server/mapper/ServerInfoMapper.java b/server/src/main/java/io/wdd/server/mapper/ServerInfoMapper.java
index 3166159..f06c67f 100644
--- a/server/src/main/java/io/wdd/server/mapper/ServerInfoMapper.java
+++ b/server/src/main/java/io/wdd/server/mapper/ServerInfoMapper.java
@@ -1,14 +1,14 @@
package io.wdd.server.mapper;
-import io.wdd.server.beans.po.ServerInfoPO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import io.wdd.server.beans.po.ServerInfoPO;
/**
-* @author wdd
-* @description 针对表【server_info】的数据库操作Mapper
-* @createDate 2022-11-30 13:54:40
-* @Entity io.wdd.server.beans.po.ServerInfoPO
-*/
+ * @author wdd
+ * @description 针对表【server_info】的数据库操作Mapper
+ * @createDate 2023-10-08 11:24:01
+ * @Entity io.wdd.server.beans.po.ServerInfoPO
+ */
public interface ServerInfoMapper extends BaseMapper {
}
diff --git a/server/src/main/java/io/wdd/server/mapper/ServerRoleMapper.java b/server/src/main/java/io/wdd/server/mapper/ServerRoleMapper.java
new file mode 100644
index 0000000..a74ba51
--- /dev/null
+++ b/server/src/main/java/io/wdd/server/mapper/ServerRoleMapper.java
@@ -0,0 +1,18 @@
+package io.wdd.server.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import io.wdd.server.beans.po.ServerRolePO;
+
+/**
+ * @author wdd
+ * @description 针对表【server_role】的数据库操作Mapper
+ * @createDate 2023-10-08 11:33:51
+ * @Entity io.wdd.server.beans.po.ServerRolePO
+ */
+public interface ServerRoleMapper extends BaseMapper {
+
+}
+
+
+
+
diff --git a/server/src/main/java/io/wdd/server/service/ServerInfoService.java b/server/src/main/java/io/wdd/server/service/ServerInfoService.java
index 676f755..7c5eb79 100644
--- a/server/src/main/java/io/wdd/server/service/ServerInfoService.java
+++ b/server/src/main/java/io/wdd/server/service/ServerInfoService.java
@@ -1,13 +1,13 @@
package io.wdd.server.service;
-import io.wdd.server.beans.po.ServerInfoPO;
import com.baomidou.mybatisplus.extension.service.IService;
+import io.wdd.server.beans.po.ServerInfoPO;
/**
-* @author wdd
-* @description 针对表【server_info】的数据库操作Service
-* @createDate 2022-11-30 13:54:40
-*/
+ * @author wdd
+ * @description 针对表【server_info】的数据库操作Service
+ * @createDate 2023-10-08 11:24:01
+ */
public interface ServerInfoService extends IService {
}
diff --git a/server/src/main/java/io/wdd/server/service/ServerRoleService.java b/server/src/main/java/io/wdd/server/service/ServerRoleService.java
new file mode 100644
index 0000000..a318536
--- /dev/null
+++ b/server/src/main/java/io/wdd/server/service/ServerRoleService.java
@@ -0,0 +1,13 @@
+package io.wdd.server.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import io.wdd.server.beans.po.ServerRolePO;
+
+/**
+ * @author wdd
+ * @description 针对表【server_role】的数据库操作Service
+ * @createDate 2023-10-08 11:33:51
+ */
+public interface ServerRoleService extends IService {
+
+}
diff --git a/server/src/main/java/io/wdd/server/service/impl/ServerInfoServiceImpl.java b/server/src/main/java/io/wdd/server/service/impl/ServerInfoServiceImpl.java
index 594a695..59b53a4 100644
--- a/server/src/main/java/io/wdd/server/service/impl/ServerInfoServiceImpl.java
+++ b/server/src/main/java/io/wdd/server/service/impl/ServerInfoServiceImpl.java
@@ -2,15 +2,15 @@ package io.wdd.server.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.wdd.server.beans.po.ServerInfoPO;
-import io.wdd.server.service.ServerInfoService;
import io.wdd.server.mapper.ServerInfoMapper;
+import io.wdd.server.service.ServerInfoService;
import org.springframework.stereotype.Service;
/**
-* @author wdd
-* @description 针对表【server_info】的数据库操作Service实现
-* @createDate 2022-11-30 13:54:40
-*/
+ * @author wdd
+ * @description 针对表【server_info】的数据库操作Service实现
+ * @createDate 2023-10-08 11:24:01
+ */
@Service
public class ServerInfoServiceImpl extends ServiceImpl
implements ServerInfoService{
diff --git a/server/src/main/java/io/wdd/server/service/impl/ServerRoleServiceImpl.java b/server/src/main/java/io/wdd/server/service/impl/ServerRoleServiceImpl.java
new file mode 100644
index 0000000..26b0359
--- /dev/null
+++ b/server/src/main/java/io/wdd/server/service/impl/ServerRoleServiceImpl.java
@@ -0,0 +1,22 @@
+package io.wdd.server.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import io.wdd.server.beans.po.ServerRolePO;
+import io.wdd.server.mapper.ServerRoleMapper;
+import io.wdd.server.service.ServerRoleService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author wdd
+ * @description 针对表【server_role】的数据库操作Service实现
+ * @createDate 2023-10-08 11:33:51
+ */
+@Service
+public class ServerRoleServiceImpl extends ServiceImpl
+ implements ServerRoleService {
+
+}
+
+
+
+
diff --git a/server/src/main/resources/mapper/ServerInfoMapper.xml b/server/src/main/resources/mapper/ServerInfoMapper.xml
index 751ea6d..10f04b6 100644
--- a/server/src/main/resources/mapper/ServerInfoMapper.xml
+++ b/server/src/main/resources/mapper/ServerInfoMapper.xml
@@ -5,19 +5,20 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
@@ -29,22 +30,22 @@
-
- server_id,server_name,server_ip_pb_v4,
- server_ip_in_v4,server_ip_pb_v6,server_ip_in_v6,
- register_time,expire_time,update_time,
- create_time,location,provider,
- manage_port,cpu_brand,cpu_core,
- memory_total,disk_total,disk_usage,
- io_speed,tcp_control,virtualization,
- os_info,os_kernel_info,machine_id,
- topic_name,comment,is_delete,
+ server_id
+ ,tenant_name,topic_name,
+ server_name,server_ip_pb_v4,server_ip_in_v4,
+ server_ip_pb_v6,server_ip_in_v6,register_time,
+ expire_time,update_time,create_time,
+ location,provider,cpu_brand,
+ cpu_core,memory_total,disk_total,
+ disk_usage,io_speed,tcp_control,
+ virtualization,os_info,os_kernel_info,
+ machine_id,comment,is_delete,
version
diff --git a/server/src/main/resources/mapper/ServerRoleMapper.xml b/server/src/main/resources/mapper/ServerRoleMapper.xml
new file mode 100644
index 0000000..61f3285
--- /dev/null
+++ b/server/src/main/resources/mapper/ServerRoleMapper.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+ role_id
+ ,role_name,role_num
+
+
diff --git a/source/src/main/java/io/wdd/source/shell/agent-bootup.sh b/source/src/main/java/io/wdd/source/shell/agent-bootup.sh
index e302c6c..d2dcfba 100644
--- a/source/src/main/java/io/wdd/source/shell/agent-bootup.sh
+++ b/source/src/main/java/io/wdd/source/shell/agent-bootup.sh
@@ -2,9 +2,7 @@
##### environment variables ######
-JAVA_OPTS="-Xms128m -Xmx512m -Ddebug=false -Dfile.encoding=utf-8 --spring.profiles.active=k3s --spring.cloud.nacos.config.group=k3s --spring.cloud.nacos.config.server-addr=150.230.198.103:21060 --spring.cloud.nacos.config.extension-configs[0].dataId=common-k3s.yaml --spring.cloud.nacos.config.extension-configs[0].group=k3s"
-
-DependLibFiles=(
+JAVA_OPTS="-Xms128m -Xmx512m -Ddebug=false -Dfile.encoding=utf-8 --spring.profiles.active=k3s --spring.cloud.nacos.config.group=k3s --spring.cloud.nacos.config.server-addr=150.230.198.103:21060 --spring.cloud.nacos.config.extension-configs[0].dataId=common-k3s.yaml --spring.cloud.nacos.config.extension-configs[0].group=k3s"DependLibFiles=(
wdd-lib-file.sh
wdd-lib-log.sh
wdd-lib-env.sh