[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
|
||||
for _, singleLineCommand := range multiLineCommand {
|
||||
result = append(result, ReadTimeCommandExecutor(singleLineCommand)...)
|
||||
}
|
||||
|
||||
// debug usage
|
||||
//log.DebugF("exec result are => %v", result)
|
||||
for _, logLine := range result {
|
||||
fmt.Println(logLine)
|
||||
// debug usage
|
||||
log.DebugF("exec result are => %v", result)
|
||||
for _, logLine := range result {
|
||||
fmt.Println(logLine)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 归一化处理
|
||||
|
||||
@@ -47,8 +47,8 @@ func TestBaseFunc(t *testing.T) {
|
||||
//agentOP.Exec("modifyHostname")
|
||||
//agentOP.Exec("disableSwap")
|
||||
//agentOP.Exec("enableSwap")
|
||||
agentOP.Exec("removeDocker")
|
||||
//agentOP.Exec("installDocker", "20")
|
||||
//agentOP.Exec("removeDocker")
|
||||
agentOP.Exec("installDocker", "20")
|
||||
//agentOP.Exec("removeDockerCompose")
|
||||
//agentOP.Exec("installDockerCompose")
|
||||
//agentOP.Exec("installHelm")
|
||||
|
||||
@@ -22,6 +22,8 @@ type OctopusMsgHandler interface {
|
||||
|
||||
type OctopusMsgSender interface {
|
||||
Send(rabbitQueue *RabbitQueue, msg []byte)
|
||||
|
||||
SendToOctopusServer()
|
||||
}
|
||||
|
||||
type OctopusMsgBuilder interface {
|
||||
@@ -47,6 +49,20 @@ func (om *OctopusMessage) Send(rabbitQueue *RabbitQueue, msg []byte) {
|
||||
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 {
|
||||
|
||||
// 当前时间
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user