def _copy_volume_data(self, ctxt, src_vol, dest_vol, remote=None):
    'Copy data from src_vol to dest_vol.'
    LOG.debug('copy_data_between_volumes %(src)s -> %(dest)s.', {'src': src_vol['name'], 'dest': dest_vol['name']})
    properties = utils.brick_get_connector_properties()
    dest_remote = (remote in ['dest', 'both'])
    dest_attach_info = self._attach_volume(ctxt, dest_vol, properties, remote=dest_remote)
    try:
        src_remote = (remote in ['src', 'both'])
        src_attach_info = self._attach_volume(ctxt, src_vol, properties, remote=src_remote)
    except Exception:
        with excutils.save_and_reraise_exception():
            LOG.error(_LE('Failed to attach source volume for copy.'))
            self._detach_volume(ctxt, dest_attach_info, dest_vol, properties, remote=dest_remote)
    rpcapi = volume_rpcapi.VolumeAPI()
    capabilities = rpcapi.get_capabilities(ctxt, dest_vol['host'], False)
    sparse_copy_volume = bool((capabilities and capabilities.get('sparse_copy_volume', False)))
    copy_error = True
    try:
        size_in_mb = (int(src_vol['size']) * units.Ki)
        vol_utils.copy_volume(src_attach_info['device']['path'], dest_attach_info['device']['path'], size_in_mb, self.configuration.volume_dd_blocksize, sparse=sparse_copy_volume)
        copy_error = False
    except Exception:
        with excutils.save_and_reraise_exception():
            LOG.error(_LE('Failed to copy volume %(src)s to %(dest)s.'), {'src': src_vol['id'], 'dest': dest_vol['id']})
    finally:
        try:
            self._detach_volume(ctxt, dest_attach_info, dest_vol, properties, force=copy_error, remote=dest_remote)
        finally:
            self._detach_volume(ctxt, src_attach_info, src_vol, properties, force=copy_error, remote=src_remote)
Copy data from src_vol to dest_vol.
def _copy_volume_data(self, ctxt, src_vol, dest_vol, remote=None):
    
    LOG.debug('copy_data_between_volumes %(src)s -> %(dest)s.', {'src': src_vol['name'], 'dest': dest_vol['name']})
    properties = utils.brick_get_connector_properties()
    dest_remote = (remote in ['dest', 'both'])
    dest_attach_info = self._attach_volume(ctxt, dest_vol, properties, remote=dest_remote)
    try:
        src_remote = (remote in ['src', 'both'])
        src_attach_info = self._attach_volume(ctxt, src_vol, properties, remote=src_remote)
    except Exception:
        with excutils.save_and_reraise_exception():
            LOG.error(_LE('Failed to attach source volume for copy.'))
            self._detach_volume(ctxt, dest_attach_info, dest_vol, properties, remote=dest_remote)
    rpcapi = volume_rpcapi.VolumeAPI()
    capabilities = rpcapi.get_capabilities(ctxt, dest_vol['host'], False)
    sparse_copy_volume = bool((capabilities and capabilities.get('sparse_copy_volume', False)))
    copy_error = True
    try:
        size_in_mb = (int(src_vol['size']) * units.Ki)
        vol_utils.copy_volume(src_attach_info['device']['path'], dest_attach_info['device']['path'], size_in_mb, self.configuration.volume_dd_blocksize, sparse=sparse_copy_volume)
        copy_error = False
    except Exception:
        with excutils.save_and_reraise_exception():
            LOG.error(_LE('Failed to copy volume %(src)s to %(dest)s.'), {'src': src_vol['id'], 'dest': dest_vol['id']})
    finally:
        try:
            self._detach_volume(ctxt, dest_attach_info, dest_vol, properties, force=copy_error, remote=dest_remote)
        finally:
            self._detach_volume(ctxt, src_attach_info, src_vol, properties, force=copy_error, remote=src_remote)