fixes to the admin tables
This commit is contained in:
parent
50d16b3d86
commit
599fe4251f
2
control
2
control
|
@ -4,7 +4,7 @@ Package: virtigo
|
||||||
Maintainer: Jeff Carr <jcarr@wit.com>
|
Maintainer: Jeff Carr <jcarr@wit.com>
|
||||||
Architecture: amd64
|
Architecture: amd64
|
||||||
Recommends: virtigod
|
Recommends: virtigod
|
||||||
Depends:
|
Depends: gus remmina remmina-plugin-spice
|
||||||
URL: https://go.wit.com/apps/virtigo
|
URL: https://go.wit.com/apps/virtigo
|
||||||
Description: control your virtual machines in your cluster
|
Description: control your virtual machines in your cluster
|
||||||
lets you start,stop, etc virtual machines
|
lets you start,stop, etc virtual machines
|
||||||
|
|
|
@ -108,18 +108,22 @@ func (admin *adminT) doAdminGui() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Info("Hypervisors len=", admin.hypervisors.Len())
|
log.Info("Hypervisors len=", admin.hypervisors.Len())
|
||||||
hwin := newHypervisorsWindow()
|
admin.hwin = newHypervisorsWindow()
|
||||||
hwin.doStdHypervisors(admin.hypervisors)
|
admin.hwin.doStdHypervisors(admin.hypervisors)
|
||||||
hwin.win.Custom = func() {
|
admin.hwin.win.Custom = func() {
|
||||||
log.Info("hiding table window")
|
log.Info("hiding table window")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
grid.NewButton("show active droplets", func() {
|
grid.NewButton("droplets", func() {
|
||||||
if admin.droplets == nil {
|
if admin.droplets == nil {
|
||||||
log.Info("droplets not initialized")
|
log.Info("droplets not initialized")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
admin.dwin = newDropletsWindow()
|
||||||
|
admin.dwin.win.Custom = func() {
|
||||||
|
log.Info("hiding droplet table window")
|
||||||
|
}
|
||||||
var found *virtpb.Droplets
|
var found *virtpb.Droplets
|
||||||
found = virtpb.NewDroplets()
|
found = virtpb.NewDroplets()
|
||||||
all := admin.droplets.All()
|
all := admin.droplets.All()
|
||||||
|
@ -130,33 +134,7 @@ func (admin *adminT) doAdminGui() {
|
||||||
}
|
}
|
||||||
found.Append(vm)
|
found.Append(vm)
|
||||||
}
|
}
|
||||||
dropWin := newDropletsWindow()
|
admin.dwin.doActiveDroplets(found)
|
||||||
dropWin.doActiveDroplets(found)
|
|
||||||
dropWin.win.Custom = func() {
|
|
||||||
log.Info("hiding droplet table window")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
grid.NewButton("inactive droplets", func() {
|
|
||||||
if admin.droplets == nil {
|
|
||||||
log.Info("droplets not initialized")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
var found *virtpb.Droplets
|
|
||||||
found = virtpb.NewDroplets()
|
|
||||||
all := admin.droplets.All()
|
|
||||||
for all.Scan() {
|
|
||||||
vm := all.Next()
|
|
||||||
if vm.Current.State == virtpb.DropletState_ON {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
found.Append(vm)
|
|
||||||
}
|
|
||||||
dropWin := newDropletsWindow()
|
|
||||||
dropWin.doInactiveDroplets(found)
|
|
||||||
dropWin.win.Custom = func() {
|
|
||||||
log.Info("hiding droplet table window")
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
grid.NewButton("events", func() {
|
grid.NewButton("events", func() {
|
||||||
|
@ -165,9 +143,9 @@ func (admin *adminT) doAdminGui() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Info("Events len=", admin.events.Len())
|
log.Info("Events len=", admin.events.Len())
|
||||||
hwin := newEventsWindow()
|
admin.ewin = newEventsWindow()
|
||||||
hwin.doStdEvents(admin.events)
|
admin.ewin.doStdEvents(admin.events)
|
||||||
hwin.win.Custom = func() {
|
admin.ewin.win.Custom = func() {
|
||||||
log.Info("hiding table window")
|
log.Info("hiding table window")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
11
structs.go
11
structs.go
|
@ -41,10 +41,13 @@ type virtigoT struct {
|
||||||
|
|
||||||
type adminT struct {
|
type adminT struct {
|
||||||
// admin mode
|
// admin mode
|
||||||
droplets *virtpb.Droplets // your droplets
|
droplets *virtpb.Droplets // your droplets
|
||||||
hypervisors *virtpb.Hypervisors // yep
|
hypervisors *virtpb.Hypervisors // yep
|
||||||
events *virtpb.Events // yep
|
events *virtpb.Events // yep
|
||||||
uptime *gui.Node // the uptime message
|
uptime *gui.Node // the uptime message
|
||||||
|
dwin *stdDropletTableWin // the droplet window
|
||||||
|
hwin *stdHypervisorTableWin // the hypervisor window
|
||||||
|
ewin *stdEventTableWin // the events window
|
||||||
}
|
}
|
||||||
|
|
||||||
// the stuff that is needed for a hypervisor
|
// the stuff that is needed for a hypervisor
|
||||||
|
|
|
@ -22,6 +22,7 @@ type stdDropletTableWin struct {
|
||||||
pb *virtpb.Droplets // the droplets protobuf
|
pb *virtpb.Droplets // the droplets protobuf
|
||||||
TB *virtpb.DropletsTable // the gui table buffer
|
TB *virtpb.DropletsTable // the gui table buffer
|
||||||
update bool // if the window should be updated
|
update bool // if the window should be updated
|
||||||
|
Close func() // this function is called when the window is closed
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *stdDropletTableWin) Toggle() {
|
func (w *stdDropletTableWin) Toggle() {
|
||||||
|
@ -36,10 +37,39 @@ func (w *stdDropletTableWin) Toggle() {
|
||||||
|
|
||||||
func newDropletsWindow() *stdDropletTableWin {
|
func newDropletsWindow() *stdDropletTableWin {
|
||||||
dwin := new(stdDropletTableWin)
|
dwin := new(stdDropletTableWin)
|
||||||
dwin.win = gadgets.NewGenericWindow("virtigo current droplets", "")
|
dwin.win = gadgets.NewGenericWindow("virtigo current droplets", "Options")
|
||||||
dwin.win.Custom = func() {
|
dwin.win.Custom = func() {
|
||||||
log.Info("test delete window here")
|
log.Info("test delete window here")
|
||||||
}
|
}
|
||||||
|
grid := dwin.win.Group.RawGrid()
|
||||||
|
|
||||||
|
grid.NewButton("Active", func() {
|
||||||
|
var found *virtpb.Droplets
|
||||||
|
found = virtpb.NewDroplets()
|
||||||
|
all := me.admin.droplets.All()
|
||||||
|
for all.Scan() {
|
||||||
|
vm := all.Next()
|
||||||
|
if vm.Current.State != virtpb.DropletState_ON {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
found.Append(vm)
|
||||||
|
}
|
||||||
|
dwin.doActiveDroplets(found)
|
||||||
|
})
|
||||||
|
|
||||||
|
grid.NewButton("Inactive", func() {
|
||||||
|
var found *virtpb.Droplets
|
||||||
|
found = virtpb.NewDroplets()
|
||||||
|
all := me.admin.droplets.All()
|
||||||
|
for all.Scan() {
|
||||||
|
vm := all.Next()
|
||||||
|
if vm.Current.State == virtpb.DropletState_ON {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
found.Append(vm)
|
||||||
|
}
|
||||||
|
dwin.doInactiveDroplets(found)
|
||||||
|
})
|
||||||
|
|
||||||
// make a box at the bottom of the window for the protobuf table
|
// make a box at the bottom of the window for the protobuf table
|
||||||
dwin.box = dwin.win.Bottom.Box().SetProgName("TBOX")
|
dwin.box = dwin.win.Bottom.Box().SetProgName("TBOX")
|
||||||
|
|
|
@ -5,6 +5,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
"go.wit.com/gui"
|
"go.wit.com/gui"
|
||||||
"go.wit.com/lib/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
|
@ -64,6 +65,33 @@ func (dw *stdHypervisorTableWin) doStdHypervisors(pb *virtpb.Hypervisors) {
|
||||||
t.AddHostname()
|
t.AddHostname()
|
||||||
t.AddMemory()
|
t.AddMemory()
|
||||||
t.AddCpus()
|
t.AddCpus()
|
||||||
|
t.AddKillcount()
|
||||||
|
t.AddTimeFunc("last poll", func(h *virtpb.Hypervisor) time.Time {
|
||||||
|
// hm := me.hmap[h]
|
||||||
|
// tmp := hm.lastpoll
|
||||||
|
// log.Info("poll age", h.Hostname, virtpb.FormatDuration(time.Since(tmp)))
|
||||||
|
return time.Now()
|
||||||
|
})
|
||||||
|
t.AddStringFunc("droplets", func(h *virtpb.Hypervisor) string {
|
||||||
|
/*
|
||||||
|
var totalDroplets int
|
||||||
|
var totalUnknownDroplets int
|
||||||
|
// dur := time.Since(h.lastpoll)
|
||||||
|
// tmp := virtpb.FormatDuration(dur)
|
||||||
|
// fmt.Fprintln(w, h.pb.Hostname, "killcount =", h.killcount, "lastpoll:", tmp)
|
||||||
|
hm := me.hmap[h]
|
||||||
|
for name, _ := range hm.lastDroplets {
|
||||||
|
totalDroplets += 1
|
||||||
|
d := me.cluster.FindDropletByName(name)
|
||||||
|
if d == nil {
|
||||||
|
totalUnknownDroplets += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.Printf("Total Droplets %d total libvirt only droplets = %d\n", totalDroplets, totalUnknownDroplets)
|
||||||
|
return fmt.Sprintf("%d", totalDroplets)
|
||||||
|
*/
|
||||||
|
return "todo"
|
||||||
|
})
|
||||||
|
|
||||||
// display the protobuf
|
// display the protobuf
|
||||||
dw.TB = t
|
dw.TB = t
|
||||||
|
|
Loading…
Reference in New Issue