fixe issue #600, where ec2 module returns instance state as runing even after instance is terminated

This commit is contained in:
Benno Joy 2015-05-14 08:29:11 +05:30
parent 74351490f7
commit 9d9d8def6f

View file

@ -1089,6 +1089,13 @@ def terminate_instances(module, ec2, instance_ids):
# waiting took too long # waiting took too long
if wait_timeout < time.time() and num_terminated < len(terminated_instance_ids): if wait_timeout < time.time() and num_terminated < len(terminated_instance_ids):
module.fail_json(msg = "wait for instance termination timeout on %s" % time.asctime()) module.fail_json(msg = "wait for instance termination timeout on %s" % time.asctime())
#Lets get the current state of the instances after terminating - issue600
instance_dict_array = []
for res in ec2.get_all_instances(instance_ids=terminated_instance_ids,\
filters={'instance-state-name':'terminated'}):
for inst in res.instances:
instance_dict_array.append(get_instance_info(inst))
return (changed, instance_dict_array, terminated_instance_ids) return (changed, instance_dict_array, terminated_instance_ids)