talking with zood again
This commit is contained in:
parent
8c7f6c3c1b
commit
e85a8ae69f
4
doGui.go
4
doGui.go
|
@ -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()
|
||||
|
|
25
http.go
25
http.go
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue