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