mml
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"fmt"
|
||||
"math"
|
||||
"net/http"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -425,6 +426,32 @@ func InstallLicense(mml *MmlCommand, omcMmlVar *MmlVar, outputJson *dborm.MmlOut
|
||||
return &output
|
||||
}
|
||||
|
||||
func RunShellCommand(mml *MmlCommand, omcMmlVar *MmlVar, outputJson *dborm.MmlOutput) *[]byte {
|
||||
var output []byte
|
||||
log.Debug("mml:", mml)
|
||||
var command string
|
||||
for _, Param := range mml.Params {
|
||||
switch Param.Name {
|
||||
case "netype":
|
||||
command = Param.Value
|
||||
default:
|
||||
}
|
||||
}
|
||||
cmd := exec.Command("/bin/bash", "-c", command)
|
||||
out, err := cmd.CombinedOutput()
|
||||
log.Tracef("Exec output: %v", string(out))
|
||||
if err != nil {
|
||||
log.Error("exe cmd error: ", err)
|
||||
output = *ParseErrorOutput(err)
|
||||
return &output
|
||||
} else {
|
||||
str := fmt.Sprintf("Run shell command: %s output:\n\n%v", command, string(out))
|
||||
output = []byte(str)
|
||||
}
|
||||
|
||||
return &output
|
||||
}
|
||||
|
||||
func TransMml2HttpReq(omcMmlVar *MmlVar, mml *MmlCommand) (*[]byte, error) {
|
||||
log.Info("TransMml2HttpReq processing ...")
|
||||
log.Debug("mml: ", mml)
|
||||
@@ -510,6 +537,9 @@ func TransMml2HttpReq(omcMmlVar *MmlVar, mml *MmlCommand) (*[]byte, error) {
|
||||
case "InstallLicense":
|
||||
output = InstallLicense(mml, omcMmlVar, outputJson)
|
||||
return output, nil
|
||||
case "RunShellCommand":
|
||||
output = RunShellCommand(mml, omcMmlVar, outputJson)
|
||||
return output, nil
|
||||
default:
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user