[Excution] - base function accomplish - 4
This commit is contained in:
@@ -96,12 +96,13 @@ func (op *AgentOsOperator) Exec(baseFuncName string, funcArgs ...string) []strin
|
|||||||
// exec the command here
|
// exec the command here
|
||||||
for _, singleLineCommand := range multiLineCommand {
|
for _, singleLineCommand := range multiLineCommand {
|
||||||
result = append(result, ReadTimeCommandExecutor(singleLineCommand)...)
|
result = append(result, ReadTimeCommandExecutor(singleLineCommand)...)
|
||||||
}
|
|
||||||
|
|
||||||
// debug usage
|
// debug usage
|
||||||
//log.DebugF("exec result are => %v", result)
|
log.DebugF("exec result are => %v", result)
|
||||||
for _, logLine := range result {
|
for _, logLine := range result {
|
||||||
fmt.Println(logLine)
|
fmt.Println(logLine)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 归一化处理
|
// 归一化处理
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ func TestBaseFunc(t *testing.T) {
|
|||||||
//agentOP.Exec("modifyHostname")
|
//agentOP.Exec("modifyHostname")
|
||||||
//agentOP.Exec("disableSwap")
|
//agentOP.Exec("disableSwap")
|
||||||
//agentOP.Exec("enableSwap")
|
//agentOP.Exec("enableSwap")
|
||||||
agentOP.Exec("removeDocker")
|
//agentOP.Exec("removeDocker")
|
||||||
//agentOP.Exec("installDocker", "20")
|
agentOP.Exec("installDocker", "20")
|
||||||
//agentOP.Exec("removeDockerCompose")
|
//agentOP.Exec("removeDockerCompose")
|
||||||
//agentOP.Exec("installDockerCompose")
|
//agentOP.Exec("installDockerCompose")
|
||||||
//agentOP.Exec("installHelm")
|
//agentOP.Exec("installHelm")
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ type OctopusMsgHandler interface {
|
|||||||
|
|
||||||
type OctopusMsgSender interface {
|
type OctopusMsgSender interface {
|
||||||
Send(rabbitQueue *RabbitQueue, msg []byte)
|
Send(rabbitQueue *RabbitQueue, msg []byte)
|
||||||
|
|
||||||
|
SendToOctopusServer()
|
||||||
}
|
}
|
||||||
|
|
||||||
type OctopusMsgBuilder interface {
|
type OctopusMsgBuilder interface {
|
||||||
@@ -47,6 +49,20 @@ func (om *OctopusMessage) Send(rabbitQueue *RabbitQueue, msg []byte) {
|
|||||||
rabbitQueue.Send(msg)
|
rabbitQueue.Send(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SendToOctopusServer send octopus message back to octopusToServer queue
|
||||||
|
func (om *OctopusMessage) SendToOctopusServer() {
|
||||||
|
|
||||||
|
// write the octopus message to bytes
|
||||||
|
octopusMessageReplayBytes, err := json.Marshal(om)
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorF("replay octopus message write error => %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send back the result to queue
|
||||||
|
OctopusToServerQueue.Send(octopusMessageReplayBytes)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func (om *OctopusMessage) Build(omType string, content interface{}) *OctopusMessage {
|
func (om *OctopusMessage) Build(omType string, content interface{}) *OctopusMessage {
|
||||||
|
|
||||||
// 当前时间
|
// 当前时间
|
||||||
@@ -111,7 +127,19 @@ func executorOMHandler(octopusMessage *OctopusMessage) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 交给后端的实际处理器处理, 再次策略
|
// 交给后端的实际处理器处理, 再次策略
|
||||||
executor.Execute(executionMessage)
|
resultLog, err := executor.Execute(executionMessage)
|
||||||
|
if err != nil {
|
||||||
|
octopusMessage.ResultCode = "200"
|
||||||
|
} else {
|
||||||
|
octopusMessage.ResultCode = "300"
|
||||||
|
}
|
||||||
|
|
||||||
|
// send back the result log
|
||||||
|
octopusMessage.Result = resultLog
|
||||||
|
octopusMessage.ACTime = utils.ParseISOLocalDateTime()
|
||||||
|
|
||||||
|
// Send
|
||||||
|
octopusMessage.SendToOctopusServer()
|
||||||
}
|
}
|
||||||
|
|
||||||
func statusOMHandler(octopusMessage *OctopusMessage) {
|
func statusOMHandler(octopusMessage *OctopusMessage) {
|
||||||
|
|||||||
Reference in New Issue
Block a user