2025-02-15 03:45:32 -06:00
|
|
|
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
|
|
|
|
// Use of this source code is governed by the GPL 3.0
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
// An app to submit patches for the 30 GO GUI repos
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"go.wit.com/gui"
|
|
|
|
"go.wit.com/lib/gadgets"
|
2025-03-12 13:16:05 -05:00
|
|
|
"go.wit.com/lib/protobuf/zoopb"
|
2025-02-15 03:45:32 -06:00
|
|
|
"go.wit.com/log"
|
|
|
|
)
|
|
|
|
|
2025-03-06 04:36:07 -06:00
|
|
|
// refresh the windows & tables the user has open
|
|
|
|
func refresh() {
|
|
|
|
if argv.Verbose {
|
|
|
|
log.Info("zookeeper scan here")
|
|
|
|
}
|
|
|
|
if me.zood != nil {
|
2025-03-12 13:16:05 -05:00
|
|
|
me.zood.doMachinesUpgradeTable(me.machines)
|
2025-03-12 15:10:49 -05:00
|
|
|
all := me.machines.All()
|
|
|
|
for all.Scan() {
|
|
|
|
m := all.Next()
|
|
|
|
if me.hostname == m.Hostname {
|
|
|
|
// this is me! This is the version of zood that should be installed everywhere
|
|
|
|
v := findVersion(m, "zood")
|
|
|
|
me.zood.version = v
|
|
|
|
me.zood.versionL.SetText(v)
|
|
|
|
}
|
|
|
|
}
|
2025-02-15 03:45:32 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func doGui() {
|
|
|
|
me.myGui = gui.New()
|
|
|
|
me.myGui.InitEmbed(resources)
|
|
|
|
me.myGui.Default()
|
|
|
|
|
2025-03-05 07:46:05 -06:00
|
|
|
win := gadgets.RawBasicWindow("Zookeeper: (inventory your cluster)")
|
|
|
|
win.Make()
|
|
|
|
win.Show()
|
|
|
|
win.Custom = func() {
|
2025-02-15 03:45:32 -06:00
|
|
|
log.Warn("Main window close")
|
|
|
|
os.Exit(0)
|
|
|
|
}
|
|
|
|
|
|
|
|
box := win.Box()
|
|
|
|
|
|
|
|
vbox := box.NewVerticalBox("BOX2")
|
|
|
|
|
|
|
|
group1 := vbox.NewGroup("Zookeeper Settings")
|
|
|
|
grid := group1.NewGrid("buildOptions", 0, 0)
|
|
|
|
|
2025-03-06 04:36:07 -06:00
|
|
|
grid.NewButton("zood versions", func() {
|
2025-03-06 03:54:08 -06:00
|
|
|
// if the window exists, just toggle it open or closed
|
2025-03-06 04:36:07 -06:00
|
|
|
if me.zood != nil {
|
|
|
|
me.zood.Toggle()
|
2025-03-06 03:54:08 -06:00
|
|
|
return
|
|
|
|
}
|
2025-03-12 15:10:49 -05:00
|
|
|
me.zood = makeZoodWin()
|
2025-03-06 04:36:07 -06:00
|
|
|
})
|
2025-02-15 04:12:27 -06:00
|
|
|
|
2025-03-06 05:16:00 -06:00
|
|
|
grid.NewButton("Cluster Events", func() {
|
|
|
|
log.Info("todo: start a list here!")
|
|
|
|
})
|
|
|
|
|
2025-03-06 04:36:07 -06:00
|
|
|
// sit here forever refreshing the GUI
|
|
|
|
for {
|
|
|
|
refresh()
|
2025-03-12 15:10:49 -05:00
|
|
|
time.Sleep(90 * time.Second)
|
2025-02-15 06:44:25 -06:00
|
|
|
}
|
|
|
|
}
|
2025-03-12 13:16:05 -05:00
|
|
|
|
|
|
|
func saveMachineState() {
|
|
|
|
cur := zoopb.NewMachines()
|
|
|
|
|
|
|
|
all := me.machines.SortByHostname()
|
|
|
|
for all.Scan() {
|
|
|
|
m := all.Next()
|
|
|
|
log.Info("have machine:", m.Hostname)
|
|
|
|
cur.Append(m)
|
|
|
|
}
|
|
|
|
cur.ConfigSave()
|
|
|
|
}
|