def legacy_mapping(block_device_mapping):
 legacy_block_device_mapping = []
 for bdm in block_device_mapping:
  try:
   legacy_block_device = BlockDeviceDict(bdm).legacy()
  except exception.InvalidBDMForLegacy:
   continue
  legacy_block_device_mapping.append(legacy_block_device)
 for (i, dev) in enumerate((dev for dev in legacy_block_device_mapping if (dev['virtual_name'] and is_ephemeral(dev['virtual_name'])))):
  dev['virtual_name'] = (dev['virtual_name'][:(-1)] + str(i))
 return legacy_block_device_mapping

def legacy_mapping ( block_device_mapping ) : legacy_block_device_mapping = [ ] for bdm in block_device_mapping : try : legacy_block_device = BlockDeviceDict ( bdm ) . legacy ( ) except exception . InvalidBDMForLegacy : continue legacy_block_device_mapping . append ( legacy_block_device ) for ( i , dev ) in enumerate ( ( dev for dev in legacy_block_device_mapping if ( dev [ 'virtual_name' ] and is_ephemeral ( dev [ 'virtual_name' ] ) ) ) ) : dev [ 'virtual_name' ] = ( dev [ 'virtual_name' ] [ : ( - 1 ) ] + str ( i ) ) return legacy_block_device_mapping
transform a list of block devices of an instance back to the legacy data format .