builder/openstack: wait for more states
This commit is contained in:
parent
48b674d331
commit
b6d6a71c6e
|
@ -28,7 +28,7 @@ type StateChangeConf struct {
|
|||
Pending []string
|
||||
Refresh StateRefreshFunc
|
||||
StepState multistep.StateBag
|
||||
Target string
|
||||
Target []string
|
||||
}
|
||||
|
||||
// ServerStateRefreshFunc returns a StateRefreshFunc that is used to watch
|
||||
|
@ -65,8 +65,10 @@ func WaitForState(conf *StateChangeConf) (i interface{}, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
if currentState == conf.Target {
|
||||
return
|
||||
for _, t := range conf.Target {
|
||||
if currentState == t {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if conf.StepState != nil {
|
||||
|
|
|
@ -65,7 +65,7 @@ func (s *StepRunSourceServer) Run(state multistep.StateBag) multistep.StepAction
|
|||
ui.Say("Waiting for server to become ready...")
|
||||
stateChange := StateChangeConf{
|
||||
Pending: []string{"BUILD"},
|
||||
Target: "ACTIVE",
|
||||
Target: []string{"ACTIVE"},
|
||||
Refresh: ServerStateRefreshFunc(computeClient, s.server),
|
||||
StepState: state,
|
||||
}
|
||||
|
@ -105,9 +105,9 @@ func (s *StepRunSourceServer) Cleanup(state multistep.StateBag) {
|
|||
}
|
||||
|
||||
stateChange := StateChangeConf{
|
||||
Pending: []string{"ACTIVE", "BUILD", "REBUILD", "SUSPENDED"},
|
||||
Pending: []string{"ACTIVE", "BUILD", "REBUILD", "SUSPENDED", "SHUTOFF", "STOPPED"},
|
||||
Refresh: ServerStateRefreshFunc(computeClient, s.server),
|
||||
Target: "DELETED",
|
||||
Target: []string{"DELETED"},
|
||||
}
|
||||
|
||||
WaitForState(&stateChange)
|
||||
|
|
|
@ -41,7 +41,7 @@ func (s *StepStopServer) Run(state multistep.StateBag) multistep.StepAction {
|
|||
ui.Message("Waiting for server to stop...")
|
||||
stateChange := StateChangeConf{
|
||||
Pending: []string{"ACTIVE"},
|
||||
Target: "STOPPED",
|
||||
Target: []string{"SHUTOFF", "STOPPED"},
|
||||
Refresh: ServerStateRefreshFunc(client, server),
|
||||
StepState: state,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue