#NEWLINE# def _reached_end_state( operation , volume , update , elapsed_time , timeout = VOLUME_STATE_CHANGE_TIMEOUT ) : #NEWLINE# #INDENT# "\n    Helper function to determine if wait for volume's state transition\n    resulting from given operation is over.\n    The method completes if volume reached expected end state, or, failed\n    to reach expected end state, or we timed out waiting for the volume to\n    reach expected end state.\n\n    :param NamedConstant operation: Operation performed on given volume.\n    :param boto3.resources.factory.ec2.Volume: Target volume of given\n        operation.\n    :param method update: Method to use to check volume state.\n    :param float elapsed_time: Time since operation was executed on volume.\n    :param int timeout: Time, in seconds, to wait for volume to reach expected\n        destination state.\n\n    :returns: True or False indicating end of wait for volume state transition.\n    :rtype: bool\n    " #NEWLINE# state_flow = VOLUME_STATE_TABLE . table [ operation ] #NEWLINE# start_state = state_flow . start_state . value #NEWLINE# transient_state = state_flow . transient_state . value #NEWLINE# end_state = state_flow . end_state . value #NEWLINE# sets_attach = state_flow . sets_attach #NEWLINE# unsets_attach = state_flow . unsets_attach #NEWLINE# if ( elapsed_time > timeout ) : #NEWLINE# #INDENT# raise TimeoutException ( unicode ( volume . id ) , operation , start_state , transient_state , end_state , volume . state ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# update ( volume ) #NEWLINE# #UNINDENT# except ClientError as e : #NEWLINE# #INDENT# if ( e . response [ 'Error' ] [ 'Code' ] == NOT_FOUND ) : #NEWLINE# #INDENT# raise UnknownVolume ( volume . id ) #NEWLINE# #UNINDENT# #UNINDENT# WAITING_FOR_VOLUME_STATUS_CHANGE ( volume_id = volume . id , status = volume . state , target_status = end_state , needs_attach_data = sets_attach , wait_time = elapsed_time ) . write ( ) #NEWLINE# if ( volume . state not in [ start_state , transient_state , end_state ] ) : #NEWLINE# #INDENT# raise UnexpectedStateException ( unicode ( volume . id ) , operation , start_state , transient_state , end_state , volume . state ) #NEWLINE# #UNINDENT# if ( volume . state != end_state ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# if volume . attachments : #NEWLINE# #INDENT# volume_attach_data = volume . attachments [ 0 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# volume_attach_data = None #NEWLINE# #UNINDENT# if sets_attach : #NEWLINE# #INDENT# return ( ( volume_attach_data is not None ) and ( ( unsets_attach [ 'Device' ] != '' ) and ( volume_attach_data [ 'InstanceId' ] != '' ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if unsets_attach : #NEWLINE# #INDENT# return ( ( volume_attach_data is None ) or ( ( volume_attach_data [ 'Device' ] == '' ) and ( volume_attach_data [ 'InstanceId' ] == '' ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return True