droplet start worked

This commit is contained in:
Jeff Carr 2025-04-21 20:43:59 -05:00
parent a24448a9d4
commit 2c5701eeca
5 changed files with 25 additions and 9 deletions

View File

@ -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 \

View File

@ -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
}

View File

@ -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

View File

@ -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
}

View File

@ -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