summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-10-26 08:54:28 -0500
committerJeff Carr <[email protected]>2024-10-26 08:54:28 -0500
commitb4518e8b82df2109b75072c679122e4826b341ef (patch)
treea501d4f3c0717a9a5acb51fbcec2b0cc232cda86 /main.go
parent9020957ee73741a3f120ff7fd9f9afcb517e02ed (diff)
compiles and lists hypervisors
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'main.go')
-rw-r--r--main.go28
1 files changed, 23 insertions, 5 deletions
diff --git a/main.go b/main.go
index 7fd9f38..e09de05 100644
--- a/main.go
+++ b/main.go
@@ -41,7 +41,8 @@ func main() {
me.unstable = time.Now() // initialize the grid as unstable
me.delay = 5 * time.Second // how often to poll the hypervisors
me.changed = false
- me.dmap = make(map[*pb.Droplet]*DropletT)
+ // me.dmap = make(map[*pb.Droplet]*DropletT)
+ me.hmap = make(map[*pb.Hypervisor]*HyperT)
// read in the config file
me.cluster = new(pb.Cluster)
@@ -100,11 +101,10 @@ func main() {
log.Info(i, "Event:", e.Droplet, e.FieldName, "orig:", e.OrigVal, "new:", e.NewVal)
me.changed = true
}
- if err := me.cluster.ConfigSave(); err != nil {
- log.Info("configsave error", err)
- }
+ // if err := me.cluster.ConfigSave(); err != nil {
+ // log.Info("configsave error", err)
+ // }
- os.Exit(0)
if me.changed {
if argv.Save {
if err := me.cluster.ConfigSave(); err != nil {
@@ -129,6 +129,24 @@ func main() {
newStart(argv.Start)
os.Exit(0)
}
+ // 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
+
+ h.lastpoll = time.Now()
+
+ me.hmap[pbh] = h
+ // me.hypers = append(me.hypers, h)
+ log.Log(EVENT, "config new hypervisors", h.pb.Hostname)
+ }
// start the watchdog polling for each hypervisor
for _, h := range me.hypers {