diff --git a/Makefile b/Makefile index dea0e61..4fd4f3d 100644 --- a/Makefile +++ b/Makefile @@ -10,8 +10,8 @@ all: install @echo build worked virtigo list droplets virtigo list droplets --on - virtigo droplet show --name coriolis - virtigo droplet start --name coriolis + virtigo droplet show --name check.lab.wit.org + virtigo droplet start --name check.lab.wit.org build: goimports vet GO111MODULE=off go build \ diff --git a/doAdminGui.go b/doAdminGui.go index 6418d9b..544ee06 100644 --- a/doAdminGui.go +++ b/doAdminGui.go @@ -290,6 +290,8 @@ func (admin *adminT) makeClusterGroup(c *virtpb.Cluster) { if admin.cluster == nil { admin.cluster = new(virtpb.Cluster) + admin.cluster.Name = c.Name + admin.cluster.Uuid = c.Uuid } name := c.GetName() @@ -355,7 +357,7 @@ func (admin *adminT) makeClusterGroup(c *virtpb.Cluster) { }) grid.NewButton("save cluster.pb", func() { - admin.refresh() + admin.cluster.ConfigSave() }) } @@ -404,6 +406,9 @@ func (admin *adminT) postEvent(e *virtpb.Event) error { return err } } - log.Printf("Event type: %s\n", result.DropletUuid) + if result.Error != "" { + return fmt.Errorf(result.Error) + } + log.Printf("Event worked: %s\n", result.DropletUuid) return nil } diff --git a/doDroplet.go b/doDroplet.go index 38d9903..89e88e7 100644 --- a/doDroplet.go +++ b/doDroplet.go @@ -106,6 +106,9 @@ func doEvent(e *virtpb.Event) *virtpb.Event { rs, err := Start(e.DropletUuid) log.Println("Start() returned", rs) log.Println("Start() returned err", err) + if err != nil { + result.Error = fmt.Sprintf("%v", err) + } } return result diff --git a/doList.go b/doList.go index 7a65650..289639f 100644 --- a/doList.go +++ b/doList.go @@ -58,6 +58,9 @@ func doList() { all := admin.cluster.Droplets.All() for all.Scan() { vm := all.Next() + if vm.Current == nil { + continue + } if argv.List.On && (vm.Current.State == virtpb.DropletState_OFF) { continue } diff --git a/start.go b/start.go index e5bf0fd..a7cf493 100644 --- a/start.go +++ b/start.go @@ -38,7 +38,7 @@ func Start(id string) (string, error) { } // lookup the droplet by name - d := me.cluster.FindDropletByName(id) + d := me.cluster.FindDropletByUuid(id) if d == nil { result = "can't start unknown droplet: " + id return result, errors.New(result) @@ -51,10 +51,15 @@ func Start(id string) (string, error) { return result, err } - // is the droplet already on? - if d.Current.State == virtpb.DropletState_ON { - result = "EVENT start droplet " + d.Hostname + " is already ON" - return result, errors.New(result) + if d.Current == nil { + // result = d.Hostname + " d.Current == nil" + // return result, errors.New(result) + + // is the droplet already on? + if d.Current.State == virtpb.DropletState_ON { + result = "EVENT start droplet " + d.Hostname + " is already ON" + return result, errors.New(result) + } } // make the list of hypervisors that are active and can start new droplets