xml generation works
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
783a06b050
commit
07ef0b9f5b
13
http.go
13
http.go
|
@ -60,7 +60,18 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
if tmp == "/start" {
|
if tmp == "/start" {
|
||||||
start := r.URL.Query().Get("start")
|
start := r.URL.Query().Get("start")
|
||||||
xml := "/root/jcarr/machines/autostart/" + start + ".xml"
|
xml := "/tmp/" + start + ".xml"
|
||||||
|
if shell.Unlink(xml) {
|
||||||
|
fmt.Fprintln(w, "START FAILED")
|
||||||
|
fmt.Fprintln(w, "error =", "could not remove existing xml file", xml)
|
||||||
|
fmt.Fprintln(w, "error =", "file still exists after unlink")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := newStart(start); err != nil {
|
||||||
|
fmt.Fprintln(w, "START FAILED")
|
||||||
|
fmt.Fprintln(w, "error =", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
cmd := []string{"virsh", "create", xml}
|
cmd := []string{"virsh", "create", xml}
|
||||||
|
|
||||||
fmt.Fprintln(w, "Handling URL:", tmp, "start droplet")
|
fmt.Fprintln(w, "Handling URL:", tmp, "start droplet")
|
||||||
|
|
3
main.go
3
main.go
|
@ -57,6 +57,9 @@ func main() {
|
||||||
for i, e := range me.cluster.Events {
|
for i, e := range me.cluster.Events {
|
||||||
log.Info("Event", i, e)
|
log.Info("Event", i, e)
|
||||||
}
|
}
|
||||||
|
for i, d := range me.cluster.Droplets {
|
||||||
|
log.Info("Event", i, d.Hostname)
|
||||||
|
}
|
||||||
|
|
||||||
if argv.Start != "" {
|
if argv.Start != "" {
|
||||||
newStart(argv.Start)
|
newStart(argv.Start)
|
||||||
|
|
8
start.go
8
start.go
|
@ -3,18 +3,18 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"errors"
|
||||||
|
|
||||||
"go.wit.com/lib/virtigoxml"
|
"go.wit.com/lib/virtigoxml"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"libvirt.org/go/libvirtxml"
|
"libvirt.org/go/libvirtxml"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newStart(start string) {
|
func newStart(start string) error {
|
||||||
d := me.cluster.FindDroplet(start)
|
d := me.cluster.FindDroplet(start)
|
||||||
if d == nil {
|
if d == nil {
|
||||||
log.Info("droplet is unknown:", start)
|
log.Info("droplet is unknown:", start)
|
||||||
os.Exit(0)
|
return errors.New("droplet is unknown: " + start)
|
||||||
}
|
}
|
||||||
log.Info("start droplet here:", d.Hostname)
|
log.Info("start droplet here:", d.Hostname)
|
||||||
domcfg := &libvirtxml.Domain{}
|
domcfg := &libvirtxml.Domain{}
|
||||||
|
@ -25,7 +25,7 @@ func newStart(start string) {
|
||||||
newAddXml(domcfg, "spice")
|
newAddXml(domcfg, "spice")
|
||||||
newAddXml(domcfg, "qcow")
|
newAddXml(domcfg, "qcow")
|
||||||
|
|
||||||
virtigoxml.StartDropletXml(me.cluster, d, domcfg, start)
|
return virtigoxml.GenerateDropletXml(me.cluster, d, domcfg, start)
|
||||||
}
|
}
|
||||||
|
|
||||||
func newAddXml(domcfg *libvirtxml.Domain, filename string) error {
|
func newAddXml(domcfg *libvirtxml.Domain, filename string) error {
|
||||||
|
|
|
@ -8,7 +8,7 @@ var me Virtigod
|
||||||
|
|
||||||
// this app's variables
|
// this app's variables
|
||||||
type Virtigod struct {
|
type Virtigod struct {
|
||||||
cluster *virtbuf.Cluster
|
cluster *virtbuf.Cluster
|
||||||
// droplets *virtbuf.Droplets
|
// droplets *virtbuf.Droplets
|
||||||
// events *virtbuf.Events
|
// events *virtbuf.Events
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue