1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Prevent ec2_remote_facts from failing when listing a terminated instance

This commit is contained in:
wimnat 2015-11-03 01:03:31 +00:00 committed by Matt Clay
parent 3ef5be470f
commit 482f0a8d1c

View file

@ -76,6 +76,12 @@ def get_instance_info(instance):
interfaces = [] interfaces = []
for interface in instance.interfaces: for interface in instance.interfaces:
interfaces.append({ 'id': interface.id, 'mac_address': interface.mac_address }.copy()) interfaces.append({ 'id': interface.id, 'mac_address': interface.mac_address }.copy())
# If an instance is terminated, sourceDestCheck is no longer returned
try:
source_dest_check = instance.sourceDestCheck
except AttributeError:
source_dest_check = None
instance_info = { 'id': instance.id, instance_info = { 'id': instance.id,
'kernel': instance.kernel, 'kernel': instance.kernel,
@ -90,7 +96,7 @@ def get_instance_info(instance):
'ramdisk': instance.ramdisk, 'ramdisk': instance.ramdisk,
'tags': instance.tags, 'tags': instance.tags,
'key_name': instance.key_name, 'key_name': instance.key_name,
'source_destination_check': instance.sourceDestCheck, 'source_destination_check': source_dest_check,
'image_id': instance.image_id, 'image_id': instance.image_id,
'groups': groups, 'groups': groups,
'interfaces': interfaces, 'interfaces': interfaces,