def get_block_device_mapping(image):
 bdm_dict = dict()
 if ((image is not None) and hasattr(image, 'block_device_mapping')):
  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 get_block_device_mapping ( image ) : bdm_dict = dict ( ) if ( ( image is not None ) and hasattr ( image , 'block_device_mapping' ) ) : 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
retrieves block device mapping from ami .