def migrate_volume(self, ctxt, volume_id, host, force_host_copy=False, new_type_id=None, volume=None):
    'Migrate the volume to the specified host (called on source host).'
    if (volume is None):
        volume = objects.Volume.get_by_id(ctxt, volume_id)
    try:
        utils.require_driver_initialized(self.driver)
    except exception.DriverNotInitialized:
        with excutils.save_and_reraise_exception():
            volume.migration_status = 'error'
            volume.save()
    model_update = None
    moved = False
    status_update = None
    if (volume.status in ('retyping', 'maintenance')):
        status_update = {'status': volume.previous_status}
    volume.migration_status = 'migrating'
    volume.save()
    if ((not force_host_copy) and (new_type_id is None)):
        try:
            LOG.debug('Issue driver.migrate_volume.', resource=volume)
            (moved, model_update) = self.driver.migrate_volume(ctxt, volume, host)
            if moved:
                updates = {'host': host['host'], 'migration_status': 'success', 'previous_status': volume.status}
                if status_update:
                    updates.update(status_update)
                if model_update:
                    updates.update(model_update)
                volume.update(updates)
                volume.save()
        except Exception:
            with excutils.save_and_reraise_exception():
                updates = {'migration_status': 'error'}
                if status_update:
                    updates.update(status_update)
                volume.update(updates)
                volume.save()
    if (not moved):
        try:
            self._migrate_volume_generic(ctxt, volume, host, new_type_id)
        except Exception:
            with excutils.save_and_reraise_exception():
                updates = {'migration_status': 'error'}
                if status_update:
                    updates.update(status_update)
                volume.update(updates)
                volume.save()
    LOG.info(_LI('Migrate volume completed successfully.'), resource=volume)
Migrate the volume to the specified host (called on source host).
def migrate_volume(self, ctxt, volume_id, host, force_host_copy=False, new_type_id=None, volume=None):
    
    if (volume is None):
        volume = objects.Volume.get_by_id(ctxt, volume_id)
    try:
        utils.require_driver_initialized(self.driver)
    except exception.DriverNotInitialized:
        with excutils.save_and_reraise_exception():
            volume.migration_status = 'error'
            volume.save()
    model_update = None
    moved = False
    status_update = None
    if (volume.status in ('retyping', 'maintenance')):
        status_update = {'status': volume.previous_status}
    volume.migration_status = 'migrating'
    volume.save()
    if ((not force_host_copy) and (new_type_id is None)):
        try:
            LOG.debug('Issue driver.migrate_volume.', resource=volume)
            (moved, model_update) = self.driver.migrate_volume(ctxt, volume, host)
            if moved:
                updates = {'host': host['host'], 'migration_status': 'success', 'previous_status': volume.status}
                if status_update:
                    updates.update(status_update)
                if model_update:
                    updates.update(model_update)
                volume.update(updates)
                volume.save()
        except Exception:
            with excutils.save_and_reraise_exception():
                updates = {'migration_status': 'error'}
                if status_update:
                    updates.update(status_update)
                volume.update(updates)
                volume.save()
    if (not moved):
        try:
            self._migrate_volume_generic(ctxt, volume, host, new_type_id)
        except Exception:
            with excutils.save_and_reraise_exception():
                updates = {'migration_status': 'error'}
                if status_update:
                    updates.update(status_update)
                volume.update(updates)
                volume.save()
    LOG.info(_LI('Migrate volume completed successfully.'), resource=volume)