diff --git a/control b/control index cc3a129..6ddbba6 100644 --- a/control +++ b/control @@ -4,7 +4,7 @@ Package: virtigo Maintainer: Jeff Carr Architecture: amd64 Recommends: virtigod -Depends: +Depends: gus remmina remmina-plugin-spice URL: https://go.wit.com/apps/virtigo Description: control your virtual machines in your cluster lets you start,stop, etc virtual machines diff --git a/doAdminGui.go b/doAdminGui.go index 77f30bf..e7cdf48 100644 --- a/doAdminGui.go +++ b/doAdminGui.go @@ -108,18 +108,22 @@ func (admin *adminT) doAdminGui() { return } log.Info("Hypervisors len=", admin.hypervisors.Len()) - hwin := newHypervisorsWindow() - hwin.doStdHypervisors(admin.hypervisors) - hwin.win.Custom = func() { + admin.hwin = newHypervisorsWindow() + admin.hwin.doStdHypervisors(admin.hypervisors) + admin.hwin.win.Custom = func() { log.Info("hiding table window") } }) - grid.NewButton("show active droplets", func() { + grid.NewButton("droplets", func() { if admin.droplets == nil { log.Info("droplets not initialized") return } + admin.dwin = newDropletsWindow() + admin.dwin.win.Custom = func() { + log.Info("hiding droplet table window") + } var found *virtpb.Droplets found = virtpb.NewDroplets() all := admin.droplets.All() @@ -130,33 +134,7 @@ func (admin *adminT) doAdminGui() { } found.Append(vm) } - dropWin := newDropletsWindow() - 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") - } + admin.dwin.doActiveDroplets(found) }) grid.NewButton("events", func() { @@ -165,9 +143,9 @@ func (admin *adminT) doAdminGui() { return } log.Info("Events len=", admin.events.Len()) - hwin := newEventsWindow() - hwin.doStdEvents(admin.events) - hwin.win.Custom = func() { + admin.ewin = newEventsWindow() + admin.ewin.doStdEvents(admin.events) + admin.ewin.win.Custom = func() { log.Info("hiding table window") } }) diff --git a/structs.go b/structs.go index 33708c3..e5cb9c0 100644 --- a/structs.go +++ b/structs.go @@ -41,10 +41,13 @@ type virtigoT struct { type adminT struct { // admin mode - droplets *virtpb.Droplets // your droplets - hypervisors *virtpb.Hypervisors // yep - events *virtpb.Events // yep - uptime *gui.Node // the uptime message + droplets *virtpb.Droplets // your droplets + hypervisors *virtpb.Hypervisors // yep + events *virtpb.Events // yep + 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 diff --git a/windowDroplets.go b/windowDroplets.go index 6d2e71b..09c2d18 100644 --- a/windowDroplets.go +++ b/windowDroplets.go @@ -22,6 +22,7 @@ type stdDropletTableWin struct { pb *virtpb.Droplets // the droplets protobuf TB *virtpb.DropletsTable // the gui table buffer update bool // if the window should be updated + Close func() // this function is called when the window is closed } func (w *stdDropletTableWin) Toggle() { @@ -36,10 +37,39 @@ func (w *stdDropletTableWin) Toggle() { func newDropletsWindow() *stdDropletTableWin { dwin := new(stdDropletTableWin) - dwin.win = gadgets.NewGenericWindow("virtigo current droplets", "") + dwin.win = gadgets.NewGenericWindow("virtigo current droplets", "Options") dwin.win.Custom = func() { 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 dwin.box = dwin.win.Bottom.Box().SetProgName("TBOX") diff --git a/windowHypervisors.go b/windowHypervisors.go index 4db757b..31da9f6 100644 --- a/windowHypervisors.go +++ b/windowHypervisors.go @@ -5,6 +5,7 @@ package main import ( "sync" + "time" "go.wit.com/gui" "go.wit.com/lib/gadgets" @@ -64,6 +65,33 @@ func (dw *stdHypervisorTableWin) doStdHypervisors(pb *virtpb.Hypervisors) { t.AddHostname() t.AddMemory() 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 dw.TB = t