Commit b6d6a71c authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

builder/openstack: wait for more states

parent 48b674d3
...@@ -28,7 +28,7 @@ type StateChangeConf struct { ...@@ -28,7 +28,7 @@ type StateChangeConf struct {
Pending []string Pending []string
Refresh StateRefreshFunc Refresh StateRefreshFunc
StepState multistep.StateBag StepState multistep.StateBag
Target string Target []string
} }
// ServerStateRefreshFunc returns a StateRefreshFunc that is used to watch // ServerStateRefreshFunc returns a StateRefreshFunc that is used to watch
...@@ -65,9 +65,11 @@ func WaitForState(conf *StateChangeConf) (i interface{}, err error) { ...@@ -65,9 +65,11 @@ func WaitForState(conf *StateChangeConf) (i interface{}, err error) {
return return
} }
if currentState == conf.Target { for _, t := range conf.Target {
if currentState == t {
return return
} }
}
if conf.StepState != nil { if conf.StepState != nil {
if _, ok := conf.StepState.GetOk(multistep.StateCancelled); ok { if _, ok := conf.StepState.GetOk(multistep.StateCancelled); ok {
......
...@@ -65,7 +65,7 @@ func (s *StepRunSourceServer) Run(state multistep.StateBag) multistep.StepAction ...@@ -65,7 +65,7 @@ func (s *StepRunSourceServer) Run(state multistep.StateBag) multistep.StepAction
ui.Say("Waiting for server to become ready...") ui.Say("Waiting for server to become ready...")
stateChange := StateChangeConf{ stateChange := StateChangeConf{
Pending: []string{"BUILD"}, Pending: []string{"BUILD"},
Target: "ACTIVE", Target: []string{"ACTIVE"},
Refresh: ServerStateRefreshFunc(computeClient, s.server), Refresh: ServerStateRefreshFunc(computeClient, s.server),
StepState: state, StepState: state,
} }
...@@ -105,9 +105,9 @@ func (s *StepRunSourceServer) Cleanup(state multistep.StateBag) { ...@@ -105,9 +105,9 @@ func (s *StepRunSourceServer) Cleanup(state multistep.StateBag) {
} }
stateChange := StateChangeConf{ stateChange := StateChangeConf{
Pending: []string{"ACTIVE", "BUILD", "REBUILD", "SUSPENDED"}, Pending: []string{"ACTIVE", "BUILD", "REBUILD", "SUSPENDED", "SHUTOFF", "STOPPED"},
Refresh: ServerStateRefreshFunc(computeClient, s.server), Refresh: ServerStateRefreshFunc(computeClient, s.server),
Target: "DELETED", Target: []string{"DELETED"},
} }
WaitForState(&stateChange) WaitForState(&stateChange)
......
...@@ -41,7 +41,7 @@ func (s *StepStopServer) Run(state multistep.StateBag) multistep.StepAction { ...@@ -41,7 +41,7 @@ func (s *StepStopServer) Run(state multistep.StateBag) multistep.StepAction {
ui.Message("Waiting for server to stop...") ui.Message("Waiting for server to stop...")
stateChange := StateChangeConf{ stateChange := StateChangeConf{
Pending: []string{"ACTIVE"}, Pending: []string{"ACTIVE"},
Target: "STOPPED", Target: []string{"SHUTOFF", "STOPPED"},
Refresh: ServerStateRefreshFunc(client, server), Refresh: ServerStateRefreshFunc(client, server),
StepState: state, StepState: state,
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment