#NEWLINE# def push( self , volume , destination ) : #NEWLINE# #INDENT# "\n        Push the latest data in the volume to a remote destination.\n\n        This is a blocking API for now.\n\n        Only locally owned volumes (i.e. volumes whose ``uuid`` matches\n        this service's) can be pushed.\n\n        :param Volume volume: The volume to push.\n\n        :param IRemoteVolumeManager destination: The remote volume manager\n            to push to.\n\n        :raises ValueError: If the uuid of the volume is different than\n            our own; only locally-owned volumes can be pushed.\n        " #NEWLINE# if ( volume . node_id != self . node_id ) : #NEWLINE# #INDENT# raise ValueError ( ) #NEWLINE# #UNINDENT# fs = volume . get_filesystem ( ) #NEWLINE# getting_snapshots = destination . snapshots ( volume ) #NEWLINE# def got_snapshots( snapshots ) : #NEWLINE# #INDENT# with destination . receive ( volume ) as receiver : #NEWLINE# #INDENT# with fs . reader ( snapshots ) as contents : #NEWLINE# #INDENT# for chunk in iter ( ( lambda : contents . read ( ( 1024 * 1024 ) ) ) , b'' ) : #NEWLINE# #INDENT# receiver . write ( chunk ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# pushing = getting_snapshots . addCallback ( got_snapshots ) #NEWLINE# return fs