diff options
| author | Jeff Carr <[email protected]> | 2025-03-06 05:16:00 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-03-06 05:34:25 -0600 |
| commit | e85a8ae69f538147f969859ea45af6048fce243c (patch) | |
| tree | 2a90f5f94656fb9a7404b538373318f2141c5e76 | |
| parent | 8c7f6c3c1be68c3ac350c4b611e08ed8b23bd3a8 (diff) | |
talking with zood again
| -rw-r--r-- | doGui.go | 4 | ||||
| -rw-r--r-- | http.go | 25 | ||||
| -rw-r--r-- | machine.go | 2 | ||||
| -rw-r--r-- | structs.go | 2 | ||||
| -rw-r--r-- | windowZood.go | 11 |
5 files changed, 19 insertions, 25 deletions
@@ -54,6 +54,10 @@ func doGui() { makeZoodWin() }) + grid.NewButton("Cluster Events", func() { + log.Info("todo: start a list here!") + }) + // sit here forever refreshing the GUI for { refresh() @@ -41,31 +41,6 @@ func okHandler(w http.ResponseWriter, r *http.Request) { if route == "/machine" { handleMachine(r, w, hostname, msg) return - - /* - var m *zoopb.Machine - m = new(zoopb.Machine) - if err := m.Unmarshal(msg); err != nil { - log.Info("zoo host sent unknown machine protobuf len", len(msg)) - forgepb.IdentifyProtobuf(msg) - log.Info("error =", err) - return - } - log.Log(INFO, "proto.Unmarshal() worked on wire message len", len(msg), "from", m.Hostname) - b := me.upgrade[m.Hostname] - switch updateMachine(m) { - case "upgrade": - if b { - fmt.Fprintln(w, "apt update") - me.upgrade[m.Hostname] = false - } else { - fmt.Fprintln(w, "upgrade") - } - default: - fmt.Fprintln(w, "notsure") - } - return - */ } if route == "/status" { @@ -4,6 +4,7 @@ package main import ( + "fmt" "net/http" "strings" "time" @@ -53,6 +54,7 @@ func handleMachine(r *http.Request, w http.ResponseWriter, hostname string, data log.Info("hostname ua changed len =", len(data), ra, hostname, ua) m.UserAgent = ua } + fmt.Fprintln(w, "upgrade") // log.Info("update machine protobuf", hostname) updateMachine(newm) } @@ -4,6 +4,7 @@ package main import ( + "sync" "time" "go.wit.com/gui" @@ -33,6 +34,7 @@ type zookeep struct { } type stdTableWin struct { + sync.Mutex win *gadgets.GenericWindow // the machines gui window box *gui.Node // the machines gui parent box widget TB *zoopb.MachinesTable // the machines gui table buffer diff --git a/windowZood.go b/windowZood.go index 3aeca05..f62da2c 100644 --- a/windowZood.go +++ b/windowZood.go @@ -34,6 +34,8 @@ func makeZoodWin() { } func doMachinesUpgradeTable() { + me.zood.Lock() + defer me.zood.Unlock() if me.zood.TB != nil { me.zood.TB.Delete() me.zood.TB = nil @@ -45,6 +47,7 @@ func doMachinesUpgradeTable() { 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") + m.Upgrade = true } me.zood.TB.Custom(f) log.Info("table has uuid", me.zood.TB.GetUuid()) @@ -66,6 +69,14 @@ func AddMachinesPB(tbox *gui.Node, pb *zoopb.Machines) *zoopb.MachinesTable { return findVersion(m, "zood") }) + // show if the machine needs to be upgraded + t.AddStringFunc("triggered?", func(m *zoopb.Machine) string { + if m.Upgrade { + return "yes" + } + return "" + }) + t.AddTimeFunc("age", func(m *zoopb.Machine) time.Time { return m.Laststamp.AsTime() }) |
