hypervisor poll time attempt 1

This commit is contained in:
Jeff Carr 2025-02-23 12:59:02 -06:00
parent 4aef241137
commit c82997ed61
1 changed files with 49 additions and 13 deletions

View File

@ -30,13 +30,49 @@ func (mt *EventsTable) NewUuid() {
} }
func (mt *HypervisorsTable) Update() { func (mt *HypervisorsTable) Update() {
log.Info("now what hyper?") for _, name := range mt.pb.Order {
if mt.updateTimeFunc(name) {
continue
}
}
mt.parent.UpdateTable(mt.pb)
}
func (mt *HypervisorsTable) updateTimeFunc(name string) bool {
log.Info("LOOKING FOR TIME row", name)
var found *guipb.TimeRow
for i, r := range mt.pb.TimeRows {
// log.Info("could use", i, r.Header.Name, "for name =", name)
if r.Header.Name == name {
log.Info("found row", i, r.Header.Name)
found = r
break
}
}
if found == nil {
log.Info("did not find time row", name)
return false
}
for _, sf := range mt.timeFuncs {
if sf.title != name {
continue
}
// log.Info("updateTimeFunc() has row len =", len(mt.x.Droplets))
// log.Info("virtpb: starting", name, found.Vals)
for i, _ := range found.Vals {
newt := sf.f(mt.x.Hypervisors[i])
found.Vals[i] = timestamppb.New(newt) // convert to protobuf time
}
// log.Info("virtpb: ending", name, found.Vals)
return true
}
return false
} }
func (mt *DropletsTable) Update() { func (mt *DropletsTable) Update() {
log.Info("now what?") // log.Info("now what?")
for _, name := range mt.pb.Order { for _, name := range mt.pb.Order {
log.Info("virtpb: trying to update row()", name) // log.Info("virtpb: trying to update row()", name)
if mt.updateStringFunc(name) { if mt.updateStringFunc(name) {
continue continue
} }
@ -49,7 +85,7 @@ func (mt *DropletsTable) Update() {
} }
*/ */
} }
mt.dumpStringFunc("Hostname") // mt.dumpStringFunc("Hostname")
mt.parent.UpdateTable(mt.pb) mt.parent.UpdateTable(mt.pb)
} }
@ -64,12 +100,12 @@ func (mt *DropletsTable) dumpStringFunc(name string) {
} }
func (mt *DropletsTable) updateStringFunc(name string) bool { func (mt *DropletsTable) updateStringFunc(name string) bool {
log.Info("LOOKING FOR STRING row", name) // log.Info("LOOKING FOR STRING row", name)
var found *guipb.StringRow var found *guipb.StringRow
for i, r := range mt.pb.StringRows { for _, r := range mt.pb.StringRows {
// log.Info("could use", i, r.Header.Name, "for name =", name) // log.Info("could use", i, r.Header.Name, "for name =", name)
if r.Header.Name == name { if r.Header.Name == name {
log.Info("found row", i, r.Header.Name) // log.Info("found row", i, r.Header.Name)
found = r found = r
break break
} }
@ -82,8 +118,8 @@ func (mt *DropletsTable) updateStringFunc(name string) bool {
if sf.title != name { if sf.title != name {
continue continue
} }
log.Printf("updateStringFunc() %s len (%d)\n", name, len(mt.x.Droplets)) // log.Printf("updateStringFunc() %s len (%d)\n", name, len(mt.x.Droplets))
log.Info("virtpb: starting", name, found.Vals) // log.Info("virtpb: starting", name, found.Vals)
for i, _ := range found.Vals { for i, _ := range found.Vals {
tmp := sf.f(mt.x.Droplets[i]) tmp := sf.f(mt.x.Droplets[i])
if tmp == "www.wit.com" { if tmp == "www.wit.com" {
@ -92,7 +128,7 @@ func (mt *DropletsTable) updateStringFunc(name string) bool {
} }
found.Vals[i] = tmp found.Vals[i] = tmp
} }
log.Info("virtpb: ending", name, found.Vals) // log.Info("virtpb: ending", name, found.Vals)
return true return true
} }
return false return false
@ -117,13 +153,13 @@ func (mt *DropletsTable) updateTimeFunc(name string) bool {
if sf.title != name { if sf.title != name {
continue continue
} }
log.Info("updateTimeFunc() has row len =", len(mt.x.Droplets)) // log.Info("updateTimeFunc() has row len =", len(mt.x.Droplets))
log.Info("virtpb: starting", name, found.Vals) // log.Info("virtpb: starting", name, found.Vals)
for i, _ := range found.Vals { for i, _ := range found.Vals {
newt := sf.f(mt.x.Droplets[i]) newt := sf.f(mt.x.Droplets[i])
found.Vals[i] = timestamppb.New(newt) // convert to protobuf time found.Vals[i] = timestamppb.New(newt) // convert to protobuf time
} }
log.Info("virtpb: ending", name, found.Vals) // log.Info("virtpb: ending", name, found.Vals)
return true return true
} }
return false return false