def _format_block_device_mapping(bdm):
 keys = (('deviceName', 'device_name'), ('virtualName', 'virtual_name'))
 item = {}
 for (name, k) in keys:
  if (k in bdm):
   item[name] = bdm[k]
 if bdm.get('no_device'):
  item['noDevice'] = True
 if (('snapshot_id' in bdm) or ('volume_id' in bdm)):
  ebs_keys = (('snapshotId', 'snapshot_id'), ('snapshotId', 'volume_id'), ('volumeSize', 'volume_size'), ('deleteOnTermination', 'delete_on_termination'))
  ebs = {}
  for (name, k) in ebs_keys:
   if (k in bdm):
    if (k == 'snapshot_id'):
     ebs[name] = ec2utils.id_to_ec2_snap_id(bdm[k])
    elif (k == 'volume_id'):
     ebs[name] = ec2utils.id_to_ec2_vol_id(bdm[k])
    else:
     ebs[name] = bdm[k]
  assert ('snapshotId' in ebs)
  item['ebs'] = ebs
 return item

def _format_block_device_mapping ( bdm ) : keys = ( ( 'deviceName' , 'device_name' ) , ( 'virtualName' , 'virtual_name' ) ) item = { } for ( name , k ) in keys : if ( k in bdm ) : item [ name ] = bdm [ k ] if bdm . get ( 'no_device' ) : item [ 'noDevice' ] = True if ( ( 'snapshot_id' in bdm ) or ( 'volume_id' in bdm ) ) : ebs_keys = ( ( 'snapshotId' , 'snapshot_id' ) , ( 'snapshotId' , 'volume_id' ) , ( 'volumeSize' , 'volume_size' ) , ( 'deleteOnTermination' , 'delete_on_termination' ) ) ebs = { } for ( name , k ) in ebs_keys : if ( k in bdm ) : if ( k == 'snapshot_id' ) : ebs [ name ] = ec2utils . id_to_ec2_snap_id ( bdm [ k ] ) elif ( k == 'volume_id' ) : ebs [ name ] = ec2utils . id_to_ec2_vol_id ( bdm [ k ] ) else : ebs [ name ] = bdm [ k ] assert ( 'snapshotId' in ebs ) item [ 'ebs' ] = ebs return item
construct blockdevicemappingitemtype {device_name: .