diff --git a/http.go b/http.go index 5fb63f6..1572fc8 100644 --- a/http.go +++ b/http.go @@ -67,6 +67,25 @@ func okHandler(w http.ResponseWriter, r *http.Request) { return } + if tmp == "/cluster" { + log.Info("/cluster jcarr actually doing START") + fmt.Fprintln(w, "/cluster jcarr actually doing START") + var c *pb.Cluster + c = new(pb.Cluster) + + fmt.Fprintln(w, "START len(msg) =", len(msg)) + err = c.UnmarshalJSON(msg) + if err != nil { + fmt.Fprintln(w, "START FAILED") + fmt.Fprintln(w, "error =", err) + } + for _, dir := range c.Dirs { + log.Info("append dir", dir) + fmt.Fprintln(w, "append dir", dir) + me.dirs = append(me.dirs, dir) + } + } + if tmp == "/start" { log.Info("/start jcarr actually doing START") fmt.Fprintln(w, "/start jcarr actually doing START") @@ -93,7 +112,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(w, "START len(msg) =", len(msg)) err = d.UnmarshalJSON(msg) if d.Hostname == "" { - fmt.Fprintln(w,"START hostname is blank") + fmt.Fprintln(w, "START hostname is blank") log.Info("START hostname is blank") return } diff --git a/main.go b/main.go index 19c684f..ae7069c 100644 --- a/main.go +++ b/main.go @@ -23,7 +23,6 @@ import ( "github.com/digitalocean/go-qemu/hypervisor" "go.wit.com/dev/alexflint/arg" - pb "go.wit.com/lib/protobuf/virtbuf" "go.wit.com/log" ) @@ -48,25 +47,6 @@ func main() { os.Exit(0) } - me.cluster = new(pb.Cluster) - if err := me.cluster.ConfigLoad(); err != nil { - log.Info("config file error:", err) - os.Exit(0) - } - - for i, e := range me.cluster.Events { - log.Info("Event", i, e) - } - for i, d := range me.cluster.Droplets { - log.Info("Event", i, d.Hostname) - } - - if argv.Start != "" { - d := me.cluster.FindDroplet(argv.Start) - newStart(argv.Start, d) - os.Exit(0) - } - log.DaemonMode(true) // fmt.Printf("\nConnecting to %s://%s\n", *network, *address) diff --git a/start.go b/start.go index 4bd3844..f7c1fbf 100644 --- a/start.go +++ b/start.go @@ -26,7 +26,7 @@ func newStart(start string, d *pb.Droplet) error { newAddXml(domcfg, "spice") newAddXml(domcfg, "qcow") - return virtigoxml.GenerateDropletXml(me.cluster, d, domcfg, start) + return virtigoxml.GenerateDropletXml(me.dirs, d, domcfg, start) } func newAddXml(domcfg *libvirtxml.Domain, filename string) error { diff --git a/structs.go b/structs.go index a99883a..a6e323a 100644 --- a/structs.go +++ b/structs.go @@ -1,14 +1,9 @@ package main -import ( - "go.wit.com/lib/protobuf/virtbuf" -) - var me Virtigod // this app's variables type Virtigod struct { - cluster *virtbuf.Cluster - // droplets *virtbuf.Droplets - // events *virtbuf.Events + dirs []string + // cluster *virtbuf.Cluster }