only knows about protobufs

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-10-26 20:47:44 -05:00
parent 170f548a61
commit 9a0ebc0348
4 changed files with 23 additions and 29 deletions

21
http.go
View File

@ -67,6 +67,25 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
return 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" { if tmp == "/start" {
log.Info("/start jcarr actually doing START") log.Info("/start jcarr actually doing START")
fmt.Fprintln(w, "/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)) fmt.Fprintln(w, "START len(msg) =", len(msg))
err = d.UnmarshalJSON(msg) err = d.UnmarshalJSON(msg)
if d.Hostname == "" { if d.Hostname == "" {
fmt.Fprintln(w,"START hostname is blank") fmt.Fprintln(w, "START hostname is blank")
log.Info("START hostname is blank") log.Info("START hostname is blank")
return return
} }

20
main.go
View File

@ -23,7 +23,6 @@ import (
"github.com/digitalocean/go-qemu/hypervisor" "github.com/digitalocean/go-qemu/hypervisor"
"go.wit.com/dev/alexflint/arg" "go.wit.com/dev/alexflint/arg"
pb "go.wit.com/lib/protobuf/virtbuf"
"go.wit.com/log" "go.wit.com/log"
) )
@ -48,25 +47,6 @@ func main() {
os.Exit(0) 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) log.DaemonMode(true)
// fmt.Printf("\nConnecting to %s://%s\n", *network, *address) // fmt.Printf("\nConnecting to %s://%s\n", *network, *address)

View File

@ -26,7 +26,7 @@ func newStart(start string, d *pb.Droplet) error {
newAddXml(domcfg, "spice") newAddXml(domcfg, "spice")
newAddXml(domcfg, "qcow") 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 { func newAddXml(domcfg *libvirtxml.Domain, filename string) error {

View File

@ -1,14 +1,9 @@
package main package main
import (
"go.wit.com/lib/protobuf/virtbuf"
)
var me Virtigod var me Virtigod
// this app's variables // this app's variables
type Virtigod struct { type Virtigod struct {
cluster *virtbuf.Cluster dirs []string
// droplets *virtbuf.Droplets // cluster *virtbuf.Cluster
// events *virtbuf.Events
} }