summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go33
1 files changed, 18 insertions, 15 deletions
diff --git a/main.go b/main.go
index 69a8f45..98af0d0 100644
--- a/main.go
+++ b/main.go
@@ -4,6 +4,7 @@ package main
import (
"embed"
+ "fmt"
"os"
"path/filepath"
"time"
@@ -33,9 +34,9 @@ func main() {
os.Exit(0)
}
- if argv.Daemon {
- log.DaemonMode(true)
- }
+ // if argv.Daemon {
+ // log.DaemonMode(true)
+ // }
// set defaults
me.unstable = time.Now() // initialize the grid as unstable
@@ -52,20 +53,25 @@ func main() {
// how long the cluster must be stable before new droplets can be started
me.clusterStableDuration = 37 * time.Second
- // read in the config file
- me.cluster = new(pb.Cluster)
- me.cluster.E = new(pb.Events)
+ me.cluster = pb.InitCluster()
if err := me.cluster.ConfigLoad(); err != nil {
log.Info("config load error", err)
os.Exit(-1)
}
- for i, d := range me.cluster.Droplets {
+ loop := me.cluster.DropletsAll() // get the list of droplets
+ for loop.Scan() {
+ d := loop.Droplet()
+ if d == nil {
+ fmt.Println("d == nil")
+ os.Exit(-1)
+ }
+ fmt.Println("Droplet UUID:", d.Uuid)
if d.Current == nil {
d.Current = new(pb.Current)
}
d.Current.State = pb.DropletState_OFF
- log.Info(i, "droplet", d.Hostname)
+ log.Info("droplet", d.Hostname)
}
hmm := "pihole.wit.com"
d := me.cluster.FindDropletByName(hmm)
@@ -78,11 +84,11 @@ func main() {
var newEvents []*pb.Event
// sanity check the cluster & droplets
- if _, _, err := ValidateDroplets(me.cluster); err != nil {
+ if _, _, err := ValidateDroplets(); err != nil {
log.Info("todo: add flag to ignore. for now, fix problems in the config file.")
os.Exit(0)
}
- newe, err := ValidateDiskFilenames(me.cluster)
+ newe, err := ValidateDiskFilenames()
if err != nil {
log.Info(err)
os.Exit(-1)
@@ -91,7 +97,7 @@ func main() {
for _, e := range newe {
newEvents = append(newEvents, e)
}
- ValidateUniqueFilenames(me.cluster)
+ ValidateUniqueFilenames()
for _, filename := range argv.Xml {
domcfg, err := virtigolib.ReadXml(filename)
@@ -138,7 +144,7 @@ func main() {
}
// initialize each hypervisor
- for _, pbh := range me.cluster.Hypervisors {
+ for _, pbh := range me.cluster.H.Hypervisors {
// this is a new unknown droplet (not in the config file)
var h *HyperT
h = new(HyperT)
@@ -155,9 +161,6 @@ func main() {
for _, h := range me.hypers {
log.Info("starting polling on", h.pb.Hostname)
- // inititialize the search directories on each hypervisor
- h.sendDirs()
-
// start a watchdog on each hypervisor
go h.NewWatchdog()
}