move everything into cluster protobuf
This commit is contained in:
parent
d3f809b25d
commit
a4dd085a47
|
@ -73,12 +73,12 @@ func (admin *adminT) refresh() {
|
||||||
log.Info("Error:", err)
|
log.Info("Error:", err)
|
||||||
} else {
|
} else {
|
||||||
fmt.Println("EventsPB Response len:", len(data))
|
fmt.Println("EventsPB Response len:", len(data))
|
||||||
admin.events = new(virtpb.Events)
|
admin.cluster.Events = new(virtpb.Events)
|
||||||
if err := admin.events.Unmarshal(data); err != nil {
|
if err := admin.cluster.Events.Unmarshal(data); err != nil {
|
||||||
fmt.Println("events marshal failed", err)
|
fmt.Println("events marshal failed", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Println("Events len=", admin.events.Len())
|
fmt.Println("Events len=", admin.cluster.Events.Len())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,13 +127,13 @@ func doLocalhostAdminGui() *adminT {
|
||||||
})
|
})
|
||||||
|
|
||||||
grid.NewButton("events", func() {
|
grid.NewButton("events", func() {
|
||||||
if admin.events == nil {
|
if admin.cluster.Events == nil {
|
||||||
log.Info("events are not initialized")
|
log.Info("events are not initialized")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Info("Events len=", admin.events.Len())
|
log.Info("Events len=", admin.cluster.Events.Len())
|
||||||
admin.ewin = newEventsWindow()
|
admin.ewin = newEventsWindow()
|
||||||
admin.ewin.doStdEvents(admin.events)
|
admin.ewin.doStdEvents(admin.cluster.Events)
|
||||||
admin.ewin.win.Custom = func() {
|
admin.ewin.win.Custom = func() {
|
||||||
log.Info("hiding table window")
|
log.Info("hiding table window")
|
||||||
}
|
}
|
||||||
|
@ -148,6 +148,41 @@ func doLocalhostAdminGui() *adminT {
|
||||||
return admin
|
return admin
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func doAdminGui() {
|
||||||
|
me.myGui = gui.New()
|
||||||
|
me.myGui.InitEmbed(resources)
|
||||||
|
me.myGui.Default()
|
||||||
|
|
||||||
|
// Initialize a persistent client with a custom Transport
|
||||||
|
client = &http.Client{
|
||||||
|
Transport: &http.Transport{
|
||||||
|
DisableKeepAlives: false, // Ensure Keep-Alive is enabled
|
||||||
|
},
|
||||||
|
Timeout: 10 * time.Second, // Set a reasonable timeout
|
||||||
|
}
|
||||||
|
|
||||||
|
me.gwin = gadgets.NewGenericWindow("Virtigo: (run your cluster)", "")
|
||||||
|
me.gwin.Custom = func() {
|
||||||
|
log.Warn("Main window close")
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
me.cmap = make(map[*virtpb.Cluster]*adminT)
|
||||||
|
for c := range me.clusters.IterAll() {
|
||||||
|
a := new(adminT)
|
||||||
|
me.cmap[c] = a
|
||||||
|
log.Info("found in the config file", c.URL[0])
|
||||||
|
a.makeClusterGroup(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// sit here forever refreshing the GUI
|
||||||
|
for {
|
||||||
|
// admin.refresh()
|
||||||
|
log.Info("todo: refresh() protobufs here")
|
||||||
|
time.Sleep(90 * time.Second)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (admin *adminT) doAdminGui() {
|
func (admin *adminT) doAdminGui() {
|
||||||
me.myGui = gui.New()
|
me.myGui = gui.New()
|
||||||
me.myGui.InitEmbed(resources)
|
me.myGui.InitEmbed(resources)
|
||||||
|
@ -208,13 +243,13 @@ func (admin *adminT) doAdminGui() {
|
||||||
})
|
})
|
||||||
|
|
||||||
grid.NewButton("events", func() {
|
grid.NewButton("events", func() {
|
||||||
if admin.events == nil {
|
if admin.cluster.Events == nil {
|
||||||
log.Info("events are not initialized")
|
log.Info("events are not initialized")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Info("Events len=", admin.events.Len())
|
log.Info("Events len=", admin.cluster.Events.Len())
|
||||||
admin.ewin = newEventsWindow()
|
admin.ewin = newEventsWindow()
|
||||||
admin.ewin.doStdEvents(admin.events)
|
admin.ewin.doStdEvents(admin.cluster.Events)
|
||||||
admin.ewin.win.Custom = func() {
|
admin.ewin.win.Custom = func() {
|
||||||
log.Info("hiding table window")
|
log.Info("hiding table window")
|
||||||
}
|
}
|
||||||
|
@ -253,6 +288,10 @@ func (admin *adminT) makeClusterGroup(c *virtpb.Cluster) {
|
||||||
badExit(err)
|
badExit(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if admin.cluster == nil {
|
||||||
|
admin.cluster = new(virtpb.Cluster)
|
||||||
|
}
|
||||||
|
|
||||||
name := c.GetName()
|
name := c.GetName()
|
||||||
if name == "" {
|
if name == "" {
|
||||||
name = admin.url.Hostname()
|
name = admin.url.Hostname()
|
||||||
|
@ -299,17 +338,25 @@ func (admin *adminT) makeClusterGroup(c *virtpb.Cluster) {
|
||||||
})
|
})
|
||||||
|
|
||||||
grid.NewButton("events", func() {
|
grid.NewButton("events", func() {
|
||||||
if admin.events == nil {
|
if admin.cluster.Events == nil {
|
||||||
log.Info("events are not initialized")
|
log.Info("events are not initialized")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Info("Events len=", admin.events.Len())
|
log.Info("Events len=", admin.cluster.Events.Len())
|
||||||
admin.ewin = newEventsWindow()
|
admin.ewin = newEventsWindow()
|
||||||
admin.ewin.doStdEvents(admin.events)
|
admin.ewin.doStdEvents(admin.cluster.Events)
|
||||||
admin.ewin.win.Custom = func() {
|
admin.ewin.win.Custom = func() {
|
||||||
log.Info("hiding table window")
|
log.Info("hiding table window")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
grid.NewButton("refresh", func() {
|
||||||
|
admin.refresh()
|
||||||
|
})
|
||||||
|
|
||||||
|
grid.NewButton("save cluster.pb", func() {
|
||||||
|
admin.refresh()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func postData(url string, data []byte) ([]byte, error) {
|
func postData(url string, data []byte) ([]byte, error) {
|
||||||
|
|
3
main.go
3
main.go
|
@ -70,8 +70,7 @@ func main() {
|
||||||
badExit(err)
|
badExit(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
me.admin = new(adminT)
|
doAdminGui()
|
||||||
me.admin.doAdminGui()
|
|
||||||
okExit("admin close")
|
okExit("admin close")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
17
structs.go
17
structs.go
|
@ -48,14 +48,15 @@ type virtigoT struct {
|
||||||
|
|
||||||
type adminT struct {
|
type adminT struct {
|
||||||
// admin mode
|
// admin mode
|
||||||
droplets *virtpb.Droplets // your droplets
|
cluster *virtpb.Cluster // the cluster protobuf
|
||||||
hypervisors *virtpb.Hypervisors // yep
|
droplets *virtpb.Droplets // your droplets
|
||||||
events *virtpb.Events // yep
|
hypervisors *virtpb.Hypervisors // yep
|
||||||
uptime *gui.Node // the uptime message
|
// events *virtpb.Events // yep
|
||||||
dwin *stdDropletTableWin // the droplet window
|
uptime *gui.Node // the uptime message
|
||||||
hwin *stdHypervisorTableWin // the hypervisor window
|
dwin *stdDropletTableWin // the droplet window
|
||||||
ewin *stdEventTableWin // the events window
|
hwin *stdHypervisorTableWin // the hypervisor window
|
||||||
url *url.URL // URL for the cloud
|
ewin *stdEventTableWin // the events window
|
||||||
|
url *url.URL // URL for the cloud
|
||||||
}
|
}
|
||||||
|
|
||||||
// the stuff that is needed for a hypervisor
|
// the stuff that is needed for a hypervisor
|
||||||
|
|
Loading…
Reference in New Issue