doesn't deal with libvirtxml directly anymore
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
3c1efcba0e
commit
cec509ae7f
21
main.go
21
main.go
|
@ -52,19 +52,6 @@ func main() {
|
|||
os.Exit(-1)
|
||||
}
|
||||
|
||||
// me.cluster.Events = new(pb.Events)
|
||||
// u := uuid.New()
|
||||
// me.events.Uuid = u.String()
|
||||
// me.events.Version = "dirty v1"
|
||||
|
||||
/*
|
||||
err := cfgfile()
|
||||
if err != nil {
|
||||
log.Warn("reading config file failed", err)
|
||||
os.Exit(-1)
|
||||
}
|
||||
*/
|
||||
|
||||
for i, d := range me.cluster.Droplets {
|
||||
d.CurrentState = pb.DropletState_OFF
|
||||
log.Info(i, "droplet", d.Hostname)
|
||||
|
@ -147,12 +134,6 @@ func main() {
|
|||
}
|
||||
// initialize each hypervisor
|
||||
for _, pbh := range me.cluster.Hypervisors {
|
||||
/*
|
||||
h := findHypervisor(pbh.Hostname)
|
||||
if h != nil {
|
||||
continue
|
||||
}
|
||||
*/
|
||||
// this is a new unknown droplet (not in the config file)
|
||||
h := new(HyperT)
|
||||
h.pb = pbh
|
||||
|
@ -167,6 +148,8 @@ func main() {
|
|||
// start the watchdog polling for each hypervisor
|
||||
for _, h := range me.hypers {
|
||||
log.Info("starting polling on", h.pb.Hostname)
|
||||
// inititialize the search directories on each hypervisor
|
||||
h.sendDirs()
|
||||
go h.NewWatchdog()
|
||||
}
|
||||
|
||||
|
|
22
structs.go
22
structs.go
|
@ -22,17 +22,13 @@ func (b *virtigoT) Enable() {
|
|||
type virtigoT struct {
|
||||
cluster *pb.Cluster // basic cluster settings
|
||||
delay time.Duration // how often to poll the hypervisors
|
||||
// events *pb.Events // cluster events
|
||||
// dmap map[*pb.Droplet]*DropletT // map to the local struct
|
||||
hmap map[*pb.Hypervisor]*HyperT // map to the local struct
|
||||
names []string
|
||||
hypers []*HyperT
|
||||
// droplets []*DropletT
|
||||
killcount int
|
||||
unstable time.Time // the last time the cluster was incorrect
|
||||
changed bool
|
||||
killcount int
|
||||
unstable time.Time // the last time the cluster was incorrect
|
||||
changed bool
|
||||
unstableTimeout time.Duration
|
||||
// dirs []string // all the paths too search for a qcow image
|
||||
}
|
||||
|
||||
// the stuff that is needed for a hypervisor
|
||||
|
@ -42,15 +38,3 @@ type HyperT struct {
|
|||
lastpoll time.Time // the last time the hypervisor polled
|
||||
killcount int
|
||||
}
|
||||
|
||||
/*
|
||||
// the stuff that is needed for a hypervisor
|
||||
type DropletT struct {
|
||||
pb *pb.Droplet // the Droplet protobuf
|
||||
xml *libvirtxml.Domain // a xml representation from libvirt
|
||||
h *HyperT // the hypervisor it's currently running on
|
||||
CurrentState pb.DropletState // what the state of the droplet is ACTUALLY IS
|
||||
lastpoll time.Time // the last time the droplet was seen running
|
||||
starts int // how many times a start event has been attempted
|
||||
}
|
||||
*/
|
||||
|
|
24
watchdog.go
24
watchdog.go
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
"time"
|
||||
|
||||
pb "go.wit.com/lib/protobuf/virtbuf"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
|
@ -14,6 +15,29 @@ func TimeFunction(f func()) time.Duration {
|
|||
return time.Since(startTime) // Calculate the elapsed time
|
||||
}
|
||||
|
||||
func (h *HyperT) sendDirs() {
|
||||
url := "http://" + h.pb.Hostname + ":2520/cluster"
|
||||
var msg string
|
||||
var data []byte
|
||||
|
||||
var c *pb.Cluster
|
||||
c = new(pb.Cluster)
|
||||
for _, dir := range me.cluster.Dirs {
|
||||
c.Dirs = append(c.Dirs, dir)
|
||||
}
|
||||
msg = c.FormatJSON()
|
||||
data = []byte(msg) // Convert the string to []byte
|
||||
req, err := httpPost(url, data)
|
||||
if err != nil {
|
||||
log.Info("error:", err)
|
||||
return
|
||||
}
|
||||
// log.Info("http post url:", url)
|
||||
// log.Info("http post data:", msg)
|
||||
|
||||
log.Info("EVENT start droplet response: " + string(req))
|
||||
}
|
||||
|
||||
func (h *HyperT) NewWatchdog() {
|
||||
h.dog = time.NewTicker(me.delay)
|
||||
defer h.dog.Stop()
|
||||
|
|
Loading…
Reference in New Issue