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
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")
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")
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")