import almost works
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
b0ebbeb7bc
commit
71fc48cbc2
28
http.go
28
http.go
|
@ -42,7 +42,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
|||
domname := r.URL.Query().Get("domain")
|
||||
fmt.Fprint(w, "import domain:", domname)
|
||||
|
||||
xmldoc, err := virshDumpXML(w, r, domname)
|
||||
xmldoc, err := virshDumpXML( domname)
|
||||
|
||||
domcfg := &libvirtxml.Domain{}
|
||||
fmt.Fprintln(w, "domcfg.Unmarshal()")
|
||||
|
@ -105,9 +105,9 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
|||
// curl http://localhost:2520/import?domain=foo.bar.com
|
||||
if route == "/import" {
|
||||
domname := r.URL.Query().Get("domain")
|
||||
fmt.Fprint(w, "import domain:", domname)
|
||||
// fmt.Fprint(w, "import domain:", domname)
|
||||
|
||||
xmldoc, err := virshDumpXML(w, r, domname)
|
||||
xmldoc, err := virshDumpXML(domname)
|
||||
|
||||
domcfg := &libvirtxml.Domain{}
|
||||
err = domcfg.Unmarshal(xmldoc)
|
||||
|
@ -118,14 +118,14 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
// importDomain(w, r, domcfg)
|
||||
// importDomain(w http.ResponseWriter, r *http.Request, dom *libvirtxml.Domain) {
|
||||
d, _, err := virtigolib.ImportXML(domcfg)
|
||||
xml, _, err := virtigolib.ImportXML(domcfg)
|
||||
if err != nil {
|
||||
fmt.Fprintln(w, "ImportXML failed for", domname, err)
|
||||
return
|
||||
}
|
||||
fmt.Fprintln(w, "ImportXML worked for", domname)
|
||||
fmt.Fprintln(w, "should send the protobuf to virtigo here", domname)
|
||||
d.Current.FullXml = xmldoc
|
||||
log.Warn("ImportXML worked for", domname)
|
||||
fmt.Fprintln(w, xml)
|
||||
// d.Current.FullXml = xmldoc
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -229,21 +229,17 @@ func startHTTP() {
|
|||
}
|
||||
}
|
||||
|
||||
func virshDumpXML(w http.ResponseWriter, r *http.Request, name string) (string, error) {
|
||||
func virshDumpXML(name string) (string, error) {
|
||||
cmd := []string{"virsh", "dumpxml", "--security-info", name}
|
||||
|
||||
fmt.Fprintln(w, "virsh dumpxml", name)
|
||||
log.Warn("cmd :", cmd)
|
||||
fmt.Fprintln(w, "cmd: ", cmd)
|
||||
log.Warn("Running:", cmd)
|
||||
err, ok, output := shell.RunCmd("/home/", cmd)
|
||||
shell.Run(cmd)
|
||||
if !ok {
|
||||
fmt.Fprintln(w, "START FAILED", me.Hostname)
|
||||
fmt.Fprintln(w, "error =", err)
|
||||
result := fmt.Sprintln("virsh dumpxml failed:", err)
|
||||
result := fmt.Sprintln(cmd, "failed:", err)
|
||||
log.Warn(result)
|
||||
return output, errors.New(result)
|
||||
}
|
||||
fmt.Fprintln(w, "START OK", me.Hostname)
|
||||
fmt.Fprintln(w, output)
|
||||
log.Warn(cmd, "OK")
|
||||
return output, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue