From dedd3c8382d73a6bc9e35a5986d3fbb3ed041b6c Mon Sep 17 00:00:00 2001 From: Sergio Date: Wed, 7 Jun 2017 16:24:24 +0200 Subject: [PATCH] few changes around ec2 driver state switching --- src/vmm_mad/remotes/ec2/ec2_driver.rb | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/vmm_mad/remotes/ec2/ec2_driver.rb b/src/vmm_mad/remotes/ec2/ec2_driver.rb index b28a49896e..a1759be35c 100755 --- a/src/vmm_mad/remotes/ec2/ec2_driver.rb +++ b/src/vmm_mad/remotes/ec2/ec2_driver.rb @@ -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