def _attach_volume_and_wait_for_device(volume, attach_to, attach_volume, detach_volume, device, blockdevices):
 try:
  attach_volume(volume.blockdevice_id, attach_to, device)
 except ClientError as e:
  if (e.response['Error']['Code'] == u'InvalidParameterValue'):
   return False
  raise
 else:
  device_path = _wait_for_new_device(base=blockdevices, expected_size=volume.size)
  if (_expected_device(device) != device_path):
   detach_volume(volume.blockdevice_id)
   raise AttachedUnexpectedDevice(FilePath(device), device_path)
  return True

def _attach_volume_and_wait_for_device ( volume , attach_to , attach_volume , detach_volume , device , blockdevices ) : try : attach_volume ( volume . blockdevice_id , attach_to , device ) except ClientError as e : if ( e . response [ 'Error' ] [ 'Code' ] == u'InvalidParameterValue' ) : return False raise else : device_path = _wait_for_new_device ( base = blockdevices , expected_size = volume . size ) if ( _expected_device ( device ) != device_path ) : detach_volume ( volume . blockdevice_id ) raise AttachedUnexpectedDevice ( FilePath ( device ) , device_path ) return True
attempt to attach an ebs volume to an ec2 instance and wait for the corresponding os device to become available .