mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Included 'block_device_mapping' in the output of module and other missing attributes
This commit is contained in:
parent
baeb6d8dc0
commit
aa887ce49f
1 changed files with 24 additions and 0 deletions
|
@ -165,12 +165,32 @@ EXAMPLES = '''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import boto.ec2
|
import boto.ec2
|
||||||
|
from boto.ec2.blockdevicemapping import BlockDeviceType, BlockDeviceMapping
|
||||||
HAS_BOTO=True
|
HAS_BOTO=True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
HAS_BOTO=False
|
HAS_BOTO=False
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
def get_block_device_mapping(image):
|
||||||
|
"""
|
||||||
|
Retrieves block device mapping from AMI
|
||||||
|
"""
|
||||||
|
|
||||||
|
bdm_dict = dict()
|
||||||
|
bdm = getattr(image,'block_device_mapping')
|
||||||
|
for device_name in bdm.keys():
|
||||||
|
bdm_dict[device_name] = {
|
||||||
|
'size': bdm[device_name].size,
|
||||||
|
'snapshot_id': bdm[device_name].snapshot_id,
|
||||||
|
'volume_type': bdm[device_name].volume_type,
|
||||||
|
'encrypted': bdm[device_name].encrypted,
|
||||||
|
'delete_on_termination': bdm[device_name].delete_on_termination
|
||||||
|
}
|
||||||
|
|
||||||
|
return bdm_dict
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
argument_spec = ec2_argument_spec()
|
argument_spec = ec2_argument_spec()
|
||||||
argument_spec.update(dict(
|
argument_spec.update(dict(
|
||||||
|
@ -255,8 +275,12 @@ def main():
|
||||||
data = {
|
data = {
|
||||||
'ami_id': image.id,
|
'ami_id': image.id,
|
||||||
'architecture': image.architecture,
|
'architecture': image.architecture,
|
||||||
|
'block_device_mapping': get_block_device_mapping(image),
|
||||||
|
'creationDate': image.creationDate,
|
||||||
'description': image.description,
|
'description': image.description,
|
||||||
|
'hypervisor': image.hypervisor,
|
||||||
'is_public': image.is_public,
|
'is_public': image.is_public,
|
||||||
|
'location': image.location,
|
||||||
'name': image.name,
|
'name': image.name,
|
||||||
'owner_id': image.owner_id,
|
'owner_id': image.owner_id,
|
||||||
'platform': image.platform,
|
'platform': image.platform,
|
||||||
|
|
Loading…
Reference in a new issue