mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-03 02:37:48 +08:00
Sort imports, remove obsolete TODOs
Signed-off-by: Petr Šabata <contyk@redhat.com>
This commit is contained in:
33
rida.py
33
rida.py
@@ -31,31 +31,32 @@ This is the implementation of the orchestrator's public RESTful API.
|
||||
|
||||
# TODO; Validate the input modulemd & spec inputs.
|
||||
# This requires SCM classes to be ready.
|
||||
# TODO: Update the PDC dependency graph.
|
||||
# This is done via messaging and is closely related to the next point.
|
||||
# TODO: Emit messages about module submission.
|
||||
|
||||
from flask import Flask, request
|
||||
from rida import config, database, messaging, auth, logger
|
||||
import logging
|
||||
import json
|
||||
import logging
|
||||
import modulemd
|
||||
import rida.auth
|
||||
import rida.config
|
||||
import rida.database
|
||||
import rida.logger
|
||||
import rida.messaging
|
||||
import ssl
|
||||
|
||||
app = Flask(__name__)
|
||||
app.config.from_envvar("RIDA_SETTINGS", silent=True)
|
||||
|
||||
# TODO: Load the config file from environment
|
||||
conf = config.from_file("rida.conf")
|
||||
logger.init_logging(conf)
|
||||
conf = rida.config.from_file("rida.conf")
|
||||
rida.logger.init_logging(conf)
|
||||
|
||||
db = database.Database()
|
||||
db = rida.database.Database()
|
||||
|
||||
@app.route("/rida/module-builds/", methods=["POST"])
|
||||
def submit_build():
|
||||
"""Handles new module build submissions."""
|
||||
|
||||
username = auth.is_packager(conf.pkgdb_api_url)
|
||||
username = rida.auth.is_packager(conf.pkgdb_api_url)
|
||||
if not username:
|
||||
return ("You must use your Fedora certificate when submitting"
|
||||
" new build", 403)
|
||||
@@ -83,7 +84,7 @@ def submit_build():
|
||||
mmd.loads(yaml)
|
||||
except:
|
||||
return "Invalid modulemd", 422
|
||||
module = database.Module(name=mmd.name, version=mmd.version,
|
||||
module = rida.database.Module(name=mmd.name, version=mmd.version,
|
||||
release=mmd.release, state="init", modulemd=yaml)
|
||||
db.session.add(module)
|
||||
db.session.commit()
|
||||
@@ -91,7 +92,7 @@ def submit_build():
|
||||
# all the components are available and we're allowed to
|
||||
# process them. We will assume it all passed for now.
|
||||
for rpm in mmd.components.rpms.packages.keys():
|
||||
build = database.Build(module_id=module.id, package=rpm, format="rpms")
|
||||
build = rida.database.Build(module_id=module.id, package=rpm, format="rpms")
|
||||
db.session.add(build)
|
||||
module.state = "wait"
|
||||
db.session.add(module)
|
||||
@@ -99,7 +100,7 @@ def submit_build():
|
||||
|
||||
# Publish to whatever bus we're configured to connect to.
|
||||
# This should notify ridad to start doing the work we just scheduled.
|
||||
messaging.publish(
|
||||
rida.messaging.publish(
|
||||
modname='rida',
|
||||
topic='module.state.change',
|
||||
msg=module.json(),
|
||||
@@ -116,17 +117,17 @@ def submit_build():
|
||||
def query_builds():
|
||||
"""Lists all tracked module builds."""
|
||||
return json.dumps([{"id": x.id, "state": x.state}
|
||||
for x in db.session.query(database.Module).all()]), 200
|
||||
for x in db.session.query(rida.database.Module).all()]), 200
|
||||
|
||||
|
||||
@app.route("/rida/module-builds/<int:id>", methods=["GET"])
|
||||
def query_build(id):
|
||||
"""Lists details for the specified module builds."""
|
||||
module = db.session.query(database.Module).filter_by(id=id).first()
|
||||
module = db.session.query(rida.database.Module).filter_by(id=id).first()
|
||||
if module:
|
||||
tasks = dict()
|
||||
if module.state != "init":
|
||||
for build in db.session.query(database.Build).filter_by(module_id=id).all():
|
||||
for build in db.session.query(rida.database.Build).filter_by(module_id=id).all():
|
||||
tasks[build.format + "/" + build.package] = \
|
||||
str(build.task) + "/" + build.state
|
||||
return json.dumps({
|
||||
@@ -145,4 +146,4 @@ if __name__ == "__main__":
|
||||
ssl_ctx.verify_mode = ssl.CERT_OPTIONAL
|
||||
ssl_ctx.load_verify_locations(cafile=conf.ssl_ca_certificate_file)
|
||||
|
||||
app.run(request_handler=auth.ClientCertRequestHandler, ssl_context=ssl_ctx)
|
||||
app.run(request_handler = rida.auth.ClientCertRequestHandler, ssl_context=ssl_ctx)
|
||||
|
||||
Reference in New Issue
Block a user