From 9395650eb5b0f59d30394d984c16ce04efa1f8a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0abata?= Date: Wed, 29 Jun 2016 18:13:45 +0200 Subject: [PATCH] Extend the module build submission handler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is still not done. See all the FIXMEs. Oh my. Signed-off-by: Petr Ĺ abata --- rida.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/rida.py b/rida.py index b7cf7e3d..2fbc4fbc 100755 --- a/rida.py +++ b/rida.py @@ -39,6 +39,7 @@ This is the implementation of the orchestrator's public RESTful API. from flask import Flask, request from rida import config, database import json +import modulemd app = Flask(__name__) app.config.from_envvar("RIDA_SETTINGS", silent=True) @@ -67,6 +68,29 @@ def submit_build(): if not urlallowed: # The submitted scmurl isn't allowed return "", 403 + # FIXME: Use the scm class to obtain modulemd + # for the next step we're pretending "yaml" contains + # the contents of the modulemd yaml file + yaml = str() + mmd = modulemd.ModuleMetadata() + try: + mmd.loads(yaml) + except: + # Invalid modulemd + return "", 422 + module = database.Module(name=mmd.name, version=mmd.version, + release=mmd.release, state="init", modulemd=yaml) + db.session.add(module) + db.session.commit() + # FIXME: Use the validation class to determine whether + # 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") + db.session.add(build) + module.state = "wait" + db.session.add(module) + db.session.commit() return "Not implemented yet.", 501 @app.route("/rida/module-builds/", methods=["GET"])