Skip to content

Commit

Permalink
Consider VM state as well
Browse files Browse the repository at this point in the history
  • Loading branch information
kayrus committed Jun 10, 2021
1 parent 28ac855 commit e1f7dae
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ type serverExtended struct {
extendedstatus.ServerExtendedStatusExt
}

var serverNormalStates = []string{
"active",
"stopped",
}

var serverNormalStatuses = []string{
"ACTIVE",
"SHUTOFF",
Expand Down Expand Up @@ -72,7 +77,7 @@ func waitForServer(client *gophercloud.ServiceClient, id string, secs float64) (
// this is needed, because if new data contains a "null", the struct will contain an old data, e.g. `"OS-EXT-STS:task_state": null`
server = tmp

if server.VmState != "active" {
if !isSliceContainsStr(serverNormalStates, server.VmState) {
if server.TaskState != "" {
log.Printf("Server status: %s (%s, %s)", server.Status, server.VmState, server.TaskState)
return false, nil
Expand Down

0 comments on commit e1f7dae

Please sign in to comment.