// Copyright 2017-2025 WIT.COM Inc. All rights reserved. // Use of this source code is governed by the GPL 3.0 package main import ( "fmt" "time" "go.wit.com/gui" "go.wit.com/lib/protobuf/zoopb" "go.wit.com/log" ) func doMachinesUpgradeTable() { if me.machinesTB != nil { me.machinesTB.Delete() me.machinesTB = nil } // 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 { t := pb.NewTable("MachinesPB") t.NewUuid() t.SetParent(tbox) t.AddHostname() t.AddMemory() t.AddCpus() t.AddStringFunc("sMB", func(m *zoopb.Machine) string { return fmt.Sprintf("%d mb", m.Memory/(1024*1024)) }) t.AddStringFunc("zood", func(m *zoopb.Machine) string { return findVersion(m, "zood") }) t.AddTimeFunc("age", func(m *zoopb.Machine) time.Time { return m.Laststamp.AsTime() }) f := func(m *zoopb.Machine) string { log.Info("machine =", m.Hostname) return m.Hostname } t.AddButtonFunc("upgrade", f) t.ShowTable() return t }