#NEWLINE# def _cinder_volume_data_iterator( self , client , volume , max_size , offset = 0 , chunk_size = None , partial_length = None ) : #NEWLINE# #INDENT# chunk_size = ( chunk_size if chunk_size else self . READ_CHUNKSIZE ) #NEWLINE# partial = ( partial_length is not None ) #NEWLINE# with self . _open_cinder_volume ( client , volume , 'rb' ) as fp : #NEWLINE# #INDENT# if offset : #NEWLINE# #INDENT# fp . seek ( offset ) #NEWLINE# max_size -= offset #NEWLINE# #UNINDENT# while True : #NEWLINE# #INDENT# if partial : #NEWLINE# #INDENT# size = min ( chunk_size , partial_length , max_size ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# size = min ( chunk_size , max_size ) #NEWLINE# #UNINDENT# chunk = fp . read ( size ) #NEWLINE# if chunk : #NEWLINE# #INDENT# ( yield chunk ) #NEWLINE# max_size -= len ( chunk ) #NEWLINE# if ( max_size <= 0 ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# if partial : #NEWLINE# #INDENT# partial_length -= len ( chunk ) #NEWLINE# if ( partial_length <= 0 ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# break