diff --git a/doGui.go b/doGui.go index fb15a82..8ee8c30 100644 --- a/doGui.go +++ b/doGui.go @@ -19,6 +19,9 @@ func debug() { for { time.Sleep(90 * time.Second) log.Info("TODO: zookeeper scan here. repo count =") + if me.machinesWin != nil { + doMachinesUpgradeTable() + } } } @@ -42,7 +45,20 @@ func doGui() { group1 := vbox.NewGroup("Zookeeper Settings") grid := group1.NewGrid("buildOptions", 0, 0) - addButtonForZooPB(grid) + grid.NewButton("show zoo", func() { + // if the window exists, just toggle it open or closed + if me.machinesWin != nil { + me.machinesWin.Toggle() + return + } + + me.machinesWin = gadgets.NewGenericWindow("Zoo Machines", "Stuff") + me.machinesWin.Win.Custom = func() { + log.Info("test delete window here") + } + me.machinesBox = me.machinesWin.Bottom.Box().SetProgName("TBOX") + doMachinesUpgradeTable() + }) // sits here forever debug() diff --git a/main.go b/main.go index f7d670f..bae1d78 100644 --- a/main.go +++ b/main.go @@ -35,7 +35,7 @@ func main() { log.DaemonMode(true) } - me = new(stuff) + me = new(zookeep) me.hostname, _ = os.Hostname() me.pollDelay = 10 * time.Second me.machines = zoopb.NewMachines() diff --git a/structs.go b/structs.go index f3978c3..20b3a34 100644 --- a/structs.go +++ b/structs.go @@ -7,22 +7,26 @@ import ( "time" "go.wit.com/gui" + "go.wit.com/lib/gadgets" "go.wit.com/lib/protobuf/zoopb" ) -var me *stuff +var me *zookeep // this app's variables -type stuff struct { - hostname string // my fqdn dns zookeeper hostname - pollDelay time.Duration // how often to report our status - dog *time.Ticker // the watchdog timer - dogchan chan bool // can kill the watchdog - distro string // debian,redhat,gentoo,macos,wincrap - packages *zoopb.Packages // installed packages and versions - machines *zoopb.Machines // every machine that has reported itself to the zookeeper - machines2 *zoopb.Machines // every machine that has reported itself to the zookeeper - targets map[string]string // what versions the machines should be running - upgrade map[string]bool // use this to trigger builds - myGui *gui.Node // the gui toolkit handle +type zookeep struct { + hostname string // my fqdn dns zookeeper hostname + pollDelay time.Duration // how often to report our status + dog *time.Ticker // the watchdog timer + dogchan chan bool // can kill the watchdog + distro string // debian,redhat,gentoo,macos,wincrap + packages *zoopb.Packages // installed packages and versions + machines *zoopb.Machines // every machine that has reported itself to the zookeeper + machines2 *zoopb.Machines // every machine that has reported itself to the zookeeper + targets map[string]string // what versions the machines should be running + upgrade map[string]bool // use this to trigger builds + myGui *gui.Node // the gui toolkit handle + machinesWin *gadgets.GenericWindow // the machines gui window + machinesBox *gui.Node // the machines gui parent box widget + machinesTB *zoopb.MachinesTable // the machines gui table buffer } diff --git a/windowZooPB.go b/windowZooPB.go index 154335b..5f7eb74 100644 --- a/windowZooPB.go +++ b/windowZooPB.go @@ -8,56 +8,25 @@ import ( "time" "go.wit.com/gui" - "go.wit.com/lib/gadgets" "go.wit.com/lib/protobuf/zoopb" "go.wit.com/log" ) -func addButtonForZooPB(grid *gui.Node) (*gui.Node, *gadgets.GenericWindow) { - var win *gadgets.GenericWindow - b := grid.NewButton("show zoo", func() { - // if the window exists, just toggle it open or closed - if win != nil { - win.Toggle() - return - } +func doMachinesUpgradeTable() { + if me.machinesTB != nil { + me.machinesTB.Delete() + me.machinesTB = nil + } - win = gadgets.NewGenericWindow("Zoo Raw PB View", "Stuff") - win.Win.Custom = func() { - log.Info("test delete window here") - } - tbox := win.Bottom.Box().SetProgName("TBOX") - grid := win.Group.RawGrid() - - var t *zoopb.MachinesTable - grid.NewButton("Show", func() { - if t != nil { - t.Delete() - t = nil - } - - // display the protobuf - t = AddMachinesPB(tbox, me.machines) - f := func(m *zoopb.Machine) { - log.Info("got to MachinesTable.Custom() ", m.Hostname) - } - t.Custom(f) - log.Info("table has uuid", t.GetUuid()) - }) - - grid.NewButton("update", func() { - if t != nil { - t.Delete() - t = nil - } - t = AddMachinesPB(tbox, me.machines) - log.Info("table has uuid", t.GetUuid()) - }) - grid.NewButton("ListChildren", func() { - me.myGui.ListChildren(false) - }) - }) - return b, win + // display the protobuf + me.machinesTB = AddMachinesPB(me.machinesBox, me.machines) + f := func(m *zoopb.Machine) { + log.Info("upgrade machine", m.Hostname, "memory", m.Memory/(1024*1024*1024)) + log.Info("ADD THE CODE TO TRIGGER AN UPGRADE HERE") + log.Info("ADD THE CODE TO TRIGGER AN UPGRADE HERE") + } + me.machinesTB.Custom(f) + log.Info("table has uuid", me.machinesTB.GetUuid()) } func AddMachinesPB(tbox *gui.Node, pb *zoopb.Machines) *zoopb.MachinesTable {