few changes around ec2 driver state switching

This commit is contained in:
Sergio authored and Tino Vázquez committed 2017-06-08 11:30:18 +02:00
1 parent 585cc13033
commit dedd3c8382
1 file changed
+6 -9
+6 -9
View File
@@ -736,17 +736,14 @@ private
# +state+: String, is the desired state, needs to be a real state of Amazon ec2: running, stopped, terminated, pending
# +deploy_id+: String, VM id in EC2
def wait_state(state, deploy_id)
ready = (state == 'stopped') || (state == 'pending') || (state == 'running') || (state == 'terminated')
ready = (state == 'stopped') || (state == 'pending') || (state == 'running') || (state == 'terminated')
raise "Waiting for an invalid state" if !ready
t_init = Time.now
current_state = get_instance(deploy_id).state.name
while current_state != state
break if Time.now - t_init > @state_change_timeout
sleep 3
current_state = get_instance(deploy_id).state.name
end
begin
wstate = get_instance(deploy_id).state.name rescue nil
raise "Ended in invalid state" if Time.now - t_init > @state_change_timeout
sleep 3
end while wstate != state
end
# Load the default values that will be used to create a new instance, if