attempting the cluster protobuf
This commit is contained in:
parent
a4dd085a47
commit
4121e66e01
|
@ -47,12 +47,12 @@ func (admin *adminT) refresh() {
|
|||
log.Info("/DropletsPB Error:", err)
|
||||
} else {
|
||||
fmt.Println("DropletsPB Response len:", len(data))
|
||||
admin.droplets = new(virtpb.Droplets)
|
||||
if err := admin.droplets.Unmarshal(data); err != nil {
|
||||
admin.cluster.Droplets = new(virtpb.Droplets)
|
||||
if err := admin.cluster.Droplets.Unmarshal(data); err != nil {
|
||||
fmt.Println("droplets marshal failed", err)
|
||||
return
|
||||
}
|
||||
fmt.Println("Droplet len=", admin.droplets.Len())
|
||||
fmt.Println("Droplet len=", admin.cluster.Droplets.Len())
|
||||
}
|
||||
|
||||
// update the hypervisor list
|
||||
|
@ -60,12 +60,12 @@ func (admin *adminT) refresh() {
|
|||
log.Info("Error:", err)
|
||||
} else {
|
||||
fmt.Println("HypervisorsPB Response len:", len(data))
|
||||
admin.hypervisors = new(virtpb.Hypervisors)
|
||||
if err := admin.hypervisors.Unmarshal(data); err != nil {
|
||||
admin.cluster.Hypervisors = new(virtpb.Hypervisors)
|
||||
if err := admin.cluster.Hypervisors.Unmarshal(data); err != nil {
|
||||
fmt.Println("hypervisors marshal failed", err)
|
||||
return
|
||||
}
|
||||
fmt.Println("Hypervisors len=", admin.hypervisors.Len())
|
||||
fmt.Println("Hypervisors len=", admin.cluster.Hypervisors.Len())
|
||||
}
|
||||
|
||||
// update the events list
|
||||
|
@ -92,20 +92,20 @@ func doLocalhostAdminGui() *adminT {
|
|||
grid := me.gwin.Group.RawGrid()
|
||||
|
||||
grid.NewButton("show hypervisors", func() {
|
||||
if admin.hypervisors == nil {
|
||||
if admin.cluster.Hypervisors == nil {
|
||||
log.Info("hypervisors not initialized")
|
||||
return
|
||||
}
|
||||
log.Info("Hypervisors len=", admin.hypervisors.Len())
|
||||
log.Info("Hypervisors len=", admin.cluster.Hypervisors.Len())
|
||||
admin.hwin = newHypervisorsWindow()
|
||||
admin.hwin.doStdHypervisors(admin.hypervisors)
|
||||
admin.hwin.doStdHypervisors(admin.cluster.Hypervisors)
|
||||
admin.hwin.win.Custom = func() {
|
||||
log.Info("hiding table window")
|
||||
}
|
||||
})
|
||||
|
||||
grid.NewButton("droplets", func() {
|
||||
if admin.droplets == nil {
|
||||
if admin.cluster.Droplets == nil {
|
||||
log.Info("droplets not initialized")
|
||||
return
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ func doLocalhostAdminGui() *adminT {
|
|||
}
|
||||
var found *virtpb.Droplets
|
||||
found = virtpb.NewDroplets()
|
||||
all := admin.droplets.All()
|
||||
all := admin.cluster.Droplets.All()
|
||||
for all.Scan() {
|
||||
vm := all.Next()
|
||||
if vm.Current.State != virtpb.DropletState_ON {
|
||||
|
@ -208,20 +208,20 @@ func (admin *adminT) doAdminGui() {
|
|||
grid := win.Group.RawGrid()
|
||||
|
||||
grid.NewButton("show hypervisors", func() {
|
||||
if admin.hypervisors == nil {
|
||||
if admin.cluster.Hypervisors == nil {
|
||||
log.Info("hypervisors not initialized")
|
||||
return
|
||||
}
|
||||
log.Info("Hypervisors len=", admin.hypervisors.Len())
|
||||
log.Info("Hypervisors len=", admin.cluster.Hypervisors.Len())
|
||||
admin.hwin = newHypervisorsWindow()
|
||||
admin.hwin.doStdHypervisors(admin.hypervisors)
|
||||
admin.hwin.doStdHypervisors(admin.cluster.Hypervisors)
|
||||
admin.hwin.win.Custom = func() {
|
||||
log.Info("hiding table window")
|
||||
}
|
||||
})
|
||||
|
||||
grid.NewButton("droplets", func() {
|
||||
if admin.droplets == nil {
|
||||
if admin.cluster.Droplets == nil {
|
||||
log.Info("droplets not initialized")
|
||||
return
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ func (admin *adminT) doAdminGui() {
|
|||
}
|
||||
var found *virtpb.Droplets
|
||||
found = virtpb.NewDroplets()
|
||||
all := admin.droplets.All()
|
||||
all := admin.cluster.Droplets.All()
|
||||
for all.Scan() {
|
||||
vm := all.Next()
|
||||
if vm.Current.State != virtpb.DropletState_ON {
|
||||
|
@ -303,20 +303,20 @@ func (admin *adminT) makeClusterGroup(c *virtpb.Cluster) {
|
|||
grid := group.RawGrid()
|
||||
|
||||
grid.NewButton("show hypervisors", func() {
|
||||
if admin.hypervisors == nil {
|
||||
if admin.cluster.Hypervisors == nil {
|
||||
log.Info("hypervisors not initialized")
|
||||
return
|
||||
}
|
||||
log.Info("Hypervisors len=", admin.hypervisors.Len())
|
||||
log.Info("Hypervisors len=", admin.cluster.Hypervisors.Len())
|
||||
admin.hwin = newHypervisorsWindow()
|
||||
admin.hwin.doStdHypervisors(admin.hypervisors)
|
||||
admin.hwin.doStdHypervisors(admin.cluster.Hypervisors)
|
||||
admin.hwin.win.Custom = func() {
|
||||
log.Info("hiding table window")
|
||||
}
|
||||
})
|
||||
|
||||
grid.NewButton("droplets", func() {
|
||||
if admin.droplets == nil {
|
||||
if admin.cluster.Droplets == nil {
|
||||
log.Info("droplets not initialized")
|
||||
return
|
||||
}
|
||||
|
@ -326,7 +326,7 @@ func (admin *adminT) makeClusterGroup(c *virtpb.Cluster) {
|
|||
}
|
||||
var found *virtpb.Droplets
|
||||
found = virtpb.NewDroplets()
|
||||
all := admin.droplets.All()
|
||||
all := admin.cluster.Droplets.All()
|
||||
for all.Scan() {
|
||||
vm := all.Next()
|
||||
if vm.Current.State != virtpb.DropletState_ON {
|
||||
|
|
11
doDroplet.go
11
doDroplet.go
|
@ -35,6 +35,9 @@ func doDroplet() (string, error) {
|
|||
for c := range me.clusters.IterAll() {
|
||||
var err error
|
||||
admin := new(adminT)
|
||||
if admin.cluster == nil {
|
||||
admin.cluster = new(virtpb.Cluster)
|
||||
}
|
||||
me.cmap[c] = admin
|
||||
log.Info("found in the config file", c.URL[0])
|
||||
// a.makeClusterGroup(c)
|
||||
|
@ -48,15 +51,15 @@ func doDroplet() (string, error) {
|
|||
log.Info("/DropletsPB Error:", err)
|
||||
continue
|
||||
} else {
|
||||
admin.droplets = new(virtpb.Droplets)
|
||||
if err := admin.droplets.Unmarshal(data); err != nil {
|
||||
admin.cluster.Droplets = new(virtpb.Droplets)
|
||||
if err := admin.cluster.Droplets.Unmarshal(data); err != nil {
|
||||
log.Printf("DropletsPB Response len:%d\n", len(data))
|
||||
log.Println("droplets marshal failed", err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
log.Printf("Cluster Name: %s\n", c.Name)
|
||||
log.Printf("Number of Droplets: %d\n", admin.droplets.Len())
|
||||
log.Printf("Number of Droplets: %d\n", admin.cluster.Droplets.Len())
|
||||
|
||||
if argv.Droplet.Name == "" {
|
||||
return "", fmt.Errorf("--name droplet name was empty")
|
||||
|
@ -64,7 +67,7 @@ func doDroplet() (string, error) {
|
|||
|
||||
var found *virtpb.Droplets
|
||||
found = virtpb.NewDroplets()
|
||||
all := admin.droplets.All()
|
||||
all := admin.cluster.Droplets.All()
|
||||
for all.Scan() {
|
||||
vm := all.Next()
|
||||
if argv.Droplet.Name == vm.Hostname {
|
||||
|
|
|
@ -29,6 +29,7 @@ func doList() {
|
|||
for c := range me.clusters.IterAll() {
|
||||
var err error
|
||||
admin := new(adminT)
|
||||
admin.cluster = new(virtpb.Cluster)
|
||||
me.cmap[c] = admin
|
||||
log.Info("found in the config file", c.URL[0])
|
||||
// a.makeClusterGroup(c)
|
||||
|
@ -42,19 +43,19 @@ func doList() {
|
|||
log.Info("/DropletsPB Error:", err)
|
||||
continue
|
||||
} else {
|
||||
admin.droplets = new(virtpb.Droplets)
|
||||
if err := admin.droplets.Unmarshal(data); err != nil {
|
||||
admin.cluster.Droplets = new(virtpb.Droplets)
|
||||
if err := admin.cluster.Droplets.Unmarshal(data); err != nil {
|
||||
log.Printf("DropletsPB Response len:%d\n", len(data))
|
||||
log.Println("droplets marshal failed", err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
log.Printf("Cluster Name: %s\n", c.Name)
|
||||
log.Printf("Number of Droplets: %d\n", admin.droplets.Len())
|
||||
log.Printf("Number of Droplets: %d\n", admin.cluster.Droplets.Len())
|
||||
|
||||
var found *virtpb.Droplets
|
||||
found = virtpb.NewDroplets()
|
||||
all := admin.droplets.All()
|
||||
all := admin.cluster.Droplets.All()
|
||||
for all.Scan() {
|
||||
vm := all.Next()
|
||||
if argv.List.On && (vm.Current.State == virtpb.DropletState_OFF) {
|
||||
|
|
17
structs.go
17
structs.go
|
@ -46,17 +46,14 @@ type virtigoT struct {
|
|||
gwin *gadgets.GenericWindow // main window
|
||||
}
|
||||
|
||||
// cluster "admin" mode
|
||||
type adminT struct {
|
||||
// admin mode
|
||||
cluster *virtpb.Cluster // the cluster protobuf
|
||||
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
|
||||
url *url.URL // URL for the cloud
|
||||
cluster *virtpb.Cluster // the cluster protobuf
|
||||
uptime *gui.Node // the uptime message
|
||||
dwin *stdDropletTableWin // the droplet window
|
||||
hwin *stdHypervisorTableWin // the hypervisor window
|
||||
ewin *stdEventTableWin // the events window
|
||||
url *url.URL // URL for the cloud
|
||||
}
|
||||
|
||||
// the stuff that is needed for a hypervisor
|
||||
|
|
|
@ -46,7 +46,7 @@ func newDropletsWindow() *stdDropletTableWin {
|
|||
grid.NewButton("Active", func() {
|
||||
var found *virtpb.Droplets
|
||||
found = virtpb.NewDroplets()
|
||||
all := me.admin.droplets.All()
|
||||
all := me.admin.cluster.Droplets.All()
|
||||
for all.Scan() {
|
||||
vm := all.Next()
|
||||
if vm.Current.State != virtpb.DropletState_ON {
|
||||
|
@ -60,7 +60,7 @@ func newDropletsWindow() *stdDropletTableWin {
|
|||
grid.NewButton("Inactive", func() {
|
||||
var found *virtpb.Droplets
|
||||
found = virtpb.NewDroplets()
|
||||
all := me.admin.droplets.All()
|
||||
all := me.admin.cluster.Droplets.All()
|
||||
for all.Scan() {
|
||||
vm := all.Next()
|
||||
if vm.Current.State == virtpb.DropletState_ON {
|
||||
|
|
Loading…
Reference in New Issue