#NEWLINE# def _attach_volume_and_wait_for_device( volume , attach_to , attach_volume , detach_volume , device , blockdevices ) : #NEWLINE# #INDENT# '\n    Attempt to attach an EBS volume to an EC2 instance and wait for the\n    corresponding OS device to become available.\n\n    :param BlockDeviceVolume volume: The Flocker representation of the volume\n        to attach.\n    :param unicode attach_to: The EC2 instance id to which to attach it.\n    :param attach_volume: A function like ``EC2Connection.attach_volume``.\n    :param detach_volume: A function like ``EC2Connection.detach_volume``.\n    :param unicode device: The OS device path to which to attach the device.\n    :param list blockdevices: The OS device paths (as ``FilePath``) which are\n        already present on the system before this operation is attempted\n        (primarily useful to make testing easier).\n    :raise: Anything ``attach_volume`` can raise.  Or\n        ``AttachedUnexpectedDevice`` if the volume appears to become attached\n        to the wrong OS device file.\n\n    :return: ``True`` if the volume is attached and accessible via the expected\n        OS device file.  ``False`` if the attempt times out without succeeding.\n    ' #NEWLINE# try : #NEWLINE# #INDENT# attach_volume ( volume . blockdevice_id , attach_to , device ) #NEWLINE# #UNINDENT# except ClientError as e : #NEWLINE# #INDENT# if ( e . response [ 'Error' ] [ 'Code' ] == 'InvalidParameterValue' ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# raise #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# device_path = _wait_for_new_device ( base = blockdevices , expected_size = volume . size ) #NEWLINE# if ( _expected_device ( device ) != device_path ) : #NEWLINE# #INDENT# detach_volume ( volume . blockdevice_id ) #NEWLINE# raise AttachedUnexpectedDevice ( FilePath ( device ) , device_path ) #NEWLINE# #UNINDENT# return True