use go-cmd/cmd
This commit is contained in:
parent
4a9c0c7e6a
commit
ee8a0897e1
25
http.go
25
http.go
|
@ -12,8 +12,8 @@ import (
|
|||
|
||||
"go.wit.com/lib/gui/shell"
|
||||
pb "go.wit.com/lib/protobuf/virtbuf"
|
||||
"go.wit.com/log"
|
||||
"go.wit.com/lib/virtigolib"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
// remove '?' part and trailing '/'
|
||||
|
@ -173,15 +173,15 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
|||
log.Warn("cmd :", cmd)
|
||||
fmt.Fprintln(w, "Handling start droplet", cmd)
|
||||
|
||||
err, ok, output := shell.RunCmd("/home/", cmd)
|
||||
shell.Run(cmd)
|
||||
if ok {
|
||||
r := shell.PathRun("/home/", cmd)
|
||||
output := strings.Join(r.Stdout, "\n")
|
||||
if r.Error == nil {
|
||||
fmt.Fprintln(w, "START OK", me.Hostname)
|
||||
fmt.Fprintln(w, output)
|
||||
} else {
|
||||
fmt.Fprintln(w, "START FAILED", me.Hostname)
|
||||
fmt.Fprintln(w, "error =", err)
|
||||
fmt.Fprintln(w, "output =", output)
|
||||
fmt.Fprintln(w, "error =", r.Error)
|
||||
fmt.Fprintln(w, "output =", r.Stdout)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -231,10 +231,15 @@ func virshDumpXML(name string) (string, error) {
|
|||
cmd := []string{"virsh", "dumpxml", "--security-info", name}
|
||||
|
||||
log.Warn("Running:", cmd)
|
||||
err, ok, output := shell.RunCmd("/home/", cmd)
|
||||
shell.Run(cmd)
|
||||
if !ok {
|
||||
result := fmt.Sprintln(cmd, "failed:", err)
|
||||
r := shell.PathRun("/home/", cmd)
|
||||
output := strings.Join(r.Stdout, "\n")
|
||||
if r.Error != nil {
|
||||
result := fmt.Sprintln(cmd, "failed:", r.Error)
|
||||
log.Warn(result)
|
||||
return output, errors.New(result)
|
||||
}
|
||||
if r.Exit != 0 {
|
||||
result := fmt.Sprintln(cmd, "failed exit:", r.Exit)
|
||||
log.Warn(result)
|
||||
return output, errors.New(result)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue