'Permit admins to (live) migrate a server to a new host.'

@wsgi.response(202)
@extensions.expected_errors((400, 404, 409))
@wsgi.action('os-migrateLive')
@validation.schema(migrate_server.migrate_live, '2.0', '2.24')
@validation.schema(migrate_server.migrate_live_v2_25, '2.25', '2.29')
@validation.schema(migrate_server.migrate_live_v2_30, '2.30')
def _migrate_live(self, req, id, body):

    context = req.environ['nova.context']
    context.can((ms_policies.POLICY_ROOT % 'migrate_live'))
    host = body['os-migrateLive']['host']
    block_migration = body['os-migrateLive']['block_migration']
    force = None
    async = api_version_request.is_supported(req, min_version='2.34')
    if api_version_request.is_supported(req, min_version='2.30'):
        force = self._get_force_param_for_live_migration(body, host)
    if api_version_request.is_supported(req, min_version='2.25'):
        if (block_migration == 'auto'):
            block_migration = None
        else:
            block_migration = strutils.bool_from_string(block_migration, strict=True)
        disk_over_commit = None
    else:
        disk_over_commit = body['os-migrateLive']['disk_over_commit']
        block_migration = strutils.bool_from_string(block_migration, strict=True)
        disk_over_commit = strutils.bool_from_string(disk_over_commit, strict=True)
    instance = common.get_instance(self.compute_api, context, id)
    try:
        self.compute_api.live_migrate(context, instance, block_migration, disk_over_commit, host, force, async)
    except exception.InstanceUnknownCell as e:
        raise exc.HTTPNotFound(explanation=e.format_message())
    except (exception.NoValidHost, exception.ComputeServiceUnavailable, exception.ComputeHostNotFound, exception.InvalidHypervisorType, exception.InvalidCPUInfo, exception.UnableToMigrateToSelf, exception.DestinationHypervisorTooOld, exception.InvalidLocalStorage, exception.InvalidSharedStorage, exception.HypervisorUnavailable, exception.MigrationPreCheckError, exception.LiveMigrationWithOldNovaNotSupported) as ex:
        if async:
            with excutils.save_and_reraise_exception():
                LOG.error("Unexpected    exception    received    from    conductor    during    pre-live-migration    checks    '%(ex)s'", {'ex': ex})
        else:
            raise exc.HTTPBadRequest(explanation=ex.format_message())
    except exception.InstanceIsLocked as e:
        raise exc.HTTPConflict(explanation=e.format_message())
    except exception.InstanceInvalidState as state_error:
        common.raise_http_conflict_for_instance_invalid_state(state_error, 'os-migrateLive', id)
