Пример #1
0
def __handle_request_branch(actionid, action):
    """ Handle ne branch requests. """
    msgs = utils.check_branch_creation(
        PKGDBCLIENT, action["package"]["name"], action["collection"]["branchname"], action["user"]
    )

    decision = _ask_what_to_do(msgs)
    if decision in ("a", "approve"):
        data = PKGDBCLIENT.update_acl(
            pkgname=action["package"]["name"],
            branches=action["collection"]["branchname"],
            acls=["commit", "watchbugzilla", "watchcommits", "approveacls"],
            status="Approved",
            user=action["user"],
        )

        PKGDBCLIENT.handle_api_call("/admin/action/status", data={"id": actionid, "status": "Approved"})

    elif decision in ("deny", "d"):
        message = raw_input(
            "Could you explain why you declined this request? (this message " "will be sent to the user)\n=>"
        )
        data = PKGDBCLIENT.handle_api_call(
            "/admin/action/status", data={"id": actionid, "status": "Denied", "message": message}
        )

    else:
        data = {"messages": ["Action {0} un-touched".format(actionid)]}

    return data
Пример #2
0
def __handle_request_branch(actionid, action, package):
    ''' Handle ne branch requests. '''
    msgs = utils.check_branch_creation(
        PKGDBCLIENT,
        action['package']['name'],
        action['collection']['branchname'],
        action['user'],
        namespace=action['package'].get('namespace', 'rpms'),
    )

    decision = None
    if package is not None:
        branch = action['info']['pkg_collection']

        # Requests for Fedora branches can be automatically approved if they
        # are from a package admin. Usually package DB approves them directly
        # only when the package was created at the same time the branches were
        # requested, it needs to be approved by a pkgdb admin.
        if branch[0] == "f":
            for acl in package["acls"]:
                if acl["fas_name"] == action["user"] and \
                        acl["acl"] == "approveacls" and \
                        acl["status"] == "Approved":
                    if len(msgs["bad"]) == 0:
                        print("Auto approving Fedora Branch request for "
                              "package admin {0}".format(action["user"]))
                        decision = "approve"

    if decision is None:
        decision = _ask_what_to_do(msgs)

    if decision in ('a', 'approve'):
        data = PKGDBCLIENT.update_acl(
            pkgname=action['package']['name'],
            branches=action['collection']['branchname'],
            acls=[
                'commit', 'watchbugzilla',
                'watchcommits', 'approveacls'
            ],
            status='Approved',
            user=action['user'],
            namespace=action['package'].get('namespace', 'rpms'),
        )

        approve_action(actionid)

    elif decision in ('deny', 'd'):
        data, _ = deny_action(actionid)
    else:
        data = {
            'messages': ['Action {0} un-touched'.format(actionid)]
        }

    return data
Пример #3
0
def __handle_request_branch(actionid, action):
    ''' Handle ne branch requests. '''
    msgs = utils.check_branch_creation(
        PKGDBCLIENT,
        action['package']['name'],
        action['collection']['branchname'],
        action['user']
    )

    decision = _ask_what_to_do(msgs)
    if decision in ('a', 'approve'):
        data = PKGDBCLIENT.update_acl(
            pkgname=action['package']['name'],
            branches=action['collection']['branchname'],
            acls=[
                'commit', 'watchbugzilla',
                'watchcommits', 'approveacls'
            ],
            status='Approved',
            user=action['user'],
        )

        PKGDBCLIENT.handle_api_call(
            '/admin/action/status',
            data={
                'id': actionid,
                'status': 'Approved'
            }
        )

    elif decision in ('deny', 'd'):
        message = raw_input(
            'Could you explain why you declined this request? (this message '
            'will be sent to the user)\n=>')
        data = PKGDBCLIENT.handle_api_call(
            '/admin/action/status',
            data={
                'id': actionid,
                'status': 'Denied',
                'message': message,
            }
        )

    else:
        data = {
            'messages': ['Action {0} un-touched'.format(actionid)]
        }


    return data
Пример #4
0
def __handle_request_branch(actionid, action, package):
    ''' Handle ne branch requests. '''
    msgs = utils.check_branch_creation(
        PKGDBCLIENT,
        action['package']['name'],
        action['collection']['branchname'],
        action['user'],
        namespace=action['package'].get('namespace', 'rpms'),
    )

    decision = None
    if package is not None:
        branch = action['info']['pkg_collection']

        # Requests for Fedora branches can be automatically approved if they
        # are from a package admin. Usually package DB approves them directly
        # only when the package was created at the same time the branches were
        # requested, it needs to be approved by a pkgdb admin.
        if branch[0] == "f":
            for acl in package["acls"]:
                if acl["fas_name"] == action["user"] and \
                        acl["acl"] == "approveacls" and \
                        acl["status"] == "Approved":
                    if len(msgs["bad"]) == 0:
                        print("Auto approving Fedora Branch request for "
                              "package admin {0}".format(action["user"]))
                        decision = "approve"

    if decision is None:
        decision = _ask_what_to_do(msgs)

    if decision in ('a', 'approve'):
        data = PKGDBCLIENT.update_acl(
            pkgname=action['package']['name'],
            branches=action['collection']['branchname'],
            acls=['commit', 'watchbugzilla', 'watchcommits', 'approveacls'],
            status='Approved',
            user=action['user'],
            namespace=action['package'].get('namespace', 'rpms'),
        )

        approve_action(actionid)

    elif decision in ('deny', 'd'):
        data, _ = deny_action(actionid)
    else:
        data = {'messages': ['Action {0} un-touched'.format(actionid)]}

    return data
Пример #5
0
def __handle_request_unretire(actionid, action):
    ''' Handle unretirement requests. Do the same checks as done for new
    package requests and ask the admin to do the necessary steps by hand. '''

    # Add valuees to info that pkgdb adds to new package actions
    action['info']['pkg_name'] = action['package']['name']
    action['info']['pkg_summary'] = action['package']['summary']
    action['info']['pkg_collection'] = action['collection'][
        'branchname']
    action['info']['pkg_poc'] = action['user']
    # FIXME : Does not need to use .get() once
    # https://github.com/fedora-infra/pkgdb2/pull/333
    # is deployed.
    action['info']['pkg_namespace'] = action['package'].get(
        'namespace', 'rpms')

    if action['info']['pkg_review_url']:
        bugid = utils.get_bug_id_from_url(action['info']['pkg_review_url'])
        msgs = utils.check_package_creation(
            action['info'], bugid, PKGDBCLIENT, action['user'])
    else:
        msgs = utils.check_branch_creation(
            PKGDBCLIENT, action['package']['name'],
            action['collection']['branchname'], action['user'], new_pkg=True,
            namespace=action['info']['pkg_namespace'])

        package = PKGDBCLIENT.get_package(
            action['package']['name'],
            branches=[action['info']['pkg_collection']],
            namespace=action['info']['pkg_namespace'],
        )["packages"][0]
        rawhide_package = PKGDBCLIENT.get_package(
            action['package']['name'], branches=["master"],
            namespace=action['info']['pkg_namespace'],
        )["packages"][0]

        last_pkg_change = datetime.datetime.fromtimestamp(
            package["status_change"])
        request_date = datetime.datetime.fromtimestamp(
            action['date_created'])
        delta = request_date - last_pkg_change
        if delta.days < 14:
            msgs["good"].append("Package was retired less than 14 days ago")
        elif rawhide_package.status != "Retired":
            msgs["good"].append("Package is not retired in Rawhide")
        else:
            msgs["bad"].append(
                "Package is retired in Rawhide and was retired more than "
                "14 days ago")
    if action['info'].get('pkg_review_url'):
        print('Review url {}'.format(action['info'].get('pkg_review_url')))
    else:
        print('No review url was provided with this request')

    decision = _ask_what_to_do(msgs)

    if decision in ('a', 'approve'):
        cmd = ("pkgdb-cli", "unorphan", "--poc", action['info']['pkg_poc'],
               action['info']['pkg_name'], action['info']['pkg_collection'])
        input("Please run the following command (confirm with any key): " +
              " ".join(cmd))
        input("Please make sure the package is properly unblocked in koji. "
              "(Confirm with any key)")

        data = approve_action(actionid)

    elif decision in ('deny', 'd'):
        data, _ = deny_action(actionid)
    else:
        data = {
            'messages': ['Action {0} un-touched'.format(actionid)]
        }
    return data