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")
|
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{}
|
domcfg := &libvirtxml.Domain{}
|
||||||
fmt.Fprintln(w, "domcfg.Unmarshal()")
|
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
|
// curl http://localhost:2520/import?domain=foo.bar.com
|
||||||
if route == "/import" {
|
if route == "/import" {
|
||||||
domname := r.URL.Query().Get("domain")
|
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{}
|
domcfg := &libvirtxml.Domain{}
|
||||||
err = domcfg.Unmarshal(xmldoc)
|
err = domcfg.Unmarshal(xmldoc)
|
||||||
|
@ -118,14 +118,14 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
// importDomain(w, r, domcfg)
|
// importDomain(w, r, domcfg)
|
||||||
// importDomain(w http.ResponseWriter, r *http.Request, dom *libvirtxml.Domain) {
|
// importDomain(w http.ResponseWriter, r *http.Request, dom *libvirtxml.Domain) {
|
||||||
d, _, err := virtigolib.ImportXML(domcfg)
|
xml, _, err := virtigolib.ImportXML(domcfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintln(w, "ImportXML failed for", domname, err)
|
fmt.Fprintln(w, "ImportXML failed for", domname, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Fprintln(w, "ImportXML worked for", domname)
|
log.Warn("ImportXML worked for", domname)
|
||||||
fmt.Fprintln(w, "should send the protobuf to virtigo here", domname)
|
fmt.Fprintln(w, xml)
|
||||||
d.Current.FullXml = xmldoc
|
// d.Current.FullXml = xmldoc
|
||||||
return
|
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}
|
cmd := []string{"virsh", "dumpxml", "--security-info", name}
|
||||||
|
|
||||||
fmt.Fprintln(w, "virsh dumpxml", name)
|
log.Warn("Running:", cmd)
|
||||||
log.Warn("cmd :", cmd)
|
|
||||||
fmt.Fprintln(w, "cmd: ", cmd)
|
|
||||||
err, ok, output := shell.RunCmd("/home/", cmd)
|
err, ok, output := shell.RunCmd("/home/", cmd)
|
||||||
shell.Run(cmd)
|
shell.Run(cmd)
|
||||||
if !ok {
|
if !ok {
|
||||||
fmt.Fprintln(w, "START FAILED", me.Hostname)
|
result := fmt.Sprintln(cmd, "failed:", err)
|
||||||
fmt.Fprintln(w, "error =", err)
|
log.Warn(result)
|
||||||
result := fmt.Sprintln("virsh dumpxml failed:", err)
|
|
||||||
return output, errors.New(result)
|
return output, errors.New(result)
|
||||||
}
|
}
|
||||||
fmt.Fprintln(w, "START OK", me.Hostname)
|
log.Warn(cmd, "OK")
|
||||||
fmt.Fprintln(w, output)
|
|
||||||
return output, nil
|
return output, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue