Example #1
0
def activate_changes(params):
    """Activate pending changes"""
    body = params['body']
    sites = body['sites']
    with may_fail(MKUserError, status=400):
        activation_id = watolib.activate_changes_start(sites)
    if body['redirect']:
        wait_for = _completion_link(activation_id)
        response = Response(status=301)
        response.location = wait_for['href']
        return response

    return _serve_activation_run(activation_id, is_running=True)
Example #2
0
def activate_changes(params):
    """Activate pending changes"""
    body = params["body"]
    sites = body["sites"]
    with may_fail(MKUserError, status=400):
        activation_id = watolib.activate_changes_start(
            sites, force_foreign_changes=body["force_foreign_changes"])
    if body["redirect"]:
        wait_for = _completion_link(activation_id)
        response = Response(status=302)
        response.location = wait_for["href"]
        return response

    return _serve_activation_run(activation_id, is_running=True)
Example #3
0
def activate_changes_state(params):
    """Wait for an activation-run to complete.

    This endpoint will periodically redirect on itself to prevent timeouts.
    """
    activation_id = params['activation_id']
    manager = watolib.ActivateChangesManager()
    manager.load()
    manager.load_activation(activation_id)
    done = manager.wait_for_completion(timeout=request.request_timeout - 10)
    if not done:
        response = Response(status=301)
        response.location = request.url
        return response

    return Response(status=204)
Example #4
0
def activate_changes_wait_for_completion(params):
    """Wait for activation completion

    This endpoint will periodically redirect on itself to prevent timeouts.
    """
    activation_id = params['activation_id']
    manager = watolib.ActivateChangesManager()
    manager.load()
    try:
        manager.load_activation(activation_id)
    except MKUserError:
        raise ProblemException(
            status=404, title=f"Activation {activation_id!r} not found.")
    done = manager.wait_for_completion(timeout=request.request_timeout - 10)
    if not done:
        response = Response(status=302)
        response.location = request.url
        return response

    return Response(status=204)