Ejemplo n.º 1
0
def approve_application(application_id, project_id=None, request_user=None,
                        reason=""):
    get_project_lock()
    project = get_project_of_application_for_update(application_id)
    application = get_application(application_id)
    check_app_relevant(application, project, project_id)
    app_check_allowed(application, request_user, level=ADMIN_LEVEL)

    if not application.can_approve():
        m = _(astakos_messages.APPLICATION_CANNOT_APPROVE %
              (application.id, application.state_display()))
        raise ProjectConflict(m)

    if application.name:
        check_conflicting_projects(project, application.name)

    qh_release_pending_app(application.applicant)
    application.approve(actor=request_user, reason=reason)

    if project.state == Project.UNINITIALIZED:
        _fill_from_skeleton(project)
    else:
        _apply_modifications(project, application)
    project.activate(actor=request_user, reason=reason)

    quotas.qh_sync_project(project)
    logger.info("%s has been approved." % (application.log_display))
    project_notif.application_notify(application, "approve")
    return project
Ejemplo n.º 2
0
def _perform_action_project(project_id, action, request_user, reason):
    """
    This method performs an action regarding to a specific project, e.g. project
    termination, etc.

    Args:
        project_id: ID of project.
        action: Action to be performed on project.
        request_user: User who's performing action.
        reason: Reason of action.

    Returns:
        Project in which a user performed an action.
    """
    project = get_project_for_update(project_id)
    action_methods = {
        'TERMINATE': project.terminate,
        'SUSPEND': project.suspend,
        'UNSUSPEND': project.resume,
        'REINSTATE': project.resume,
    }

    validate_project_action(project, action, request_user, silent=False)
    action_methods[action](actor=request_user, reason=reason)
    quotas.qh_sync_project(project)
    if QUOTA_POLICY:
        QUOTA_POLICY.check_state_projects([project], action)
    project_notif.project_notify(project, action.lower())
    return project
Ejemplo n.º 3
0
def reinstate(project_id, request_user=None, reason=None):
    get_project_lock()
    project = get_project_for_update(project_id)
    validate_project_action(project, "REINSTATE", request_user, silent=False)
    project.resume(actor=request_user, reason=reason)
    quotas.qh_sync_project(project)
    logger.info("%s has been reinstated" % (project))
    project_notif.project_notify(project, "reinstate")
Ejemplo n.º 4
0
def unsuspend(project_id, request_user=None, reason=None):
    project = get_project_for_update(project_id)
    validate_project_action(project, "UNSUSPEND", request_user, silent=False)

    project.resume(actor=request_user, reason=reason)
    quotas.qh_sync_project(project)
    logger.info("%s has been unsuspended." % (project))
    project_notif.project_notify(project, "unsuspend")
Ejemplo n.º 5
0
def terminate(project_id, request_user=None, reason=None):
    project = get_project_for_update(project_id)
    validate_project_action(project, "TERMINATE", request_user, silent=False)

    project.terminate(actor=request_user, reason=reason)
    quotas.qh_sync_project(project)
    logger.info("%s has been terminated." % (project))

    project_notif.project_notify(project, "terminate")
Ejemplo n.º 6
0
def suspend(project_id, request_user=None, reason=None):
    project = get_project_for_update(project_id)
    project_check_allowed(project, request_user, level=ADMIN_LEVEL)
    checkAlive(project)

    project.suspend(actor=request_user, reason=reason)
    qh_sync_project(project)
    logger.info("%s has been suspended." % (project))

    project_suspension_notify(project)
Ejemplo n.º 7
0
def suspend(project_id, request_user=None, reason=None):
    project = get_project_for_update(project_id)
    project_check_allowed(project, request_user, level=ADMIN_LEVEL)
    checkAlive(project)

    project.suspend(actor=request_user, reason=reason)
    qh_sync_project(project)
    logger.info("%s has been suspended." % (project))

    project_suspension_notify(project)
Ejemplo n.º 8
0
def suspend(project_id, request_user=None):
    get_chain_for_update(project_id)
    project = get_project_by_id(project_id)
    checkAllowed(project, request_user, admin_only=True)
    checkAlive(project)

    project.suspend()
    qh_sync_project(project)
    logger.info("%s has been suspended." % (project))

    project_suspension_notify(project)
Ejemplo n.º 9
0
def suspend(project_id, request_user=None):
    get_chain_for_update(project_id)
    project = get_project_by_id(project_id)
    checkAllowed(project, request_user, admin_only=True)
    checkAlive(project)

    project.suspend()
    qh_sync_project(project)
    logger.info("%s has been suspended." % (project))

    project_suspension_notify(project)
Ejemplo n.º 10
0
def resume(project_id, request_user=None):
    get_chain_for_update(project_id)
    project = get_project_by_id(project_id)
    checkAllowed(project, request_user, admin_only=True)

    if not project.is_suspended:
        m = _(astakos_messages.NOT_SUSPENDED_PROJECT) % project.id
        raise PermissionDenied(m)

    project.resume()
    qh_sync_project(project)
    logger.info("%s has been unsuspended." % (project))
Ejemplo n.º 11
0
def unsuspend(project_id, request_user=None, reason=None):
    project = get_project_for_update(project_id)
    project_check_allowed(project, request_user, level=ADMIN_LEVEL)

    if not project.is_suspended:
        m = _(astakos_messages.NOT_SUSPENDED_PROJECT) % project.id
        raise ProjectConflict(m)

    project.resume(actor=request_user, reason=reason)
    qh_sync_project(project)
    logger.info("%s has been unsuspended." % (project))
    project_unsuspension_notify(project)
Ejemplo n.º 12
0
def unsuspend(project_id, request_user=None, reason=None):
    project = get_project_for_update(project_id)
    project_check_allowed(project, request_user, level=ADMIN_LEVEL)

    if not project.is_suspended:
        m = _(astakos_messages.NOT_SUSPENDED_PROJECT) % project.id
        raise ProjectConflict(m)

    project.resume(actor=request_user, reason=reason)
    qh_sync_project(project)
    logger.info("%s has been unsuspended." % (project))
    project_unsuspension_notify(project)
Ejemplo n.º 13
0
def resume(project_id, request_user=None):
    get_chain_for_update(project_id)
    project = get_project_by_id(project_id)
    checkAllowed(project, request_user, admin_only=True)

    if not project.is_suspended:
        m = _(astakos_messages.NOT_SUSPENDED_PROJECT) % project.id
        raise PermissionDenied(m)

    project.resume()
    qh_sync_project(project)
    logger.info("%s has been unsuspended." % (project))
Ejemplo n.º 14
0
def reinstate(project_id, request_user=None, reason=None):
    get_project_lock()
    project = get_project_for_update(project_id)
    project_check_allowed(project, request_user, level=ADMIN_LEVEL)

    if not project.is_terminated:
        m = _(astakos_messages.NOT_TERMINATED_PROJECT) % project.id
        raise ProjectConflict(m)

    check_conflicting_projects(project.application)
    project.resume(actor=request_user, reason=reason)
    qh_sync_project(project)
    logger.info("%s has been reinstated" % (project))
    project_reinstatement_notify(project)
Ejemplo n.º 15
0
def reinstate(project_id, request_user=None, reason=None):
    get_project_lock()
    project = get_project_for_update(project_id)
    project_check_allowed(project, request_user, level=ADMIN_LEVEL)

    if not project.is_terminated:
        m = _(astakos_messages.NOT_TERMINATED_PROJECT) % project.id
        raise ProjectConflict(m)

    check_conflicting_projects(project.application)
    project.resume(actor=request_user, reason=reason)
    qh_sync_project(project)
    logger.info("%s has been reinstated" % (project))
    project_reinstatement_notify(project)
Ejemplo n.º 16
0
def enable_base_project(user):
    project = make_base_project(user)
    _fill_from_skeleton(project)
    project.activate()
    new_membership(project, user, enroll=True)
    quotas.qh_sync_project(project)