예제 #1
0
def quickbuild_image(rpmname):
    """ Shortcut method to quickly allow the creation of an image with an rpm.

    This will generate a job for Jenkins with the rpm passed in as a parameter.
    A link to the

    :param rpmname: The name of the rpm to use in the images
    :type rpmname: str
    :reqheader Authorization: Basic HTTP authentication
    :statuscode 303: The uri to the Jenkins job.
    :statuscode 401: Authentication Required
    :statuscode 404: RPM was not found in the repo.
    """

    repo = IAASRepo(APP.config.get("REPO_DIR"))
    if rpmname not in repo.list():
        abort(404)

    build_url = request_build(
        APP.config.get("JENKINS_URL"),
        APP.config.get("JENKINS_USER"),
        APP.config.get("JENKINS_PASS"),
        APP.config.get("JENKINS_JOB"),
        {"RPM": rpmname},
    )

    return redirect(build_url, code=303)
예제 #2
0
def repo_get_rpm(rpmname):
    """Return a named rpm

    :param rpmname: The name of the rpm to return
    :type rpmname: str
    :reqheader Authorization: Basic HTTP authentication
    :statuscode 200: RPM successfully returned
    :statuscode 401: Authentication Required
    :statuscode 404: RPM not found
    """
    repo = IAASRepo(APP.config.get('REPO_DIR'))
    if rpmname in repo.list():
        return send_file(path.join(repo.repodir, rpmname),
                         mimetype='application/x-rpm',
                         as_attachment=True,
                         attachment_filename=rpmname)
    else:
        abort(404)
예제 #3
0
def repo_get_rpm(rpmname):
    """Return a named rpm

    :param rpmname: The name of the rpm to return
    :type rpmname: str
    :reqheader Authorization: Basic HTTP authentication
    :statuscode 200: RPM successfully returned
    :statuscode 401: Authentication Required
    :statuscode 404: RPM not found
    """
    repo = IAASRepo(APP.config.get("REPO_DIR"))
    if rpmname in repo.list():
        return send_file(
            path.join(repo.repodir, rpmname),
            mimetype="application/x-rpm",
            as_attachment=True,
            attachment_filename=rpmname,
        )
    else:
        abort(404)
예제 #4
0
def repo_list():
    """ Returns a list of rpm names in json format

    .. code-block:: javascript

        {
            "rpms": [
                "rpm1.rpm",
                "rpm2.rpm",
                .......
            ]
        }

    For security reasons, this is returned in as a dict rather than a list.
    See http://flask.pocoo.org/docs/0.10/security/#json-security

    :reqheader Authorization: Basic HTTP authentication
    :statuscode 200: List of available RPM files.
    :statuscode 401: Authentication Required.
    """
    repo = IAASRepo(APP.config.get("REPO_DIR"))
    return jsonify(rpms=repo.list())
예제 #5
0
def repo_list():
    """ Returns a list of rpm names in json format

    .. code-block:: javascript

        {
            "rpms": [
                "rpm1.rpm",
                "rpm2.rpm",
                .......
            ]
        }

    For security reasons, this is returned in as a dict rather than a list.
    See http://flask.pocoo.org/docs/0.10/security/#json-security

    :reqheader Authorization: Basic HTTP authentication
    :statuscode 200: List of available RPM files.
    :statuscode 401: Authentication Required.
    """
    repo = IAASRepo(APP.config.get('REPO_DIR'))
    return jsonify(rpms=repo.list())
예제 #6
0
def repo_add_rpm():
    """ Upload a RPM to the repo.

    Accepts multipart/form-data request. To upload using `curl` use:

    .. code-block:: bash

        curl -F '[email protected]' http://$url/repo/

    :form rpm: The contents of the RPM file.
    :reqheader Authorization: Basic HTTP authentication
    :statuscode 201: URI to newly created rpm
    :statuscode 303: The rpm alread exists at the returned URI
    :statuscode 401: Authentication Required
    """
    filedata = request.files["rpm"]
    temp_rpm = mktemp()
    if filedata:
        filedata.save(temp_rpm)
        repo = IAASRepo(APP.config.get("REPO_DIR"))
        name = repo.add(temp_rpm)
        return "%s\n" % name
    else:
        return "nope\n"
예제 #7
0
def repo_add_rpm():
    """ Upload a RPM to the repo.

    Accepts multipart/form-data request. To upload using `curl` use:

    .. code-block:: bash

        curl -F '[email protected]' http://$url/repo/

    :form rpm: The contents of the RPM file.
    :reqheader Authorization: Basic HTTP authentication
    :statuscode 201: URI to newly created rpm
    :statuscode 303: The rpm alread exists at the returned URI
    :statuscode 401: Authentication Required
    """
    filedata = request.files['rpm']
    temp_rpm = mktemp()
    if filedata:
        filedata.save(temp_rpm)
        repo = IAASRepo(APP.config.get('REPO_DIR'))
        name = repo.add(temp_rpm)
        return '%s\n' % name
    else:
        return 'nope\n'
예제 #8
0
def quickbuild_image(rpmname):
    """ Shortcut method to quickly allow the creation of an image with an rpm.

    This will generate a job for Jenkins with the rpm passed in as a parameter.
    A link to the

    :param rpmname: The name of the rpm to use in the images
    :type rpmname: str
    :reqheader Authorization: Basic HTTP authentication
    :statuscode 303: The uri to the Jenkins job.
    :statuscode 401: Authentication Required
    :statuscode 404: RPM was not found in the repo.
    """

    repo = IAASRepo(APP.config.get('REPO_DIR'))
    if rpmname not in repo.list():
        abort(404)

    build_url = request_build(APP.config.get('JENKINS_URL'),
                              APP.config.get('JENKINS_USER'),
                              APP.config.get('JENKINS_PASS'),
                              APP.config.get('JENKINS_JOB'), {'RPM': rpmname})

    return redirect(build_url, code=303)