Merge pull request #8416 from willthames/ec2_handle_terminated_instances
Improved handling of already terminated instances
This commit is contained in:
commit
ce484a5105
1 changed files with 9 additions and 0 deletions
|
@ -918,6 +918,15 @@ def create_instances(module, ec2, override_count=None):
|
|||
except boto.exception.BotoServerError, e:
|
||||
module.fail_json(msg = "Instance creation failed => %s: %s" % (e.error_code, e.error_message))
|
||||
|
||||
# The instances returned through run_instances can be in
|
||||
# terminated state due to idempotency.
|
||||
terminated_instances = [ str(instance.id) for instance in res.instances
|
||||
if instance.state == 'terminated' ]
|
||||
if terminated_instances:
|
||||
module.fail_json(msg = "Instances with id(s) %s " % terminated_instances +
|
||||
"were created previously but have since been terminated - " +
|
||||
"use a (possibly different) 'instanceid' parameter")
|
||||
|
||||
# wait here until the instances are up
|
||||
num_running = 0
|
||||
wait_timeout = time.time() + wait_timeout
|
||||
|
|
Loading…
Reference in a new issue