diff --git a/lorax-composer/.buildinfo b/lorax-composer/.buildinfo index 2447dcf4..0c9503e4 100644 --- a/lorax-composer/.buildinfo +++ b/lorax-composer/.buildinfo @@ -1,4 +1,4 @@ # Sphinx build info version 1 # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. -config: d0036b060ae50548427b7f3aa21363e9 +config: 47a43b17a6d818b63830719359188b5e tags: fbb0d17656682115ca4d033fb2f83ba1 diff --git a/lorax-composer/.doctrees/composer.cli.doctree b/lorax-composer/.doctrees/composer.cli.doctree index 77e24c51..aecf724b 100644 Binary files a/lorax-composer/.doctrees/composer.cli.doctree and b/lorax-composer/.doctrees/composer.cli.doctree differ diff --git a/lorax-composer/.doctrees/composer.doctree b/lorax-composer/.doctrees/composer.doctree index 670a404d..a98204ad 100644 Binary files a/lorax-composer/.doctrees/composer.doctree and b/lorax-composer/.doctrees/composer.doctree differ diff --git a/lorax-composer/.doctrees/environment.pickle b/lorax-composer/.doctrees/environment.pickle index a3d916ee..01c8414c 100644 Binary files a/lorax-composer/.doctrees/environment.pickle and b/lorax-composer/.doctrees/environment.pickle differ diff --git a/lorax-composer/.doctrees/lorax-composer.doctree b/lorax-composer/.doctrees/lorax-composer.doctree index 8f64c815..bc65bfbe 100644 Binary files a/lorax-composer/.doctrees/lorax-composer.doctree and b/lorax-composer/.doctrees/lorax-composer.doctree differ diff --git a/lorax-composer/.doctrees/lorax.doctree b/lorax-composer/.doctrees/lorax.doctree index c4730d86..dbc7b16f 100644 Binary files a/lorax-composer/.doctrees/lorax.doctree and b/lorax-composer/.doctrees/lorax.doctree differ diff --git a/lorax-composer/.doctrees/pylorax.api.doctree b/lorax-composer/.doctrees/pylorax.api.doctree index 7e4e3ac0..2ef7e0a6 100644 Binary files a/lorax-composer/.doctrees/pylorax.api.doctree and b/lorax-composer/.doctrees/pylorax.api.doctree differ diff --git a/lorax-composer/.doctrees/pylorax.doctree b/lorax-composer/.doctrees/pylorax.doctree index 7b33f334..b40cd9a1 100644 Binary files a/lorax-composer/.doctrees/pylorax.doctree and b/lorax-composer/.doctrees/pylorax.doctree differ diff --git a/lorax-composer/_modules/composer/cli.html b/lorax-composer/_modules/composer/cli.html index 2540b689..44a7b85e 100644 --- a/lorax-composer/_modules/composer/cli.html +++ b/lorax-composer/_modules/composer/cli.html @@ -8,7 +8,7 @@ - composer.cli — Lorax 19.7.11 documentation + composer.cli — Lorax 19.7.14 documentation @@ -16,7 +16,7 @@ - + @@ -38,7 +38,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • @@ -71,13 +71,13 @@ import logging log = logging.getLogger("composer-cli") -from composer.cli.recipes import recipes_cmd +from composer.cli.blueprints import blueprints_cmd from composer.cli.modules import modules_cmd from composer.cli.projects import projects_cmd from composer.cli.compose import compose_cmd command_map = { - "recipes": recipes_cmd, + "blueprints": blueprints_cmd, "modules": modules_cmd, "projects": projects_cmd, "compose": compose_cmd @@ -138,7 +138,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • diff --git a/lorax-composer/_modules/composer/cli/blueprints.html b/lorax-composer/_modules/composer/cli/blueprints.html new file mode 100644 index 00000000..ee9cddc7 --- /dev/null +++ b/lorax-composer/_modules/composer/cli/blueprints.html @@ -0,0 +1,616 @@ + + + + + + + + + + composer.cli.blueprints — Lorax 19.7.14 documentation + + + + + + + + + + + + + + +
    +
    +
    +
    + +

    Source code for composer.cli.blueprints

    +#
    +# Copyright (C) 2018  Red Hat, Inc.
    +#
    +# This program is free software; you can redistribute it and/or modify
    +# it under the terms of the GNU General Public License as published by
    +# the Free Software Foundation; either version 2 of the License, or
    +# (at your option) any later version.
    +#
    +# This program is distributed in the hope that it will be useful,
    +# but WITHOUT ANY WARRANTY; without even the implied warranty of
    +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    +# GNU General Public License for more details.
    +#
    +# You should have received a copy of the GNU General Public License
    +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
    +#
    +import logging
    +log = logging.getLogger("composer-cli")
    +
    +import os
    +import json
    +
    +from composer import http_client as client
    +from composer.cli.utilities import argify, frozen_toml_filename, toml_filename, handle_api_result
    +from composer.cli.utilities import packageNEVRA
    +
    +
    [docs]def blueprints_cmd(opts): + """Process blueprints commands + + :param opts: Cmdline arguments + :type opts: argparse.Namespace + :returns: Value to return from sys.exit() + :rtype: int + + This dispatches the blueprints commands to a function + """ + cmd_map = { + "list": blueprints_list, + "show": blueprints_show, + "changes": blueprints_changes, + "diff": blueprints_diff, + "save": blueprints_save, + "delete": blueprints_delete, + "depsolve": blueprints_depsolve, + "push": blueprints_push, + "freeze": blueprints_freeze, + "tag": blueprints_tag, + "undo": blueprints_undo, + "workspace": blueprints_workspace + } + if opts.args[1] not in cmd_map: + log.error("Unknown blueprints command: %s", opts.args[1]) + return 1 + + return cmd_map[opts.args[1]](opts.socket, opts.api_version, opts.args[2:], opts.json) +
    +
    [docs]def blueprints_list(socket_path, api_version, args, show_json=False): + """Output the list of available blueprints + + :param socket_path: Path to the Unix socket to use for API communication + :type socket_path: str + :param api_version: Version of the API to talk to. eg. "0" + :type api_version: str + :param args: List of remaining arguments from the cmdline + :type args: list of str + :param show_json: Set to True to show the JSON output instead of the human readable output + :type show_json: bool + + blueprints list + """ + api_route = client.api_url(api_version, "/blueprints/list") + result = client.get_url_json(socket_path, api_route) + if show_json: + print(json.dumps(result, indent=4)) + return 0 + + print("blueprints: " + ", ".join([r for r in result["blueprints"]])) + + return 0 +
    +
    [docs]def blueprints_show(socket_path, api_version, args, show_json=False): + """Show the blueprints, in TOML format + + :param socket_path: Path to the Unix socket to use for API communication + :type socket_path: str + :param api_version: Version of the API to talk to. eg. "0" + :type api_version: str + :param args: List of remaining arguments from the cmdline + :type args: list of str + :param show_json: Set to True to show the JSON output instead of the human readable output + :type show_json: bool + + blueprints show <blueprint,...> Display the blueprint in TOML format. + + Multiple blueprints will be separated by \n\n + """ + for blueprint in argify(args): + api_route = client.api_url(api_version, "/blueprints/info/%s?format=toml" % blueprint) + print(client.get_url_raw(socket_path, api_route) + "\n\n") + + return 0 +
    +
    [docs]def blueprints_changes(socket_path, api_version, args, show_json=False): + """Display the changes for each of the blueprints + + :param socket_path: Path to the Unix socket to use for API communication + :type socket_path: str + :param api_version: Version of the API to talk to. eg. "0" + :type api_version: str + :param args: List of remaining arguments from the cmdline + :type args: list of str + :param show_json: Set to True to show the JSON output instead of the human readable output + :type show_json: bool + + blueprints changes <blueprint,...> Display the changes for each blueprint. + """ + api_route = client.api_url(api_version, "/blueprints/changes/%s" % (",".join(argify(args)))) + result = client.get_url_json(socket_path, api_route) + if show_json: + print(json.dumps(result, indent=4)) + return 0 + + for blueprint in result["blueprints"]: + print(blueprint["name"]) + for change in blueprint["changes"]: + prettyCommitDetails(change) + + return 0 +
    +
    [docs]def prettyCommitDetails(change, indent=4): + """Print the blueprint's change in a nice way + + :param change: The individual blueprint change dict + :type change: dict + :param indent: Number of spaces to indent + :type indent: int + """ + def revision(): + if change["revision"]: + return " revision %d" % change["revision"] + else: + return "" + + print " " * indent + change["timestamp"] + " " + change["commit"] + revision() + print " " * indent + change["message"] + "\n" +
    +
    [docs]def blueprints_diff(socket_path, api_version, args, show_json=False): + """Display the differences between 2 versions of a blueprint + + :param socket_path: Path to the Unix socket to use for API communication + :type socket_path: str + :param api_version: Version of the API to talk to. eg. "0" + :type api_version: str + :param args: List of remaining arguments from the cmdline + :type args: list of str + :param show_json: Set to True to show the JSON output instead of the human readable output + :type show_json: bool + + blueprints diff <blueprint-name> Display the differences between 2 versions of a blueprint. + <from-commit> Commit hash or NEWEST + <to-commit> Commit hash, NEWEST, or WORKSPACE + """ + if len(args) == 0: + log.error("blueprints diff is missing the blueprint name, from commit, and to commit") + return 1 + elif len(args) == 1: + log.error("blueprints diff is missing the from commit, and the to commit") + return 1 + elif len(args) == 2: + log.error("blueprints diff is missing the to commit") + return 1 + + api_route = client.api_url(api_version, "/blueprints/diff/%s/%s/%s" % (args[0], args[1], args[2])) + result = client.get_url_json(socket_path, api_route) + + if show_json: + print(json.dumps(result, indent=4)) + return 0 + + for err in result.get("errors", []): + log.error(err) + + if result.get("errors", False): + return 1 + + for diff in result["diff"]: + print(prettyDiffEntry(diff)) + + return 0 +
    +
    [docs]def prettyDiffEntry(diff): + """Generate nice diff entry string. + + :param diff: Difference entry dict + :type diff: dict + :returns: Nice string + """ + def change(diff): + if diff["old"] and diff["new"]: + return "Changed" + elif diff["new"] and not diff["old"]: + return "Added" + elif diff["old"] and not diff["new"]: + return "Removed" + else: + return "Unknown" + + def name(diff): + if diff["old"]: + return diff["old"].keys()[0] + elif diff["new"]: + return diff["new"].keys()[0] + else: + return "Unknown" + + def details(diff): + if change(diff) == "Changed": + if name(diff) == "Description": + return '"%s" -> "%s"' % (diff["old"][name(diff)], diff["new"][name(diff)]) + elif name(diff) == "Version": + return "%s -> %s" % (diff["old"][name(diff)], diff["new"][name(diff)]) + elif name(diff) in ["Module", "Package"]: + return "%s %s -> %s" % (diff["old"][name(diff)]["name"], diff["old"][name(diff)]["version"], + diff["new"][name(diff)]["version"]) + else: + return "Unknown" + elif change(diff) == "Added": + if name(diff) in ["Module", "Package"]: + return "%s %s" % (diff["new"][name(diff)]["name"], diff["new"][name(diff)]["version"]) + else: + return " ".join([diff["new"][k] for k in diff["new"]]) + elif change(diff) == "Removed": + if name(diff) in ["Module", "Package"]: + return "%s %s" % (diff["old"][name(diff)]["name"], diff["old"][name(diff)]["version"]) + else: + return " ".join([diff["old"][k] for k in diff["old"]]) + + return change(diff) + " " + name(diff) + " " + details(diff) +
    +
    [docs]def blueprints_save(socket_path, api_version, args, show_json=False): + """Save the blueprint to a TOML file + + :param socket_path: Path to the Unix socket to use for API communication + :type socket_path: str + :param api_version: Version of the API to talk to. eg. "0" + :type api_version: str + :param args: List of remaining arguments from the cmdline + :type args: list of str + :param show_json: Set to True to show the JSON output instead of the human readable output + :type show_json: bool + + blueprints save <blueprint,...> Save the blueprint to a file, <blueprint-name>.toml + """ + for blueprint in argify(args): + api_route = client.api_url(api_version, "/blueprints/info/%s?format=toml" % blueprint) + blueprint_toml = client.get_url_raw(socket_path, api_route) + open(toml_filename(blueprint), "w").write(blueprint_toml) + + return 0 +
    +
    [docs]def blueprints_delete(socket_path, api_version, args, show_json=False): + """Delete a blueprint from the server + + :param socket_path: Path to the Unix socket to use for API communication + :type socket_path: str + :param api_version: Version of the API to talk to. eg. "0" + :type api_version: str + :param args: List of remaining arguments from the cmdline + :type args: list of str + :param show_json: Set to True to show the JSON output instead of the human readable output + :type show_json: bool + + delete <blueprint> Delete a blueprint from the server + """ + api_route = client.api_url(api_version, "/blueprints/delete/%s" % args[0]) + result = client.delete_url_json(socket_path, api_route) + + return handle_api_result(result, show_json) +
    +
    [docs]def blueprints_depsolve(socket_path, api_version, args, show_json=False): + """Display the packages needed to install the blueprint + + :param socket_path: Path to the Unix socket to use for API communication + :type socket_path: str + :param api_version: Version of the API to talk to. eg. "0" + :type api_version: str + :param args: List of remaining arguments from the cmdline + :type args: list of str + :param show_json: Set to True to show the JSON output instead of the human readable output + :type show_json: bool + + blueprints depsolve <blueprint,...> Display the packages needed to install the blueprint. + """ + api_route = client.api_url(api_version, "/blueprints/depsolve/%s" % (",".join(argify(args)))) + result = client.get_url_json(socket_path, api_route) + + if show_json: + print(json.dumps(result, indent=4)) + return 0 + + for blueprint in result["blueprints"]: + if blueprint["blueprint"].get("version", ""): + print("blueprint: %s v%s" % (blueprint["blueprint"]["name"], blueprint["blueprint"]["version"])) + else: + print("blueprint: %s" % (blueprint["blueprint"]["name"])) + for dep in blueprint["dependencies"]: + print(" " + packageNEVRA(dep)) + + return 0 +
    +
    [docs]def blueprints_push(socket_path, api_version, args, show_json=False): + """Push a blueprint TOML file to the server, updating the blueprint + + :param socket_path: Path to the Unix socket to use for API communication + :type socket_path: str + :param api_version: Version of the API to talk to. eg. "0" + :type api_version: str + :param args: List of remaining arguments from the cmdline + :type args: list of str + :param show_json: Set to True to show the JSON output instead of the human readable output + :type show_json: bool + + push <blueprint> Push a blueprint TOML file to the server. + """ + api_route = client.api_url(api_version, "/blueprints/new") + rval = 0 + for blueprint in argify(args): + if not os.path.exists(blueprint): + log.error("Missing blueprint file: %s", blueprint) + continue + blueprint_toml = open(blueprint, "r").read() + + result = client.post_url_toml(socket_path, api_route, blueprint_toml) + if handle_api_result(result, show_json): + rval = 1 + + return rval +
    +
    [docs]def blueprints_freeze(socket_path, api_version, args, show_json=False): + """Handle the blueprints freeze commands + + :param socket_path: Path to the Unix socket to use for API communication + :type socket_path: str + :param api_version: Version of the API to talk to. eg. "0" + :type api_version: str + :param args: List of remaining arguments from the cmdline + :type args: list of str + :param show_json: Set to True to show the JSON output instead of the human readable output + :type show_json: bool + + blueprints freeze <blueprint,...> Display the frozen blueprint's modules and packages. + blueprints freeze show <blueprint,...> Display the frozen blueprint in TOML format. + blueprints freeze save <blueprint,...> Save the frozen blueprint to a file, <blueprint-name>.frozen.toml. + """ + if args[0] == "show": + return blueprints_freeze_show(socket_path, api_version, args[1:], show_json) + elif args[0] == "save": + return blueprints_freeze_save(socket_path, api_version, args[1:], show_json) + + if len(args) == 0: + log.error("freeze is missing the blueprint name") + return 1 + + api_route = client.api_url(api_version, "/blueprints/freeze/%s" % (",".join(argify(args)))) + result = client.get_url_json(socket_path, api_route) + + if show_json: + print(json.dumps(result, indent=4)) + else: + for entry in result["blueprints"]: + blueprint = entry["blueprint"] + if blueprint.get("version", ""): + print("blueprint: %s v%s" % (blueprint["name"], blueprint["version"])) + else: + print("blueprint: %s" % (blueprint["name"])) + + for m in blueprint["modules"]: + print(" %s-%s" % (m["name"], m["version"])) + + for p in blueprint["packages"]: + print(" %s-%s" % (p["name"], p["version"])) + + # Print any errors + for err in result.get("errors", []): + log.error(err) + + # Return a 1 if there are any errors + if result.get("errors", []): + return 1 + else: + return 0 +
    +
    [docs]def blueprints_freeze_show(socket_path, api_version, args, show_json=False): + """Show the frozen blueprint in TOML format + + :param socket_path: Path to the Unix socket to use for API communication + :type socket_path: str + :param api_version: Version of the API to talk to. eg. "0" + :type api_version: str + :param args: List of remaining arguments from the cmdline + :type args: list of str + :param show_json: Set to True to show the JSON output instead of the human readable output + :type show_json: bool + + blueprints freeze show <blueprint,...> Display the frozen blueprint in TOML format. + """ + if len(args) == 0: + log.error("freeze show is missing the blueprint name") + return 1 + + for blueprint in argify(args): + api_route = client.api_url(api_version, "/blueprints/freeze/%s?format=toml" % blueprint) + print(client.get_url_raw(socket_path, api_route)) + + return 0 +
    +
    [docs]def blueprints_freeze_save(socket_path, api_version, args, show_json=False): + """Save the frozen blueprint to a TOML file + + :param socket_path: Path to the Unix socket to use for API communication + :type socket_path: str + :param api_version: Version of the API to talk to. eg. "0" + :type api_version: str + :param args: List of remaining arguments from the cmdline + :type args: list of str + :param show_json: Set to True to show the JSON output instead of the human readable output + :type show_json: bool + + blueprints freeze save <blueprint,...> Save the frozen blueprint to a file, <blueprint-name>.frozen.toml. + """ + if len(args) == 0: + log.error("freeze save is missing the blueprint name") + return 1 + + for blueprint in argify(args): + api_route = client.api_url(api_version, "/blueprints/freeze/%s?format=toml" % blueprint) + blueprint_toml = client.get_url_raw(socket_path, api_route) + open(frozen_toml_filename(blueprint), "w").write(blueprint_toml) + + return 0 +
    +
    [docs]def blueprints_tag(socket_path, api_version, args, show_json=False): + """Tag the most recent blueprint commit as a release + + :param socket_path: Path to the Unix socket to use for API communication + :type socket_path: str + :param api_version: Version of the API to talk to. eg. "0" + :type api_version: str + :param args: List of remaining arguments from the cmdline + :type args: list of str + :param show_json: Set to True to show the JSON output instead of the human readable output + :type show_json: bool + + blueprints tag <blueprint> Tag the most recent blueprint commit as a release. + """ + api_route = client.api_url(api_version, "/blueprints/tag/%s" % args[0]) + result = client.post_url(socket_path, api_route, "") + + return handle_api_result(result, show_json) +
    +
    [docs]def blueprints_undo(socket_path, api_version, args, show_json=False): + """Undo changes to a blueprint + + :param socket_path: Path to the Unix socket to use for API communication + :type socket_path: str + :param api_version: Version of the API to talk to. eg. "0" + :type api_version: str + :param args: List of remaining arguments from the cmdline + :type args: list of str + :param show_json: Set to True to show the JSON output instead of the human readable output + :type show_json: bool + + blueprints undo <blueprint> <commit> Undo changes to a blueprint by reverting to the selected commit. + """ + if len(args) == 0: + log.error("undo is missing the blueprint name and commit hash") + return 1 + elif len(args) == 1: + log.error("undo is missing commit hash") + return 1 + + api_route = client.api_url(api_version, "/blueprints/undo/%s/%s" % (args[0], args[1])) + result = client.post_url(socket_path, api_route, "") + + return handle_api_result(result, show_json) +
    +
    [docs]def blueprints_workspace(socket_path, api_version, args, show_json=False): + """Push the blueprint TOML to the temporary workspace storage + + :param socket_path: Path to the Unix socket to use for API communication + :type socket_path: str + :param api_version: Version of the API to talk to. eg. "0" + :type api_version: str + :param args: List of remaining arguments from the cmdline + :type args: list of str + :param show_json: Set to True to show the JSON output instead of the human readable output + :type show_json: bool + + blueprints workspace <blueprint> Push the blueprint TOML to the temporary workspace storage. + """ + api_route = client.api_url(api_version, "/blueprints/workspace") + rval = 0 + for blueprint in argify(args): + if not os.path.exists(blueprint): + log.error("Missing blueprint file: %s", blueprint) + continue + blueprint_toml = open(blueprint, "r").read() + + result = client.post_url_toml(socket_path, api_route, blueprint_toml) + if show_json: + print(json.dumps(result, indent=4)) + + for err in result.get("errors", []): + log.error(err) + + # Any errors results in returning a 1, but we continue with the rest first + if not result.get("status", False): + rval = 1 + + return rval
    +
    + +
    +
    +
    +
    +
    + + +
    +
    +
    +
    + + + + \ No newline at end of file diff --git a/lorax-composer/_modules/composer/cli/compose.html b/lorax-composer/_modules/composer/cli/compose.html index ec3c5388..88d4c88d 100644 --- a/lorax-composer/_modules/composer/cli/compose.html +++ b/lorax-composer/_modules/composer/cli/compose.html @@ -8,7 +8,7 @@ - composer.cli.compose — Lorax 19.7.11 documentation + composer.cli.compose — Lorax 19.7.14 documentation @@ -16,7 +16,7 @@ - + @@ -38,7 +38,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • composer.cli »
  • @@ -115,20 +115,24 @@ :type args: list of str :param show_json: Set to True to show the JSON output instead of the human readable output :type show_json: bool + :param testmode: unused in this function + :type testmode: int This doesn't map directly to an API command, it combines the results from queue, finished, and failed so raw JSON output is not available. """ def get_status(compose): return {"id": compose["id"], - "recipe": compose["recipe"], + "blueprint": compose["blueprint"], "version": compose["version"], + "compose_type": compose["compose_type"], + "image_size": compose["image_size"], "status": compose["queue_status"]} # Sort the status in a specific order def sort_status(a): order = ["RUNNING", "WAITING", "FINISHED", "FAILED"] - return (order.index(a["status"]), a["recipe"], a["version"]) + return (order.index(a["status"]), a["blueprint"], a["version"], a["compose_type"]) status = [] @@ -154,12 +158,18 @@ print(json.dumps(status, indent=4)) return 0 - # Print them as UUID RECIPE STATUS + # Print them as UUID blueprint STATUS for c in status: - print("%s %-8s %-15s %s" % (c["id"], c["status"], c["recipe"], c["version"])) + if c["image_size"] > 0: + image_size = str(c["image_size"]) + else: + image_size = "" + + print("%s %-8s %-15s %s %-16s %s" % (c["id"], c["status"], c["blueprint"], c["version"], c["compose_type"], + image_size)) -
    [docs]def compose_types(socket_path, api_version, args, show_json=False): +
    [docs]def compose_types(socket_path, api_version, args, show_json=False, testmode=0): """Return information about the supported compose types :param socket_path: Path to the Unix socket to use for API communication @@ -170,6 +180,8 @@ :type args: list of str :param show_json: Set to True to show the JSON output instead of the human readable output :type show_json: bool + :param testmode: unused in this function + :type testmode: int Add additional details to types that are known to composer-cli. Raw JSON output does not include this extra information. @@ -183,7 +195,7 @@ print("Compose Types: " + ", ".join([t["name"] for t in result["types"]]))
    [docs]def compose_start(socket_path, api_version, args, show_json=False, testmode=0): - """Start a new compose using the selected recipe and type + """Start a new compose using the selected blueprint and type :param socket_path: Path to the Unix socket to use for API communication :type socket_path: str @@ -193,18 +205,20 @@ :type args: list of str :param show_json: Set to True to show the JSON output instead of the human readable output :type show_json: bool + :param testmode: Set to 1 to simulate a failed compose, set to 2 to simulate a finished one. + :type testmode: int - compose start <recipe-name> <compose-type> + compose start <blueprint-name> <compose-type> """ if len(args) == 0: - log.error("start is missing the recipe name and output type") + log.error("start is missing the blueprint name and output type") return 1 if len(args) == 1: log.error("start is missing the output type") return 1 config = { - "recipe_name": args[0], + "blueprint_name": args[0], "compose_type": args[1], "branch": "master" } @@ -219,11 +233,10 @@ print(json.dumps(result, indent=4)) return 0 - if result.get("error", False): - log.error(result["error"]["msg"]) - return 1 + for err in result.get("errors", []): + log.error(err) - if result["status"] == False: + if result["status"] == False or result.get("errors", False): return 1 print("Compose %s added to the queue" % result["build_id"]) @@ -240,6 +253,8 @@ :type args: list of str :param show_json: Set to True to show the JSON output instead of the human readable output :type show_json: bool + :param testmode: unused in this function + :type testmode: int compose log <uuid> [<size>kB] @@ -259,9 +274,14 @@ log_size = 1024 api_route = client.api_url(api_version, "/compose/log/%s?size=%d" % (args[0], log_size)) - result = client.get_url_raw(socket_path, api_route) + try: + result = client.get_url_raw(socket_path, api_route) + except RuntimeError as e: + print(str(e)) + return 1 print(result) + return 0
    [docs]def compose_cancel(socket_path, api_version, args, show_json=False, testmode=0): """Cancel a running compose @@ -274,6 +294,8 @@ :type args: list of str :param show_json: Set to True to show the JSON output instead of the human readable output :type show_json: bool + :param testmode: unused in this function + :type testmode: int compose cancel <uuid> @@ -298,6 +320,8 @@ :type args: list of str :param show_json: Set to True to show the JSON output instead of the human readable output :type show_json: bool + :param testmode: unused in this function + :type testmode: int compose delete <uuid,...> @@ -317,7 +341,7 @@ # Print any errors for err in result.get("errors", []): - log.error("%s: %s", err["uuid"], err["msg"]) + log.error(err) if result.get("errors", []): return 1 @@ -335,10 +359,12 @@ :type args: list of str :param show_json: Set to True to show the JSON output instead of the human readable output :type show_json: bool + :param testmode: unused in this function + :type testmode: int compose details <uuid> - This returns information about the compose, including the recipe and the dependencies. + This returns information about the compose, including the blueprint and the dependencies. """ if len(args) == 0: log.error("details is missing the compose build id") @@ -350,17 +376,30 @@ print(json.dumps(result, indent=4)) return 0 - print("%s %-8s %-15s %s %s" % (result["id"], - result["queue_status"], - result["recipe"]["name"], - result["recipe"]["version"], - result["compose_type"])) - print("Recipe Packages:") - for p in result["recipe"]["packages"]: + for err in result.get("errors", []): + log.error(err) + + if result.get("errors", []): + return 1 + + if result["image_size"] > 0: + image_size = str(result["image_size"]) + else: + image_size = "" + + + print("%s %-8s %-15s %s %-16s %s" % (result["id"], + result["queue_status"], + result["blueprint"]["name"], + result["blueprint"]["version"], + result["compose_type"], + image_size)) + print("Packages:") + for p in result["blueprint"]["packages"]: print(" %s-%s" % (p["name"], p["version"])) - print("Recipe Modules:") - for m in result["recipe"]["modules"]: + print("Modules:") + for m in result["blueprint"]["modules"]: print(" %s-%s" % (m["name"], m["version"])) print("Dependencies:") @@ -378,6 +417,8 @@ :type args: list of str :param show_json: Set to True to show the JSON output instead of the human readable output :type show_json: bool + :param testmode: unused in this function + :type testmode: int compose metadata <uuid> @@ -401,6 +442,8 @@ :type args: list of str :param show_json: Set to True to show the JSON output instead of the human readable output :type show_json: bool + :param testmode: unused in this function + :type testmode: int compose results <uuid> @@ -425,6 +468,8 @@ :type args: list of str :param show_json: Set to True to show the JSON output instead of the human readable output :type show_json: bool + :param testmode: unused in this function + :type testmode: int compose logs <uuid> @@ -448,6 +493,8 @@ :type args: list of str :param show_json: Set to True to show the JSON output instead of the human readable output :type show_json: bool + :param testmode: unused in this function + :type testmode: int compose image <uuid> @@ -493,7 +540,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • composer.cli »
  • diff --git a/lorax-composer/_modules/composer/cli/modules.html b/lorax-composer/_modules/composer/cli/modules.html index 17f2e574..844cc556 100644 --- a/lorax-composer/_modules/composer/cli/modules.html +++ b/lorax-composer/_modules/composer/cli/modules.html @@ -8,7 +8,7 @@ - composer.cli.modules — Lorax 19.7.11 documentation + composer.cli.modules — Lorax 19.7.14 documentation @@ -16,7 +16,7 @@ - + @@ -38,7 +38,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • composer.cli »
  • @@ -127,7 +127,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • composer.cli »
  • diff --git a/lorax-composer/_modules/composer/cli/projects.html b/lorax-composer/_modules/composer/cli/projects.html index 6a4d16ce..c782417e 100644 --- a/lorax-composer/_modules/composer/cli/projects.html +++ b/lorax-composer/_modules/composer/cli/projects.html @@ -8,7 +8,7 @@ - composer.cli.projects — Lorax 19.7.11 documentation + composer.cli.projects — Lorax 19.7.14 documentation @@ -16,7 +16,7 @@ - + @@ -38,7 +38,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • composer.cli »
  • @@ -189,7 +189,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • composer.cli »
  • diff --git a/lorax-composer/_modules/composer/cli/utilities.html b/lorax-composer/_modules/composer/cli/utilities.html index 2b1ad1d1..27be09ad 100644 --- a/lorax-composer/_modules/composer/cli/utilities.html +++ b/lorax-composer/_modules/composer/cli/utilities.html @@ -8,7 +8,7 @@ - composer.cli.utilities — Lorax 19.7.11 documentation + composer.cli.utilities — Lorax 19.7.14 documentation @@ -16,7 +16,7 @@ - + @@ -38,7 +38,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • composer.cli »
  • @@ -85,25 +85,25 @@ """ return filter(lambda i: i, [arg for entry in args for arg in entry.split(",")])
    -
    [docs]def toml_filename(recipe_name): - """Convert a recipe name into a filename.toml +
    [docs]def toml_filename(blueprint_name): + """Convert a blueprint name into a filename.toml - :param recipe_name: The recipe's name - :type recipe_name: str - :returns: The recipe name with ' ' converted to - and .toml appended + :param blueprint_name: The blueprint's name + :type blueprint_name: str + :returns: The blueprint name with ' ' converted to - and .toml appended :rtype: str """ - return recipe_name.replace(" ", "-") + ".toml" + return blueprint_name.replace(" ", "-") + ".toml"
    -
    [docs]def frozen_toml_filename(recipe_name): - """Convert a recipe name into a filename.toml +
    [docs]def frozen_toml_filename(blueprint_name): + """Convert a blueprint name into a filename.toml - :param recipe_name: The recipe's name - :type recipe_name: str - :returns: The recipe name with ' ' converted to - and .toml appended + :param blueprint_name: The blueprint's name + :type blueprint_name: str + :returns: The blueprint name with ' ' converted to - and .toml appended :rtype: str """ - return recipe_name.replace(" ", "-") + ".frozen.toml" + return blueprint_name.replace(" ", "-") + ".frozen.toml"
    [docs]def handle_api_result(result, show_json=False): """Log any errors, return the correct value @@ -113,8 +113,9 @@ """ if show_json: print(json.dumps(result, indent=4)) - elif result.get("error", False): - log.error(result["error"]["msg"]) + + for err in result.get("errors", []): + log.error(err) if result["status"] == True: return 0 @@ -166,7 +167,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • composer.cli »
  • diff --git a/lorax-composer/_modules/composer/http_client.html b/lorax-composer/_modules/composer/http_client.html index f99caf7d..2026c29b 100644 --- a/lorax-composer/_modules/composer/http_client.html +++ b/lorax-composer/_modules/composer/http_client.html @@ -8,7 +8,7 @@ - composer.http_client — Lorax 19.7.11 documentation + composer.http_client — Lorax 19.7.14 documentation @@ -16,7 +16,7 @@ - + @@ -38,7 +38,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • @@ -98,6 +98,11 @@ """ http = UnixHTTPConnectionPool(socket_path) r = http.request("GET", url) + if r.status == 400: + err = json.loads(r.data.decode("utf-8")) + if "status" in err and err["status"] == False: + raise RuntimeError(", ".join(err["errors"])) + return r.data.decode('utf-8')
    [docs]def get_url_json(socket_path, url): @@ -146,7 +151,7 @@ return json.loads(r.data.decode("utf-8"))
    [docs]def post_url_toml(socket_path, url, body): - """POST a TOML recipe to the URL + """POST a TOML string to the URL :param socket_path: Path to the Unix socket to use for API communication :type socket_path: str @@ -218,7 +223,7 @@ if r.status == 400: err = json.loads(r.data.decode("utf-8")) if not err["status"]: - raise RuntimeError(err["error"]["msg"]) + raise RuntimeError(", ".join(err["errors"])) filename = get_filename(r.headers) if os.path.exists(filename): @@ -278,7 +283,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • diff --git a/lorax-composer/_modules/composer/unix_socket.html b/lorax-composer/_modules/composer/unix_socket.html index e050e756..bffdc50f 100644 --- a/lorax-composer/_modules/composer/unix_socket.html +++ b/lorax-composer/_modules/composer/unix_socket.html @@ -8,7 +8,7 @@ - composer.unix_socket — Lorax 19.7.11 documentation + composer.unix_socket — Lorax 19.7.14 documentation @@ -16,7 +16,7 @@ - + @@ -38,7 +38,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • @@ -109,12 +109,7 @@ self.socket_path = socket_path def _new_conn(self): - return UnixHTTPConnection(self.socket_path, self.timeout) -
    -if __name__ == '__main__': - http = UnixHTTPConnectionPool("/var/run/weldr/api.socket") - r = http.request("GET", "/api/v0/recipes/list") - print(r.data) + return UnixHTTPConnection(self.socket_path, self.timeout) @@ -148,7 +143,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • diff --git a/lorax-composer/_modules/index.html b/lorax-composer/_modules/index.html index 29109e22..92c79f08 100644 --- a/lorax-composer/_modules/index.html +++ b/lorax-composer/_modules/index.html @@ -8,7 +8,7 @@ - Overview: module code — Lorax 19.7.11 documentation + Overview: module code — Lorax 19.7.14 documentation @@ -16,7 +16,7 @@ - + @@ -48,16 +48,15 @@

    All modules for which code is available

    diff --git a/lorax-composer/_modules/pylorax/api/compose.html b/lorax-composer/_modules/pylorax/api/compose.html index 8adb8505..571d5748 100644 --- a/lorax-composer/_modules/pylorax/api/compose.html +++ b/lorax-composer/_modules/pylorax/api/compose.html @@ -8,7 +8,7 @@ - pylorax.api.compose — Lorax 19.7.11 documentation + pylorax.api.compose — Lorax 19.7.14 documentation @@ -16,7 +16,7 @@ - + @@ -38,7 +38,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • pylorax.api »
  • @@ -88,13 +88,18 @@ import os from glob import glob +from math import ceil import pytoml as toml import shutil from uuid import uuid4 from pyanaconda.simpleconfig import SimpleConfigFile -from pylorax.api.projects import projects_depsolve, dep_nevra +# Use pykickstart to calculate disk image size +from pykickstart.parser import KickstartParser +from pykickstart.version import makeVersion, RHEL7 + +from pylorax.api.projects import projects_depsolve_with_size, dep_nevra from pylorax.api.projects import ProjectsError from pylorax.api.recipes import read_recipe_and_id from pylorax.imgutils import default_image_name @@ -171,11 +176,32 @@ deps = [] try: with yumlock.lock: - deps = projects_depsolve(yumlock.yb, projects) + (installed_size, deps) = projects_depsolve_with_size(yumlock.yb, projects, with_core=False) except ProjectsError as e: log.error("start_build depsolve: %s", str(e)) raise RuntimeError("Problem depsolving %s: %s" % (recipe["name"], str(e))) + # Read the kickstart template for this type + ks_template_path = joinpaths(share_dir, "composer", compose_type) + ".ks" + ks_template = open(ks_template_path, "r").read() + + # How much space will the packages in the default template take? + ks_version = makeVersion(RHEL7) + ks = KickstartParser(ks_version, errorsAreFatal=False, missingIncludeIsFatal=False) + ks.readKickstartFromString(ks_template+"\n%end\n") + try: + with yumlock.lock: + (template_size, _) = projects_depsolve_with_size(yumlock.yb, ks.handler.packages.packageList, + with_core=not ks.handler.packages.nocore) + except ProjectsError as e: + log.error("start_build depsolve: %s", str(e)) + raise RuntimeError("Problem depsolving %s: %s" % (recipe["name"], str(e))) + log.debug("installed_size = %d, template_size=%d", installed_size, template_size) + + # Minimum LMC disk size is 1GiB, and anaconda bumps the estimated size up by 35% (which doesn't always work). + installed_size = max(1024**3, int((installed_size+template_size) * 1.4)) + log.debug("/ partition size = %d", installed_size) + # Create the results directory build_id = str(uuid4()) results_dir = joinpaths(lib_dir, "results", build_id) @@ -187,7 +213,7 @@ f.write(commit_id) # Write the original recipe - recipe_path = joinpaths(results_dir, "recipe.toml") + recipe_path = joinpaths(results_dir, "blueprint.toml") with open(recipe_path, "w") as f: f.write(recipe.toml()) @@ -197,16 +223,14 @@ with open(recipe_path, "w") as f: f.write(frozen_recipe.toml()) - # Read the kickstart template for this type and copy it into the results - ks_template_path = joinpaths(share_dir, "composer", compose_type) + ".ks" - shutil.copy(ks_template_path, results_dir) - ks_template = open(ks_template_path, "r").read() - # Write out the dependencies to the results dir deps_path = joinpaths(results_dir, "deps.toml") with open(deps_path, "w") as f: f.write(toml.dumps({"packages":deps}).encode("UTF-8")) + # Save a copy of the original kickstart + shutil.copy(ks_template_path, results_dir) + # Create the final kickstart with repos and package list ks_path = joinpaths(results_dir, "final-kickstart.ks") with open(ks_path, "w") as f: @@ -223,6 +247,9 @@ log.debug("repo composer-%s = %s", idx, ks_repo) f.write('repo --name="composer-%s" %s\n' % (idx, ks_repo)) + # Write the root partition and it's size in MB (rounded up) + f.write('part / --fstype="ext4" --size=%d\n' % ceil(installed_size / 1024**2)) + f.write(ks_template) for d in deps: @@ -265,18 +292,18 @@ if test_mode > 0: open(joinpaths(results_dir, "TEST"), "w").write("%s" % test_mode) - log.info("Adding %s with recipe %s output type %s to compose queue", build_id, recipe["name"], compose_type) + log.info("Adding %s (%s %s) to compose queue", build_id, recipe["name"], compose_type) os.symlink(results_dir, joinpaths(lib_dir, "queue/new/", build_id)) return build_id # Supported output types
    [docs]def compose_types(share_dir): - """ Returns a list of the supported output types + r""" Returns a list of the supported output types - The output types come from the kickstart names in /usr/share/lorax/composer/*ks + The output types come from the kickstart names in /usr/share/lorax/composer/\*ks """ - return [os.path.basename(ks)[:-3] for ks in glob(joinpaths(share_dir, "composer/*.ks"))] + return sorted([os.path.basename(ks)[:-3] for ks in glob(joinpaths(share_dir, "composer/*.ks"))])
    [docs]def compose_args(compose_type): """ Returns the settings to pass to novirt_install for the compose type @@ -300,7 +327,7 @@ "live_rootfs_keep_size": False, "live_rootfs_size": 0, "qcow2": False, - "qcow2_arg": [], + "qcow2_args": [], "image_name": default_image_name("xz", "root.tar"), "image_only": True, "app_name": None, @@ -319,7 +346,7 @@ "live_rootfs_keep_size": False, "live_rootfs_size": 0, "qcow2": False, - "qcow2_arg": [], + "qcow2_args": [], "image_name": "live.iso", "fs_label": "Anaconda", # Live booting may expect this to be 'Anaconda' "image_only": False, @@ -339,7 +366,7 @@ "live_rootfs_keep_size": False, "live_rootfs_size": 0, "qcow2": False, - "qcow2_arg": [], + "qcow2_args": [], "image_name": "disk.img", "fs_label": "", "image_only": True, @@ -347,6 +374,46 @@ "app_template": None, "app_file": None }, + "qcow2": {"make_iso": False, + "make_disk": True, + "make_fsimage": False, + "make_appliance": False, + "make_ami": False, + "make_tar": False, + "make_pxe_live": False, + "make_ostree_live": False, + "ostree": False, + "live_rootfs_keep_size": False, + "live_rootfs_size": 0, + "qcow2": True, + "qcow2_args": [], + "image_name": "disk.qcow2", + "fs_label": "", + "image_only": True, + "app_name": None, + "app_template": None, + "app_file": None + }, + "ext4-filesystem": {"make_iso": False, + "make_disk": False, + "make_fsimage": True, + "make_appliance": False, + "make_ami": False, + "make_tar": False, + "make_pxe_live": False, + "make_ostree_live": False, + "ostree": False, + "live_rootfs_keep_size": False, + "live_rootfs_size": 0, + "qcow2": False, + "qcow2_args": [], + "image_name": "filesystem.img", + "fs_label": "", + "image_only": True, + "app_name": None, + "app_template": None, + "app_file": None + }, } return _MAP[compose_type]
    @@ -363,7 +430,7 @@ elif cfg["make_iso"]: # Output from live iso is always a boot.iso under images/, move and rename it shutil.move(joinpaths(cfg["result_dir"], "images/boot.iso"), joinpaths(results_dir, cfg["image_name"])) - elif cfg["make_disk"]: + elif cfg["make_disk"] or cfg["make_fsimage"]: shutil.move(joinpaths(cfg["result_dir"], cfg["image_name"]), joinpaths(results_dir, cfg["image_name"])) @@ -405,7 +472,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • pylorax.api »
  • diff --git a/lorax-composer/_modules/pylorax/api/config.html b/lorax-composer/_modules/pylorax/api/config.html index a03c0b10..24468a22 100644 --- a/lorax-composer/_modules/pylorax/api/config.html +++ b/lorax-composer/_modules/pylorax/api/config.html @@ -8,7 +8,7 @@ - pylorax.api.config — Lorax 19.7.11 documentation + pylorax.api.config — Lorax 19.7.14 documentation @@ -16,7 +16,7 @@ - + @@ -38,7 +38,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • pylorax.api »
  • @@ -98,6 +98,7 @@ conf.set("composer", "share_dir", os.path.realpath(joinpaths(root_dir, "/usr/share/lorax/"))) conf.set("composer", "lib_dir", os.path.realpath(joinpaths(root_dir, "/var/lib/lorax/composer/"))) conf.set("composer", "yum_conf", os.path.realpath(joinpaths(root_dir, "/var/tmp/composer/yum.conf"))) + conf.set("composer", "yum_root", os.path.realpath(joinpaths(root_dir, "/var/tmp/composer/yum/root/"))) conf.set("composer", "repo_dir", os.path.realpath(joinpaths(root_dir, "/var/tmp/composer/repos.d/"))) conf.set("composer", "cache_dir", os.path.realpath(joinpaths(root_dir, "/var/tmp/composer/cache/"))) @@ -123,7 +124,7 @@ :type conf: ComposerConfig :returns: None """ - for p in ["yum_conf", "repo_dir", "cache_dir"]: + for p in ["yum_conf", "repo_dir", "cache_dir", "yum_root"]: p_dir = os.path.dirname(conf.get("composer", p)) if not os.path.exists(p_dir): os.makedirs(p_dir) @@ -190,7 +191,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • pylorax.api »
  • diff --git a/lorax-composer/_modules/pylorax/api/crossdomain.html b/lorax-composer/_modules/pylorax/api/crossdomain.html index d30b6836..24c246df 100644 --- a/lorax-composer/_modules/pylorax/api/crossdomain.html +++ b/lorax-composer/_modules/pylorax/api/crossdomain.html @@ -8,7 +8,7 @@ - pylorax.api.crossdomain — Lorax 19.7.11 documentation + pylorax.api.crossdomain — Lorax 19.7.14 documentation @@ -16,7 +16,7 @@ - + @@ -38,7 +38,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • pylorax.api »
  • @@ -148,7 +148,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • pylorax.api »
  • diff --git a/lorax-composer/_modules/pylorax/api/projects.html b/lorax-composer/_modules/pylorax/api/projects.html index a62b4581..efd9def0 100644 --- a/lorax-composer/_modules/pylorax/api/projects.html +++ b/lorax-composer/_modules/pylorax/api/projects.html @@ -8,7 +8,7 @@ - pylorax.api.projects — Lorax 19.7.11 documentation + pylorax.api.projects — Lorax 19.7.14 documentation @@ -16,7 +16,7 @@ - + @@ -38,7 +38,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • pylorax.api »
  • @@ -136,7 +136,7 @@ metadata entries are hard-coded to {} """ - build = {"epoch": yaps.epoch, + build = {"epoch": int(yaps.epoch), "release": yaps.release, "arch": yaps.arch, "build_time": api_time(yaps.buildtime), @@ -166,7 +166,7 @@ :rtype: dict """ return {"name": tm.name, - "epoch": tm.epoch, + "epoch": int(tm.epoch), "version": tm.version, "release": tm.release, "arch": tm.arch} @@ -194,10 +194,10 @@ :returns: epoch:version-release.arch :rtype: str """ - if dep["epoch"] == "0": + if dep["epoch"] == 0: return dep["version"]+"-"+dep["release"]+"."+dep["arch"] else: - return dep["epoch"]+":"+dep["version"]+"-"+dep["release"]+"."+dep["arch"] + return str(dep["epoch"])+":"+dep["version"]+"-"+dep["release"]+"."+dep["arch"]
    [docs]def dep_nevra(dep): """Return the name-epoch:version-release.arch""" @@ -264,7 +264,55 @@ finally: yb.closeRpmDB() return deps +
    +
    [docs]def estimate_size(packages, block_size=4096): + """Estimate the installed size of a package list + :param packages: The packages to be installed + :type packages: list of TransactionMember objects + :param block_size: The block size to use for rounding up file sizes. + :type block_size: int + :returns: The estimated size of installed packages + :rtype: int + + Estimating actual requirements is difficult without the actual file sizes, which + yum doesn't provide access to. So use the file count and block size to estimate + a minimum size for each package. + """ + installed_size = 0 + for p in packages: + installed_size += len(p.po.filelist) * block_size + installed_size += p.po.installedsize + return installed_size +
    +
    [docs]def projects_depsolve_with_size(yb, project_names, with_core=True): + """Return the dependencies and installed size for a list of projects + + :param yb: yum base object + :type yb: YumBase + :param project_names: The projects to find the dependencies for + :type project_names: List of Strings + :returns: installed size and a list of NEVRA's of the project and its dependencies + :rtype: tuple of (int, list of dicts) + """ + try: + # This resets the transaction + yb.closeRpmDB() + for p in project_names: + yb.install(pattern=p) + if with_core: + yb.selectGroup("core", group_package_types=['mandatory', 'default', 'optional']) + (rc, msg) = yb.buildTransaction() + if rc not in [0, 1, 2]: + raise ProjectsError("There was a problem depsolving %s: %s" % (project_names, msg)) + yb.tsInfo.makelists() + installed_size = estimate_size(yb.tsInfo.installed + yb.tsInfo.depinstalled) + deps = sorted(map(tm_to_dep, yb.tsInfo.installed + yb.tsInfo.depinstalled), key=lambda p: p["name"].lower()) + except YumBaseError as e: + raise ProjectsError("There was a problem depsolving %s: %s" % (project_names, str(e))) + finally: + yb.closeRpmDB() + return (installed_size, deps)
    [docs]def modules_list(yb, module_names): """Return a list of modules @@ -347,7 +395,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • pylorax.api »
  • diff --git a/lorax-composer/_modules/pylorax/api/queue.html b/lorax-composer/_modules/pylorax/api/queue.html index eed563f9..5d493901 100644 --- a/lorax-composer/_modules/pylorax/api/queue.html +++ b/lorax-composer/_modules/pylorax/api/queue.html @@ -8,7 +8,7 @@ - pylorax.api.queue — Lorax 19.7.11 documentation + pylorax.api.queue — Lorax 19.7.14 documentation @@ -16,7 +16,7 @@ - + @@ -38,7 +38,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • pylorax.api »
  • @@ -158,7 +158,7 @@ make_compose(cfg, os.path.realpath(dst)) log.info("Finished building %s, results are in %s", dst, os.path.realpath(dst)) open(joinpaths(dst, "STATUS"), "w").write("FINISHED\n") - except Exception as e: + except Exception: import traceback log.error("traceback: %s", traceback.format_exc()) @@ -288,6 +288,7 @@ :type results_dir: str :returns: A dictionary with details about the compose :rtype: dict + :raises: IOError if it cannot read the directory, STATUS, or blueprint file. The following details are included in the dict: @@ -295,26 +296,30 @@ * queue_status - The final status of the composition (FINISHED or FAILED) * timestamp - The time of the last status change * compose_type - The type of output generated (tar, iso, etc.) - * recipe - Recipe name - * version - Recipe version + * blueprint - Blueprint name + * version - Blueprint version + * image_size - Size of the image, if finished. 0 otherwise. """ - # Just in case it went away - if not os.path.exists(results_dir): - return {} - build_id = os.path.basename(os.path.abspath(results_dir)) status = open(joinpaths(results_dir, "STATUS")).read().strip() mtime = os.stat(joinpaths(results_dir, "STATUS")).st_mtime - recipe = recipe_from_file(joinpaths(results_dir, "recipe.toml")) + blueprint = recipe_from_file(joinpaths(results_dir, "blueprint.toml")) compose_type = get_compose_type(results_dir) + image_path = get_image_name(results_dir)[1] + if status == "FINISHED" and os.path.exists(image_path): + image_size = os.stat(image_path).st_size + else: + image_size = 0 + return {"id": build_id, "queue_status": status, "timestamp": mtime, "compose_type": compose_type, - "recipe": recipe["name"], - "version": recipe["version"] + "blueprint": blueprint["name"], + "version": blueprint["version"], + "image_size": image_size }
    [docs]def queue_status(cfg): @@ -332,9 +337,25 @@ new_queue = [os.path.realpath(p) for p in glob(joinpaths(queue_dir, "new/*"))] run_queue = [os.path.realpath(p) for p in glob(joinpaths(queue_dir, "run/*"))] + new_details = [] + for n in new_queue: + try: + d = compose_detail(n) + except IOError: + continue + new_details.append(d) + + run_details = [] + for r in run_queue: + try: + d = compose_detail(r) + except IOError: + continue + run_details.append(d) + return { - "new": [compose_detail(n) for n in new_queue], - "run": [compose_detail(r) for r in run_queue] + "new": new_details, + "run": run_details }
    [docs]def uuid_status(cfg, uuid): @@ -350,9 +371,9 @@ Returns the same dict as `compose_details()` """ uuid_dir = joinpaths(cfg.get("composer", "lib_dir"), "results", uuid) - if os.path.exists(uuid_dir): + try: return compose_detail(uuid_dir) - else: + except IOError: return None
    [docs]def build_status(cfg, status_filter=None): @@ -379,9 +400,12 @@ for build in glob(result_dir + "/*"): log.debug("Checking status of build %s", build) - status = open(joinpaths(build, "STATUS"), "r").read().strip() - if status in status_filter: - results.append(compose_detail(build)) + try: + status = open(joinpaths(build, "STATUS"), "r").read().strip() + if status in status_filter: + results.append(compose_detail(build)) + except IOError: + pass return results
    [docs]def uuid_cancel(cfg, uuid): @@ -422,7 +446,7 @@ started = time.time() while True: status = uuid_status(cfg, uuid) - if status["queue_status"] == "FAILED": + if status is None or status["queue_status"] == "FAILED": break # Is this taking too long? Exit anyway and try to cleanup. @@ -467,8 +491,8 @@ * id - The uuid of the comoposition * config - containing the configuration settings used to run Anaconda - * recipe - The depsolved recipe used to generate the kickstart - * commit - The (local) git commit hash for the recipe used + * blueprint - The depsolved blueprint used to generate the kickstart + * commit - The (local) git commit hash for the blueprint used * deps - The NEVRA of all of the dependencies used in the composition * compose_type - The type of output generated (tar, iso, etc.) * queue_status - The final status of the composition (FINISHED or FAILED) @@ -493,19 +517,21 @@ raise RuntimeError("Missing deps.toml for %s" % uuid) deps_dict = toml.loads(open(deps_path, "r").read()) - compose_type = get_compose_type(uuid_dir) - status = open(joinpaths(uuid_dir, "STATUS")).read().strip() + details = compose_detail(uuid_dir) commit_path = joinpaths(uuid_dir, "COMMIT") + if not os.path.exists(commit_path): + raise RuntimeError("Missing commit hash for %s" % uuid) commit_id = open(commit_path, "r").read().strip() return {"id": uuid, "config": cfg_dict, - "recipe": frozen_dict, + "blueprint": frozen_dict, "commit": commit_id, "deps": deps_dict, - "compose_type": compose_type, - "queue_status": status + "compose_type": details["compose_type"], + "queue_status": details["queue_status"], + "image_size": details["image_size"] }
    [docs]def uuid_tar(cfg, uuid, metadata=False, image=False, logs=False): @@ -562,6 +588,18 @@ :raises: RuntimeError if there was a problem (eg. invalid uuid, missing config file) """ uuid_dir = joinpaths(cfg.get("composer", "lib_dir"), "results", uuid) + return get_image_name(uuid_dir) +
    +
    [docs]def get_image_name(uuid_dir): + """Return the filename and full path of the build's image file + + :param uuid: The UUID of the build + :type uuid: str + :returns: The image filename and full path + :rtype: tuple of strings + :raises: RuntimeError if there was a problem (eg. invalid uuid, missing config file) + """ + uuid = os.path.basename(os.path.abspath(uuid_dir)) if not os.path.exists(uuid_dir): raise RuntimeError("%s is not a valid build_id" % uuid) @@ -597,6 +635,9 @@ # While a build is running the logs will be in /tmp/anaconda.log and when it # has finished they will be in the results directory status = uuid_status(cfg, uuid) + if status is None: + raise RuntimeError("Status is missing for %s" % uuid) + if status["queue_status"] == "RUNNING": log_path = "/tmp/anaconda.log" else: @@ -647,7 +688,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • pylorax.api »
  • diff --git a/lorax-composer/_modules/pylorax/api/recipes.html b/lorax-composer/_modules/pylorax/api/recipes.html index 4bdaa9f1..029fd517 100644 --- a/lorax-composer/_modules/pylorax/api/recipes.html +++ b/lorax-composer/_modules/pylorax/api/recipes.html @@ -8,7 +8,7 @@ - pylorax.api.recipes — Lorax 19.7.11 documentation + pylorax.api.recipes — Lorax 19.7.14 documentation @@ -16,7 +16,7 @@ - + @@ -38,7 +38,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • pylorax.api »
  • @@ -556,7 +556,7 @@ builder.insert(filename, blob_id, Git.FileMode.BLOB) (tree, sig, ref) = prepare_commit(repo, branch, builder) commit_hash = commit_id.to_string() - message = "Recipe %s reverted to commit %s" % (filename, commit_hash) + message = "%s reverted to commit %s" % (filename, commit_hash) return repo.create_commit(ref, sig, sig, "UTF-8", message, tree, [parent_commit])
    [docs]def commit_recipe(repo, branch, recipe): @@ -604,13 +604,13 @@ return commit_recipe(repo, branch, recipe)
    [docs]def commit_recipe_directory(repo, branch, directory): - """Commit all *.toml files from a directory, if they aren't already in git. + r"""Commit all \*.toml files from a directory, if they aren't already in git. :param repo: Open repository :type repo: Git.Repository :param branch: Branch name :type branch: str - :param directory: The directory of *.toml recipes to commit + :param directory: The directory of \*.toml recipes to commit :type directory: str :returns: None :raises: Can raise errors from Ggit or RecipeFileError @@ -966,7 +966,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • pylorax.api »
  • diff --git a/lorax-composer/_modules/pylorax/api/server.html b/lorax-composer/_modules/pylorax/api/server.html index 66ca111f..967a8e4f 100644 --- a/lorax-composer/_modules/pylorax/api/server.html +++ b/lorax-composer/_modules/pylorax/api/server.html @@ -8,7 +8,7 @@ - pylorax.api.server — Lorax 19.7.11 documentation + pylorax.api.server — Lorax 19.7.14 documentation @@ -16,7 +16,7 @@ - + @@ -38,7 +38,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • pylorax.api »
  • @@ -71,10 +71,11 @@ log = logging.getLogger("lorax-composer") from collections import namedtuple -from flask import Flask, send_from_directory +from flask import Flask, jsonify, redirect, send_from_directory from glob import glob import os +from pylorax import vernum from pylorax.api.crossdomain import crossdomain from pylorax.api.v0 import v0_api from pylorax.sysutils import joinpaths @@ -87,9 +88,8 @@ __all__ = ["server", "GitLock"] @server.route('/') -@crossdomain(origin="*") -def hello_world(): - return 'Hello, World!' +def server_root(): + redirect("/api/docs/") @server.route("/api/docs/") @server.route("/api/docs/<path:path>") @@ -105,6 +105,28 @@ path="index.html" return send_from_directory(docs_path, path) +@server.route("/api/status") +@crossdomain(origin="*") +def v0_status(): + """ + `/api/v0/status` + ^^^^^^^^^^^^^^^^ + Return the status of the API Server:: + + { "api": "0", + "build": "devel", + "db_supported": true, + "db_version": "0", + "schema_version": "0", + "backend": "lorax-composer"} + """ + return jsonify(backend="lorax-composer", + build=vernum, + api="0", + db_version="0", + schema_version="0", + db_supported=True) + v0_api(server)
    @@ -139,7 +161,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • pylorax.api »
  • diff --git a/lorax-composer/_modules/pylorax/api/v0.html b/lorax-composer/_modules/pylorax/api/v0.html index 9a4abb01..b1438a96 100644 --- a/lorax-composer/_modules/pylorax/api/v0.html +++ b/lorax-composer/_modules/pylorax/api/v0.html @@ -8,7 +8,7 @@ - pylorax.api.v0 — Lorax 19.7.11 documentation + pylorax.api.v0 — Lorax 19.7.14 documentation @@ -16,7 +16,7 @@ - + @@ -38,7 +38,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • pylorax.api »
  • @@ -88,43 +88,26 @@ Error response:: { - "error": { - "msg": "ggit-error: Failed to remove entry. File isn't in the tree - jboss.toml (-1)" - }, + "errors": ["ggit-error: Failed to remove entry. File isn't in the tree - jboss.toml (-1)"] "status": false } API Routes ---------- -All of the recipes routes support the optional `branch` argument. If it is not -used then the API will use the `master` branch for recipes. If you want to create +All of the blueprints routes support the optional `branch` argument. If it is not +used then the API will use the `master` branch for blueprints. If you want to create a new branch use the `new` or `workspace` routes with ?branch=<branch-name> to -store the new recipe on the new branch. +store the new blueprint on the new branch. -`/api/v0/test` -^^^^^^^^^^^^^^ +`/api/v0/blueprints/list` +^^^^^^^^^^^^^^^^^^^^^^^^^ - Return a test string. It is not JSON encoded. - -`/api/v0/status` -^^^^^^^^^^^^^^^^ - Return the status of the API Server:: - - { "api": "0", - "build": "devel", - "db_supported": false, - "db_version": "0", - "schema_version": "0" } - -`/api/v0/recipes/list` -^^^^^^^^^^^^^^^^^^^^^^ - - List the available recipes:: + List the available blueprints:: { "limit": 20, "offset": 0, - "recipes": [ + "blueprints": [ "atlas", "development", "glusterfs", @@ -133,13 +116,13 @@ "kubernetes" ], "total": 6 } -`/api/v0/recipes/info/<recipe_names>` -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +`/api/v0/blueprints/info/<blueprint_names>` +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - Return the JSON representation of the recipe. This includes 3 top level + Return the JSON representation of the blueprint. This includes 3 top level objects. `changes` which lists whether or not the workspace is different from - the most recent commit. `recipes` which lists the JSON representation of the - recipe, and `errors` which will list any errors, like non-existant recipes. + the most recent commit. `blueprints` which lists the JSON representation of the + blueprint, and `errors` which will list any errors, like non-existant blueprints. Example:: @@ -151,7 +134,7 @@ } ], "errors": [], - "recipes": [ + "blueprints": [ { "description": "An example GlusterFS server with samba", "modules": [ @@ -184,22 +167,17 @@ { "changes": [], - "errors": [ - { - "msg": "ggit-error: the path 'missing.toml' does not exist in the given tree (-3)", - "recipe": "missing" - } - ], - "recipes": [] + "errors": ["ggit-error: the path 'missing.toml' does not exist in the given tree (-3)"] + "blueprints": [] } -`/api/v0/recipes/changes/<recipe_names>[?offset=0&limit=20]` -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +`/api/v0/blueprints/changes/<blueprint_names>[?offset=0&limit=20]` +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - Return the commits to a recipe. By default it returns the first 20 commits, this + Return the commits to a blueprint. By default it returns the first 20 commits, this can be changed by passing `offset` and/or `limit`. The response will include the commit hash, summary, timestamp, and optionally the revision number. The commit - hash can be passed to `/api/v0/recipes/diff/` to retrieve the exact changes. + hash can be passed to `/api/v0/blueprints/diff/` to retrieve the exact changes. Example:: @@ -207,42 +185,42 @@ "errors": [], "limit": 20, "offset": 0, - "recipes": [ + "blueprints": [ { "changes": [ { "commit": "e083921a7ed1cf2eec91ad12b9ad1e70ef3470be", - "message": "Recipe glusterfs, version 0.0.6 saved.", + "message": "blueprint glusterfs, version 0.0.6 saved.", "revision": null, "timestamp": "2017-11-23T00:18:13Z" }, { "commit": "cee5f4c20fc33ea4d54bfecf56f4ad41ad15f4f3", - "message": "Recipe glusterfs, version 0.0.5 saved.", + "message": "blueprint glusterfs, version 0.0.5 saved.", "revision": null, "timestamp": "2017-11-11T01:00:28Z" }, { "commit": "29b492f26ed35d80800b536623bafc51e2f0eff2", - "message": "Recipe glusterfs, version 0.0.4 saved.", + "message": "blueprint glusterfs, version 0.0.4 saved.", "revision": null, "timestamp": "2017-11-11T00:28:30Z" }, { "commit": "03374adbf080fe34f5c6c29f2e49cc2b86958bf2", - "message": "Recipe glusterfs, version 0.0.3 saved.", + "message": "blueprint glusterfs, version 0.0.3 saved.", "revision": null, "timestamp": "2017-11-10T23:15:52Z" }, { "commit": "0e08ecbb708675bfabc82952599a1712a843779d", - "message": "Recipe glusterfs, version 0.0.2 saved.", + "message": "blueprint glusterfs, version 0.0.2 saved.", "revision": null, "timestamp": "2017-11-10T23:14:56Z" }, { "commit": "3e11eb87a63d289662cba4b1804a0947a6843379", - "message": "Recipe glusterfs, version 0.0.1 saved.", + "message": "blueprint glusterfs, version 0.0.1 saved.", "revision": null, "timestamp": "2017-11-08T00:02:47Z" } @@ -253,71 +231,71 @@ ] } -POST `/api/v0/recipes/new` -^^^^^^^^^^^^^^^^^^^^^^^^^^ +POST `/api/v0/blueprints/new` +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - Create a new recipe, or update an existing recipe. This supports both JSON and TOML - for the recipe format. The recipe should be in the body of the request with the + Create a new blueprint, or update an existing blueprint. This supports both JSON and TOML + for the blueprint format. The blueprint should be in the body of the request with the `Content-Type` header set to either `application/json` or `text/x-toml`. The response will be a status response with `status` set to true, or an error response with it set to false and an error message included. -DELETE `/api/v0/recipes/delete/<recipe_name>` -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +DELETE `/api/v0/blueprints/delete/<blueprint_name>` +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - Delete a recipe. The recipe is deleted from the branch, and will no longer - be listed by the `list` route. A recipe can be undeleted using the `undo` route + Delete a blueprint. The blueprint is deleted from the branch, and will no longer + be listed by the `list` route. A blueprint can be undeleted using the `undo` route to revert to a previous commit. The response will be a status response with `status` set to true, or an error response with it set to false and an error message included. -POST `/api/v0/recipes/workspace` -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +POST `/api/v0/blueprints/workspace` +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - Write a recipe to the temporary workspace. This works exactly the same as `new` except + Write a blueprint to the temporary workspace. This works exactly the same as `new` except that it does not create a commit. JSON and TOML bodies are supported. - The workspace is meant to be used as a temporary recipe storage for clients. + The workspace is meant to be used as a temporary blueprint storage for clients. It will be read by the `info` and `diff` routes if it is different from the most recent commit. The response will be a status response with `status` set to true, or an error response with it set to false and an error message included. -DELETE `/api/v0/recipes/workspace/<recipe_name>` -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +DELETE `/api/v0/blueprints/workspace/<blueprint_name>` +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - Remove the temporary workspace copy of a recipe. The `info` route will now - return the most recent commit of the recipe. Any changes that were in the + Remove the temporary workspace copy of a blueprint. The `info` route will now + return the most recent commit of the blueprint. Any changes that were in the workspace will be lost. The response will be a status response with `status` set to true, or an error response with it set to false and an error message included. -POST `/api/v0/recipes/undo/<recipe_name>/<commit>` -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +POST `/api/v0/blueprints/undo/<blueprint_name>/<commit>` +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - This will revert the recipe to a previous commit. The commit hash from the `changes` + This will revert the blueprint to a previous commit. The commit hash from the `changes` route can be used in this request. The response will be a status response with `status` set to true, or an error response with it set to false and an error message included. -POST `/api/v0/recipes/tag/<recipe_name>` -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +POST `/api/v0/blueprints/tag/<blueprint_name>` +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - Tag a recipe as a new release. This uses git tags with a special format. - `refs/tags/<branch>/<filename>/r<revision>`. Only the most recent recipe commit + Tag a blueprint as a new release. This uses git tags with a special format. + `refs/tags/<branch>/<filename>/r<revision>`. Only the most recent blueprint commit can be tagged. Revisions start at 1 and increment for each new tag - (per-recipe). If the commit has already been tagged it will return false. + (per-blueprint). If the commit has already been tagged it will return false. The response will be a status response with `status` set to true, or an error response with it set to false and an error message included. -`/api/v0/recipes/diff/<recipe_name>/<from_commit>/<to_commit>` -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +`/api/v0/blueprints/diff/<blueprint_name>/<from_commit>/<to_commit>` +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Return the differences between two commits, or the workspace. The commit hash from the `changes` response can be used here, or several special strings: @@ -325,15 +303,15 @@ - NEWEST will select the newest git commit. This works for `from_commit` or `to_commit` - WORKSPACE will select the workspace copy. This can only be used in `to_commit` - eg. `/api/v0/recipes/diff/glusterfs/NEWEST/WORKSPACE` will return the differences + eg. `/api/v0/blueprints/diff/glusterfs/NEWEST/WORKSPACE` will return the differences between the most recent git commit and the contents of the workspace. - Each entry in the response's diff object contains the old recipe value and the new one. + Each entry in the response's diff object contains the old blueprint value and the new one. If old is null and new is set, then it was added. If new is null and old is set, then it was removed. If both are set, then it was changed. - The old/new entries will have the name of the recipe field that was changed. This + The old/new entries will have the name of the blueprint field that was changed. This can be one of: Name, Description, Version, Module, or Package. The contents for these will be the old/new values for them. @@ -363,19 +341,19 @@ ] } -`/api/v0/recipes/freeze/<recipe_names>` -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +`/api/v0/blueprints/freeze/<blueprint_names>` +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - Return a JSON representation of the recipe with the package and module versions set - to the exact versions chosen by depsolving the recipe. + Return a JSON representation of the blueprint with the package and module versions set + to the exact versions chosen by depsolving the blueprint. Example:: { "errors": [], - "recipes": [ + "blueprints": [ { - "recipe": { + "blueprint": { "description": "An example GlusterFS server with samba", "modules": [ { @@ -404,19 +382,19 @@ ] } -`/api/v0/recipes/depsolve/<recipe_names>` -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +`/api/v0/blueprints/depsolve/<blueprint_names>` +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - Depsolve the recipe using yum, return the recipe used, and the NEVRAs of the packages - chosen to satisfy the recipe's requirements. The response will include a list of results, - with the full dependency list in `dependencies`, the NEVRAs for the recipe's direct modules + Depsolve the blueprint using yum, return the blueprint used, and the NEVRAs of the packages + chosen to satisfy the blueprint's requirements. The response will include a list of results, + with the full dependency list in `dependencies`, the NEVRAs for the blueprint's direct modules and packages in `modules`, and any error will be in `errors`. Example:: { "errors": [], - "recipes": [ + "blueprints": [ { "dependencies": [ { @@ -466,7 +444,7 @@ }, ... ], - "recipe": { + "blueprint": { "description": "An example GlusterFS server with samba", "modules": [ { @@ -672,13 +650,13 @@ should look like this:: { - "recipe_name": "http-server", + "blueprint_name": "http-server", "compose_type": "tar", "branch": "master" } - Pass it the name of the recipe, the type of output (from '/api/v0/compose/types'), and the - recipe branch to use. 'branch' is optional and will default to master. It will create a new + Pass it the name of the blueprint, the type of output (from '/api/v0/compose/types'), and the + blueprint branch to use. 'branch' is optional and will default to master. It will create a new build and add it to the queue. It returns the build uuid and a status if it succeeds:: { @@ -712,14 +690,14 @@ "new": [ { "id": "45502a6d-06e8-48a5-a215-2b4174b3614b", - "recipe": "glusterfs", + "blueprint": "glusterfs", "queue_status": "WAITING", "timestamp": 1517362647.4570868, "version": "0.0.6" }, { "id": "6d292bd0-bec7-4825-8d7d-41ef9c3e4b73", - "recipe": "kubernetes", + "blueprint": "kubernetes", "queue_status": "WAITING", "timestamp": 1517362659.0034983, "version": "0.0.1" @@ -728,7 +706,7 @@ "run": [ { "id": "745712b2-96db-44c0-8014-fe925c35e795", - "recipe": "glusterfs", + "blueprint": "glusterfs", "queue_status": "RUNNING", "timestamp": 1517362633.7965999, "version": "0.0.6" @@ -747,14 +725,14 @@ "finished": [ { "id": "70b84195-9817-4b8a-af92-45e380f39894", - "recipe": "glusterfs", + "blueprint": "glusterfs", "queue_status": "FINISHED", "timestamp": 1517351003.8210032, "version": "0.0.6" }, { "id": "e695affd-397f-4af9-9022-add2636e7459", - "recipe": "glusterfs", + "blueprint": "glusterfs", "queue_status": "FINISHED", "timestamp": 1517362289.7193348, "version": "0.0.6" @@ -773,7 +751,7 @@ "failed": [ { "id": "8c8435ef-d6bd-4c68-9bf1-a2ef832e6b1a", - "recipe": "http-server", + "blueprint": "http-server", "queue_status": "FAILED", "timestamp": 1517523249.9301329, "version": "0.0.2" @@ -792,14 +770,14 @@ "uuids": [ { "id": "8c8435ef-d6bd-4c68-9bf1-a2ef832e6b1a", - "recipe": "http-server", + "blueprint": "http-server", "queue_status": "FINISHED", "timestamp": 1517523644.2384307, "version": "0.0.2" }, { "id": "45502a6d-06e8-48a5-a215-2b4174b3614b", - "recipe": "glusterfs", + "blueprint": "glusterfs", "queue_status": "FINISHED", "timestamp": 1517363442.188399, "version": "0.0.6" @@ -807,8 +785,8 @@ ] } -DELETE `/api/v0/recipes/cancel/<uuid>` -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +DELETE `/api/v0/blueprints/cancel/<uuid>` +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Cancel the build, if it is not finished, and delete the results. It will return a status of True if it is successful. @@ -845,8 +823,8 @@ * id - The uuid of the comoposition * config - containing the configuration settings used to run Anaconda - * recipe - The depsolved recipe used to generate the kickstart - * commit - The (local) git commit hash for the recipe used + * blueprint - The depsolved blueprint used to generate the kickstart + * commit - The (local) git commit hash for the blueprint used * deps - The NEVRA of all of the dependencies used in the composition * compose_type - The type of output generated (tar, iso, etc.) * queue_status - The final status of the composition (FINISHED or FAILED) @@ -877,7 +855,7 @@ }, "id": "c30b7d80-523b-4a23-ad52-61b799739ce8", "queue_status": "FINISHED", - "recipe": { + "blueprint": { "description": "An example kubernetes master", ... } @@ -916,10 +894,10 @@ UUID-logs.tar `/api/v0/compose/image/<uuid>` -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Returns the output image from the build. The filename is set to the filename - from the build. eg. root.tar.xz or boot.iso. + from the build with the UUID as a prefix. eg. UUID-root.tar.xz or UUID-boot.iso. `/api/v0/compose/log/<uuid>[?size=kbytes]` ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -951,6 +929,7 @@ import logging log = logging.getLogger("lorax-composer") +import os from flask import jsonify, request, Response, send_file from pylorax.api.compose import start_build, compose_types @@ -982,341 +961,341 @@
    [docs]def v0_api(api): # Note that Sphinx will not generate documentations for any of these. - @api.route("/api/v0/test") + @api.route("/api/v0/blueprints/list") @crossdomain(origin="*") - def v0_test(): - return "API v0 test" - - @api.route("/api/v0/status") - @crossdomain(origin="*") - def v0_status(): - return jsonify(build="devel", api="0", db_version="0", schema_version="0", db_supported=False) - - @api.route("/api/v0/recipes/list") - @crossdomain(origin="*") - def v0_recipes_list(): - """List the available recipes on a branch.""" + def v0_blueprints_list(): + """List the available blueprints on a branch.""" branch = request.args.get("branch", "master") try: limit = int(request.args.get("limit", "20")) offset = int(request.args.get("offset", "0")) except ValueError as e: - return jsonify(error={"msg":str(e)}), 400 + return jsonify(status=False, errors=[str(e)]), 400 with api.config["GITLOCK"].lock: - recipes = take_limits(map(lambda f: f[:-5], list_branch_files(api.config["GITLOCK"].repo, branch)), offset, limit) - return jsonify(recipes=recipes, limit=limit, offset=offset, total=len(recipes)) + blueprints = take_limits(map(lambda f: f[:-5], list_branch_files(api.config["GITLOCK"].repo, branch)), offset, limit) + return jsonify(blueprints=blueprints, limit=limit, offset=offset, total=len(blueprints)) - @api.route("/api/v0/recipes/info/<recipe_names>") + @api.route("/api/v0/blueprints/info/<blueprint_names>") @crossdomain(origin="*") - def v0_recipes_info(recipe_names): - """Return the contents of the recipe, or a list of recipes""" + def v0_blueprints_info(blueprint_names): + """Return the contents of the blueprint, or a list of blueprints""" branch = request.args.get("branch", "master") - recipes = [] + out_fmt = request.args.get("format", "json") + blueprints = [] changes = [] errors = [] - for recipe_name in [n.strip() for n in recipe_names.split(",")]: + for blueprint_name in [n.strip() for n in blueprint_names.split(",")]: exceptions = [] # Get the workspace version (if it exists) try: with api.config["GITLOCK"].lock: - ws_recipe = workspace_read(api.config["GITLOCK"].repo, branch, recipe_name) + ws_blueprint = workspace_read(api.config["GITLOCK"].repo, branch, blueprint_name) except Exception as e: - ws_recipe = None + ws_blueprint = None exceptions.append(str(e)) - log.error("(v0_recipes_info) %s", str(e)) + log.error("(v0_blueprints_info) %s", str(e)) # Get the git version (if it exists) try: with api.config["GITLOCK"].lock: - git_recipe = read_recipe_commit(api.config["GITLOCK"].repo, branch, recipe_name) + git_blueprint = read_recipe_commit(api.config["GITLOCK"].repo, branch, blueprint_name) except Exception as e: - git_recipe = None + git_blueprint = None exceptions.append(str(e)) - log.error("(v0_recipes_info) %s", str(e)) + log.error("(v0_blueprints_info) %s", str(e)) - if not ws_recipe and not git_recipe: - # Neither recipe, return an error - errors.append({"recipe":recipe_name, "msg":", ".join(exceptions)}) - elif ws_recipe and not git_recipe: - # No git recipe, return the workspace recipe - changes.append({"name":recipe_name, "changed":True}) - recipes.append(ws_recipe) - elif not ws_recipe and git_recipe: - # No workspace recipe, no change, return the git recipe - changes.append({"name":recipe_name, "changed":False}) - recipes.append(git_recipe) + if not ws_blueprint and not git_blueprint: + # Neither blueprint, return an error + errors.append("%s: %s" % (blueprint_name, ", ".join(exceptions))) + elif ws_blueprint and not git_blueprint: + # No git blueprint, return the workspace blueprint + changes.append({"name":blueprint_name, "changed":True}) + blueprints.append(ws_blueprint) + elif not ws_blueprint and git_blueprint: + # No workspace blueprint, no change, return the git blueprint + changes.append({"name":blueprint_name, "changed":False}) + blueprints.append(git_blueprint) else: - # Both exist, maybe changed, return the workspace recipe - changes.append({"name":recipe_name, "changed":ws_recipe != git_recipe}) - recipes.append(ws_recipe) + # Both exist, maybe changed, return the workspace blueprint + changes.append({"name":blueprint_name, "changed":ws_blueprint != git_blueprint}) + blueprints.append(ws_blueprint) - # Sort all the results by case-insensitive recipe name + # Sort all the results by case-insensitive blueprint name changes = sorted(changes, key=lambda c: c["name"].lower()) - recipes = sorted(recipes, key=lambda r: r["name"].lower()) - errors = sorted(errors, key=lambda e: e["recipe"].lower()) + blueprints = sorted(blueprints, key=lambda r: r["name"].lower()) + errors = sorted(errors, key=lambda e: e.lower()) - return jsonify(changes=changes, recipes=recipes, errors=errors) + if out_fmt == "toml": + # With TOML output we just want to dump the raw blueprint, skipping the rest. + return "\n\n".join([r.toml() for r in blueprints]) + else: + return jsonify(changes=changes, blueprints=blueprints, errors=errors) - @api.route("/api/v0/recipes/changes/<recipe_names>") + @api.route("/api/v0/blueprints/changes/<blueprint_names>") @crossdomain(origin="*") - def v0_recipes_changes(recipe_names): - """Return the changes to a recipe or list of recipes""" + def v0_blueprints_changes(blueprint_names): + """Return the changes to a blueprint or list of blueprints""" branch = request.args.get("branch", "master") try: limit = int(request.args.get("limit", "20")) offset = int(request.args.get("offset", "0")) except ValueError as e: - return jsonify(error={"msg":str(e)}), 400 + return jsonify(status=False, errors=[str(e)]), 400 - recipes = [] + blueprints = [] errors = [] - for recipe_name in [n.strip() for n in recipe_names.split(",")]: - filename = recipe_filename(recipe_name) + for blueprint_name in [n.strip() for n in blueprint_names.split(",")]: + filename = recipe_filename(blueprint_name) try: with api.config["GITLOCK"].lock: commits = take_limits(list_commits(api.config["GITLOCK"].repo, branch, filename), offset, limit) except Exception as e: - errors.append({"recipe":recipe_name, "msg":e}) - log.error("(v0_recipes_changes) %s", str(e)) + errors.append("%s: %s" % (blueprint_name, str(e))) + log.error("(v0_blueprints_changes) %s", str(e)) else: - recipes.append({"name":recipe_name, "changes":commits, "total":len(commits)}) + blueprints.append({"name":blueprint_name, "changes":commits, "total":len(commits)}) - recipes = sorted(recipes, key=lambda r: r["name"].lower()) - errors = sorted(errors, key=lambda e: e["recipe"].lower()) + blueprints = sorted(blueprints, key=lambda r: r["name"].lower()) + errors = sorted(errors, key=lambda e: e.lower()) - return jsonify(recipes=recipes, errors=errors, offset=offset, limit=limit) + return jsonify(blueprints=blueprints, errors=errors, offset=offset, limit=limit) - @api.route("/api/v0/recipes/new", methods=["POST"]) + @api.route("/api/v0/blueprints/new", methods=["POST"]) @crossdomain(origin="*") - def v0_recipes_new(): - """Commit a new recipe""" + def v0_blueprints_new(): + """Commit a new blueprint""" branch = request.args.get("branch", "master") try: if request.headers['Content-Type'] == "text/x-toml": - recipe = recipe_from_toml(request.data) + blueprint = recipe_from_toml(request.data) else: - recipe = recipe_from_dict(request.get_json(cache=False)) + blueprint = recipe_from_dict(request.get_json(cache=False)) with api.config["GITLOCK"].lock: - commit_recipe(api.config["GITLOCK"].repo, branch, recipe) + commit_recipe(api.config["GITLOCK"].repo, branch, blueprint) - # Read the recipe with new version and write it to the workspace - recipe = read_recipe_commit(api.config["GITLOCK"].repo, branch, recipe["name"]) - workspace_write(api.config["GITLOCK"].repo, branch, recipe) + # Read the blueprint with new version and write it to the workspace + blueprint = read_recipe_commit(api.config["GITLOCK"].repo, branch, blueprint["name"]) + workspace_write(api.config["GITLOCK"].repo, branch, blueprint) except Exception as e: - log.error("(v0_recipes_new) %s", str(e)) - return jsonify(status=False, error={"msg":str(e)}), 400 + log.error("(v0_blueprints_new) %s", str(e)) + return jsonify(status=False, errors=[str(e)]), 400 else: return jsonify(status=True) - @api.route("/api/v0/recipes/delete/<recipe_name>", methods=["DELETE"]) + @api.route("/api/v0/blueprints/delete/<blueprint_name>", methods=["DELETE"]) @crossdomain(origin="*") - def v0_recipes_delete(recipe_name): - """Delete a recipe from git""" + def v0_blueprints_delete(blueprint_name): + """Delete a blueprint from git""" branch = request.args.get("branch", "master") try: with api.config["GITLOCK"].lock: - delete_recipe(api.config["GITLOCK"].repo, branch, recipe_name) + delete_recipe(api.config["GITLOCK"].repo, branch, blueprint_name) except Exception as e: - log.error("(v0_recipes_delete) %s", str(e)) - return jsonify(status=False, error={"msg":str(e)}), 400 + log.error("(v0_blueprints_delete) %s", str(e)) + return jsonify(status=False, errors=[str(e)]), 400 else: return jsonify(status=True) - @api.route("/api/v0/recipes/workspace", methods=["POST"]) + @api.route("/api/v0/blueprints/workspace", methods=["POST"]) @crossdomain(origin="*") - def v0_recipes_workspace(): - """Write a recipe to the workspace""" + def v0_blueprints_workspace(): + """Write a blueprint to the workspace""" branch = request.args.get("branch", "master") try: if request.headers['Content-Type'] == "text/x-toml": - recipe = recipe_from_toml(request.data) + blueprint = recipe_from_toml(request.data) else: - recipe = recipe_from_dict(request.get_json(cache=False)) + blueprint = recipe_from_dict(request.get_json(cache=False)) with api.config["GITLOCK"].lock: - workspace_write(api.config["GITLOCK"].repo, branch, recipe) + workspace_write(api.config["GITLOCK"].repo, branch, blueprint) except Exception as e: - log.error("(v0_recipes_workspace) %s", str(e)) - return jsonify(status=False, error={"msg":str(e)}), 400 + log.error("(v0_blueprints_workspace) %s", str(e)) + return jsonify(status=False, errors=[str(e)]), 400 else: return jsonify(status=True) - @api.route("/api/v0/recipes/workspace/<recipe_name>", methods=["DELETE"]) + @api.route("/api/v0/blueprints/workspace/<blueprint_name>", methods=["DELETE"]) @crossdomain(origin="*") - def v0_recipes_delete_workspace(recipe_name): - """Delete a recipe from the workspace""" + def v0_blueprints_delete_workspace(blueprint_name): + """Delete a blueprint from the workspace""" branch = request.args.get("branch", "master") try: with api.config["GITLOCK"].lock: - workspace_delete(api.config["GITLOCK"].repo, branch, recipe_name) + workspace_delete(api.config["GITLOCK"].repo, branch, blueprint_name) except Exception as e: - log.error("(v0_recipes_delete_workspace) %s", str(e)) - return jsonify(status=False, error={"msg":str(e)}), 400 + log.error("(v0_blueprints_delete_workspace) %s", str(e)) + return jsonify(status=False, error=[str(e)]), 400 else: return jsonify(status=True) - @api.route("/api/v0/recipes/undo/<recipe_name>/<commit>", methods=["POST"]) + @api.route("/api/v0/blueprints/undo/<blueprint_name>/<commit>", methods=["POST"]) @crossdomain(origin="*") - def v0_recipes_undo(recipe_name, commit): - """Undo changes to a recipe by reverting to a previous commit.""" + def v0_blueprints_undo(blueprint_name, commit): + """Undo changes to a blueprint by reverting to a previous commit.""" branch = request.args.get("branch", "master") try: with api.config["GITLOCK"].lock: - revert_recipe(api.config["GITLOCK"].repo, branch, recipe_name, commit) + revert_recipe(api.config["GITLOCK"].repo, branch, blueprint_name, commit) # Read the new recipe and write it to the workspace - recipe = read_recipe_commit(api.config["GITLOCK"].repo, branch, recipe_name) - workspace_write(api.config["GITLOCK"].repo, branch, recipe) + blueprint = read_recipe_commit(api.config["GITLOCK"].repo, branch, blueprint_name) + workspace_write(api.config["GITLOCK"].repo, branch, blueprint) except Exception as e: - log.error("(v0_recipes_undo) %s", str(e)) - return jsonify(status=False, error={"msg":str(e)}), 400 + log.error("(v0_blueprints_undo) %s", str(e)) + return jsonify(status=False, errors=[str(e)]), 400 else: return jsonify(status=True) - @api.route("/api/v0/recipes/tag/<recipe_name>", methods=["POST"]) + @api.route("/api/v0/blueprints/tag/<blueprint_name>", methods=["POST"]) @crossdomain(origin="*") - def v0_recipes_tag(recipe_name): - """Tag a recipe's latest recipe commit as a 'revision'""" + def v0_blueprints_tag(blueprint_name): + """Tag a blueprint's latest blueprint commit as a 'revision'""" branch = request.args.get("branch", "master") try: with api.config["GITLOCK"].lock: - tag_recipe_commit(api.config["GITLOCK"].repo, branch, recipe_name) + tag_recipe_commit(api.config["GITLOCK"].repo, branch, blueprint_name) except Exception as e: - log.error("(v0_recipes_tag) %s", str(e)) - return jsonify(status=False, error={"msg":str(e)}), 400 + log.error("(v0_blueprints_tag) %s", str(e)) + return jsonify(status=False, errors=[str(e)]), 400 else: return jsonify(status=True) - @api.route("/api/v0/recipes/diff/<recipe_name>/<from_commit>/<to_commit>") + @api.route("/api/v0/blueprints/diff/<blueprint_name>/<from_commit>/<to_commit>") @crossdomain(origin="*") - def v0_recipes_diff(recipe_name, from_commit, to_commit): - """Return the differences between two commits of a recipe""" + def v0_blueprints_diff(blueprint_name, from_commit, to_commit): + """Return the differences between two commits of a blueprint""" branch = request.args.get("branch", "master") try: if from_commit == "NEWEST": with api.config["GITLOCK"].lock: - old_recipe = read_recipe_commit(api.config["GITLOCK"].repo, branch, recipe_name) + old_blueprint = read_recipe_commit(api.config["GITLOCK"].repo, branch, blueprint_name) else: with api.config["GITLOCK"].lock: - old_recipe = read_recipe_commit(api.config["GITLOCK"].repo, branch, recipe_name, from_commit) + old_blueprint = read_recipe_commit(api.config["GITLOCK"].repo, branch, blueprint_name, from_commit) except Exception as e: - log.error("(v0_recipes_diff) %s", str(e)) - return jsonify(error={"msg":str(e)}), 400 + log.error("(v0_blueprints_diff) %s", str(e)) + return jsonify(status=False, errors=[str(e)]), 400 try: if to_commit == "WORKSPACE": with api.config["GITLOCK"].lock: - new_recipe = workspace_read(api.config["GITLOCK"].repo, branch, recipe_name) + new_blueprint = workspace_read(api.config["GITLOCK"].repo, branch, blueprint_name) # If there is no workspace, use the newest commit instead - if not new_recipe: + if not new_blueprint: with api.config["GITLOCK"].lock: - new_recipe = read_recipe_commit(api.config["GITLOCK"].repo, branch, recipe_name) + new_blueprint = read_recipe_commit(api.config["GITLOCK"].repo, branch, blueprint_name) elif to_commit == "NEWEST": with api.config["GITLOCK"].lock: - new_recipe = read_recipe_commit(api.config["GITLOCK"].repo, branch, recipe_name) + new_blueprint = read_recipe_commit(api.config["GITLOCK"].repo, branch, blueprint_name) else: with api.config["GITLOCK"].lock: - new_recipe = read_recipe_commit(api.config["GITLOCK"].repo, branch, recipe_name, to_commit) + new_blueprint = read_recipe_commit(api.config["GITLOCK"].repo, branch, blueprint_name, to_commit) except Exception as e: - log.error("(v0_recipes_diff) %s", str(e)) - return jsonify(error={"msg":str(e)}), 400 + log.error("(v0_blueprints_diff) %s", str(e)) + return jsonify(status=False, errors=[str(e)]), 400 - diff = recipe_diff(old_recipe, new_recipe) + diff = recipe_diff(old_blueprint, new_blueprint) return jsonify(diff=diff) - @api.route("/api/v0/recipes/freeze/<recipe_names>") + @api.route("/api/v0/blueprints/freeze/<blueprint_names>") @crossdomain(origin="*") - def v0_recipes_freeze(recipe_names): - """Return the recipe with the exact modules and packages selected by depsolve""" + def v0_blueprints_freeze(blueprint_names): + """Return the blueprint with the exact modules and packages selected by depsolve""" branch = request.args.get("branch", "master") - recipes = [] + out_fmt = request.args.get("format", "json") + blueprints = [] errors = [] - for recipe_name in [n.strip() for n in sorted(recipe_names.split(","), key=lambda n: n.lower())]: - # get the recipe + for blueprint_name in [n.strip() for n in sorted(blueprint_names.split(","), key=lambda n: n.lower())]: + # get the blueprint # Get the workspace version (if it exists) - recipe = None + blueprint = None try: with api.config["GITLOCK"].lock: - recipe = workspace_read(api.config["GITLOCK"].repo, branch, recipe_name) + blueprint = workspace_read(api.config["GITLOCK"].repo, branch, blueprint_name) except Exception: pass - if not recipe: + if not blueprint: # No workspace version, get the git version (if it exists) try: with api.config["GITLOCK"].lock: - recipe = read_recipe_commit(api.config["GITLOCK"].repo, branch, recipe_name) + blueprint = read_recipe_commit(api.config["GITLOCK"].repo, branch, blueprint_name) except Exception as e: - errors.append({"recipe":recipe_name, "msg":str(e)}) - log.error("(v0_recipes_freeze) %s", str(e)) + errors.append("%s: %s" % (blueprint_name, str(e))) + log.error("(v0_blueprints_freeze) %s", str(e)) - # No recipe found, skip it. - if not recipe: - errors.append({"recipe":recipe_name, "msg":"Recipe not found"}) + # No blueprint found, skip it. + if not blueprint: + errors.append("%s: blueprint_not_found" % (blueprint_name)) continue # Combine modules and packages and depsolve the list # TODO include the version/glob in the depsolving - module_names = recipe.module_names - package_names = recipe.package_names + module_names = blueprint.module_names + package_names = blueprint.package_names projects = sorted(set(module_names+package_names), key=lambda n: n.lower()) deps = [] try: with api.config["YUMLOCK"].lock: deps = projects_depsolve(api.config["YUMLOCK"].yb, projects) except ProjectsError as e: - errors.append({"recipe":recipe_name, "msg":str(e)}) - log.error("(v0_recipes_freeze) %s", str(e)) + errors.append("%s: %s" % (blueprint_name, str(e))) + log.error("(v0_blueprints_freeze) %s", str(e)) - recipes.append({"recipe": recipe.freeze(deps)}) + blueprints.append({"blueprint": blueprint.freeze(deps)}) - return jsonify(recipes=recipes, errors=errors) + if out_fmt == "toml": + # With TOML output we just want to dump the raw blueprint, skipping the rest. + return "\n\n".join([e["blueprint"].toml() for e in blueprints]) + else: + return jsonify(blueprints=blueprints, errors=errors) - @api.route("/api/v0/recipes/depsolve/<recipe_names>") + @api.route("/api/v0/blueprints/depsolve/<blueprint_names>") @crossdomain(origin="*") - def v0_recipes_depsolve(recipe_names): - """Return the dependencies for a recipe""" + def v0_blueprints_depsolve(blueprint_names): + """Return the dependencies for a blueprint""" branch = request.args.get("branch", "master") - recipes = [] + blueprints = [] errors = [] - for recipe_name in [n.strip() for n in sorted(recipe_names.split(","), key=lambda n: n.lower())]: - # get the recipe + for blueprint_name in [n.strip() for n in sorted(blueprint_names.split(","), key=lambda n: n.lower())]: + # get the blueprint # Get the workspace version (if it exists) - recipe = None + blueprint = None try: with api.config["GITLOCK"].lock: - recipe = workspace_read(api.config["GITLOCK"].repo, branch, recipe_name) + blueprint = workspace_read(api.config["GITLOCK"].repo, branch, blueprint_name) except Exception: pass - if not recipe: + if not blueprint: # No workspace version, get the git version (if it exists) try: with api.config["GITLOCK"].lock: - recipe = read_recipe_commit(api.config["GITLOCK"].repo, branch, recipe_name) + blueprint = read_recipe_commit(api.config["GITLOCK"].repo, branch, blueprint_name) except Exception as e: - errors.append({"recipe":recipe_name, "msg":str(e)}) - log.error("(v0_recipes_depsolve) %s", str(e)) + errors.append("%s: %s" % (blueprint_name, str(e))) + log.error("(v0_blueprints_depsolve) %s", str(e)) - # No recipe found, skip it. - if not recipe: - errors.append({"recipe":recipe_name, "msg":"Recipe not found"}) + # No blueprint found, skip it. + if not blueprint: + errors.append("%s: blueprint not found" % blueprint_name) continue # Combine modules and packages and depsolve the list # TODO include the version/glob in the depsolving - module_names = map(lambda m: m["name"], recipe["modules"] or []) - package_names = map(lambda p: p["name"], recipe["packages"] or []) + module_names = map(lambda m: m["name"], blueprint["modules"] or []) + package_names = map(lambda p: p["name"], blueprint["packages"] or []) projects = sorted(set(module_names+package_names), key=lambda n: n.lower()) deps = [] try: with api.config["YUMLOCK"].lock: deps = projects_depsolve(api.config["YUMLOCK"].yb, projects) except ProjectsError as e: - errors.append({"recipe":recipe_name, "msg":str(e)}) - log.error("(v0_recipes_depsolve) %s", str(e)) + errors.append("%s: %s" % (blueprint_name, str(e))) + log.error("(v0_blueprints_depsolve) %s", str(e)) # Get the NEVRA's of the modules and projects, add as "modules" modules = [] @@ -1325,9 +1304,9 @@ modules.append(dep) modules = sorted(modules, key=lambda m: m["name"].lower()) - recipes.append({"recipe":recipe, "dependencies":deps, "modules":modules}) + blueprints.append({"blueprint":blueprint, "dependencies":deps, "modules":modules}) - return jsonify(recipes=recipes, errors=errors) + return jsonify(blueprints=blueprints, errors=errors) @api.route("/api/v0/projects/list") @crossdomain(origin="*") @@ -1337,14 +1316,14 @@ limit = int(request.args.get("limit", "20")) offset = int(request.args.get("offset", "0")) except ValueError as e: - return jsonify(error={"msg":str(e)}), 400 + return jsonify(status=False, errors=[str(e)]), 400 try: with api.config["YUMLOCK"].lock: available = projects_list(api.config["YUMLOCK"].yb) except ProjectsError as e: log.error("(v0_projects_list) %s", str(e)) - return jsonify(error={"msg":str(e)}), 400 + return jsonify(status=False, errors=[str(e)]), 400 projects = take_limits(available, offset, limit) return jsonify(projects=projects, offset=offset, limit=limit, total=len(available)) @@ -1358,7 +1337,7 @@ projects = projects_info(api.config["YUMLOCK"].yb, project_names.split(",")) except ProjectsError as e: log.error("(v0_projects_info) %s", str(e)) - return jsonify(error={"msg":str(e)}), 400 + return jsonify(status=False, errors=[str(e)]), 400 return jsonify(projects=projects) @@ -1371,7 +1350,7 @@ deps = projects_depsolve(api.config["YUMLOCK"].yb, project_names.split(",")) except ProjectsError as e: log.error("(v0_projects_depsolve) %s", str(e)) - return jsonify(error={"msg":str(e)}), 400 + return jsonify(status=False, errors=[str(e)]), 400 return jsonify(projects=deps) @@ -1384,7 +1363,7 @@ limit = int(request.args.get("limit", "20")) offset = int(request.args.get("offset", "0")) except ValueError as e: - return jsonify(error={"msg":str(e)}), 400 + return jsonify(status=False, errors=[str(e)]), 400 if module_names: module_names = module_names.split(",") @@ -1394,7 +1373,7 @@ available = modules_list(api.config["YUMLOCK"].yb, module_names) except ProjectsError as e: log.error("(v0_modules_list) %s", str(e)) - return jsonify(error={"msg":str(e)}), 400 + return jsonify(status=False, errors=[str(e)]), 400 modules = take_limits(available, offset, limit) return jsonify(modules=modules, offset=offset, limit=limit, total=len(available)) @@ -1408,7 +1387,7 @@ modules = modules_info(api.config["YUMLOCK"].yb, module_names.split(",")) except ProjectsError as e: log.error("(v0_modules_info) %s", str(e)) - return jsonify(error={"msg":str(e)}), 400 + return jsonify(status=False, errors=[str(e)]), 400 return jsonify(modules=modules) @@ -1418,9 +1397,9 @@ """Start a compose The body of the post should have these fields: - recipe_name - The recipe name from /recipes/list/ - compose_type - The type of output to create, from /compose/types - branch - Optional, defaults to master, selects the git branch to use for the recipe. + blueprint_name - The blueprint name from /blueprints/list/ + compose_type - The type of output to create, from /compose/types + branch - Optional, defaults to master, selects the git branch to use for the blueprint. """ # Passing ?test=1 will generate a fake FAILED compose. # Passing ?test=2 will generate a fake FINISHED compose. @@ -1433,12 +1412,12 @@ errors = [] if not compose: - return jsonify(status=False, error={"msg":"Missing POST body"}), 400 + return jsonify(status=False, errors=["Missing POST body"]), 400 - if "recipe_name" not in compose: - errors.append("No 'recipe_name' in the JSON request") + if "blueprint_name" not in compose: + errors.append("No 'blueprint_name' in the JSON request") else: - recipe_name = compose["recipe_name"] + blueprint_name = compose["blueprint_name"] if "branch" not in compose or not compose["branch"]: branch = "master" @@ -1451,13 +1430,13 @@ compose_type = compose["compose_type"] if errors: - return jsonify(status=False, error={"msg":"\n".join(errors)}), 400 + return jsonify(status=False, errors=errors), 400 try: build_id = start_build(api.config["COMPOSER_CFG"], api.config["YUMLOCK"], api.config["GITLOCK"], - branch, recipe_name, compose_type, test_mode) + branch, blueprint_name, compose_type, test_mode) except Exception as e: - return jsonify(status=False, error={"msg":str(e)}), 400 + return jsonify(status=False, errors=[str(e)]), 400 return jsonify(status=True, build_id=build_id) @@ -1507,15 +1486,15 @@ """Cancel a running compose and delete its results directory""" status = uuid_status(api.config["COMPOSER_CFG"], uuid) if status is None: - return jsonify(status=False, msg="%s is not a valid build uuid" % uuid), 400 + return jsonify(status=False, errors=["%s is not a valid build uuid" % uuid]), 400 if status["queue_status"] not in ["WAITING", "RUNNING"]: - return jsonify(status=False, uuid=uuid, msg="Cannot cancel a build that is in the %s state" % status["queue_status"]) + return jsonify(status=False, errors=["Build %s is not in WAITING or RUNNING." % uuid]) try: uuid_cancel(api.config["COMPOSER_CFG"], uuid) except Exception as e: - return jsonify(status=False, uuid=uuid, msg=str(e)) + return jsonify(status=False, errors=["%s: %s" % (uuid, str(e))]),400 else: return jsonify(status=True, uuid=uuid) @@ -1528,14 +1507,14 @@ for uuid in [n.strip().lower() for n in uuids.split(",")]: status = uuid_status(api.config["COMPOSER_CFG"], uuid) if status is None: - errors.append({"uuid": uuid, "msg": "Not a valid build uuid"}) + errors.append("%s is not a valid build uuid" % uuid) elif status["queue_status"] not in ["FINISHED", "FAILED"]: - errors.append({"uuid":uuid, "msg":"Build not in FINISHED or FAILED."}) + errors.append("Build %s is not in FINISHED or FAILED." % uuid) else: try: uuid_delete(api.config["COMPOSER_CFG"], uuid) except Exception as e: - errors.append({"uuid":uuid, "msg":str(e)}) + errors.append("%s: %s" % (uuid, str(e))) else: results.append({"uuid":uuid, "status":True}) return jsonify(uuids=results, errors=errors) @@ -1547,7 +1526,7 @@ try: info = uuid_info(api.config["COMPOSER_CFG"], uuid) except Exception as e: - return jsonify(status=False, msg=str(e)) + return jsonify(status=False, errors=[str(e)]), 400 return jsonify(**info) @@ -1557,9 +1536,9 @@ """Return a tar of the metadata for the build""" status = uuid_status(api.config["COMPOSER_CFG"], uuid) if status is None: - return jsonify(status=False, msg="%s is not a valid build uuid" % uuid), 400 + return jsonify(status=False, errors=["%s is not a valid build uuid" % uuid]), 400 if status["queue_status"] not in ["FINISHED", "FAILED"]: - return jsonify(status=False, uuid=uuid, msg="Build not in FINISHED or FAILED.") + return jsonify(status=False, errors=["Build %s not in FINISHED or FAILED state." % uuid]), 400 else: return Response(uuid_tar(api.config["COMPOSER_CFG"], uuid, metadata=True, image=False, logs=False), mimetype="application/x-tar", @@ -1572,9 +1551,9 @@ """Return a tar of the metadata and the results for the build""" status = uuid_status(api.config["COMPOSER_CFG"], uuid) if status is None: - return jsonify(status=False, msg="%s is not a valid build uuid" % uuid), 400 + return jsonify(status=False, errors=["%s is not a valid build uuid" % uuid]), 400 elif status["queue_status"] not in ["FINISHED", "FAILED"]: - return jsonify(status=False, uuid=uuid, msg="Build not in FINISHED or FAILED.") + return jsonify(status=False, errors=["Build %s not in FINISHED or FAILED state." % uuid]), 400 else: return Response(uuid_tar(api.config["COMPOSER_CFG"], uuid, metadata=True, image=True, logs=True), mimetype="application/x-tar", @@ -1587,9 +1566,9 @@ """Return a tar of the metadata for the build""" status = uuid_status(api.config["COMPOSER_CFG"], uuid) if status is None: - return jsonify(status=False, msg="%s is not a valid build uuid"), 400 + return jsonify(status=False, errors=["%s is not a valid build uuid" % uuid]), 400 elif status["queue_status"] not in ["FINISHED", "FAILED"]: - return jsonify(status=False, uuid=uuid, msg="Build not in FINISHED or FAILED.") + return jsonify(status=False, errors=["Build %s not in FINISHED or FAILED state." % uuid]), 400 else: return Response(uuid_tar(api.config["COMPOSER_CFG"], uuid, metadata=False, image=False, logs=True), mimetype="application/x-tar", @@ -1602,12 +1581,18 @@ """Return the output image for the build""" status = uuid_status(api.config["COMPOSER_CFG"], uuid) if status is None: - return jsonify(status=False, msg="%s is not a valid build uuid" % uuid), 400 + return jsonify(status=False, errors=["%s is not a valid build uuid" % uuid]), 400 elif status["queue_status"] not in ["FINISHED", "FAILED"]: - return jsonify(status=False, uuid=uuid, msg="Build not in FINISHED or FAILED.") + return jsonify(status=False, errors=["Build %s not in FINISHED or FAILED state." % uuid]), 400 else: image_name, image_path = uuid_image(api.config["COMPOSER_CFG"], uuid) + # Make sure it really exists + if not os.path.exists(image_path): + return jsonify(status=False, errors=["Build %s is missing image file %s" % (uuid, image_name)]), 400 + + # Make the image name unique + image_name = uuid + "-" + image_name # XXX - Will mime type guessing work for all our output? return send_file(image_path, as_attachment=True, attachment_filename=image_name, add_etags=False) @@ -1618,15 +1603,17 @@ try: size = int(request.args.get("size", "1024")) except ValueError as e: - return jsonify(error={"msg":str(e)}), 400 + return jsonify(status=False, errors=[str(e)]), 400 status = uuid_status(api.config["COMPOSER_CFG"], uuid) - if status is None or status["queue_status"] == "WAITING": - return jsonify(status=False, uuid=uuid, msg="Build has not started yet. No logs to view") + if status is None: + return jsonify(status=False, errors=["%s is not a valid build uuid" % uuid]), 400 + elif status["queue_status"] == "WAITING": + return jsonify(status=False, errors=["Build %s has not started yet. No logs to view" % uuid]) try: return Response(uuid_log(api.config["COMPOSER_CFG"], uuid, size), direct_passthrough=True) except RuntimeError as e: - return jsonify(status=False, uuid=uuid, msg=str(e))
    + return jsonify(status=False, errors=[str(e)]), 400 @@ -1660,7 +1647,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • pylorax.api »
  • diff --git a/lorax-composer/_modules/pylorax/api/workspace.html b/lorax-composer/_modules/pylorax/api/workspace.html index 74a0e857..1aa878aa 100644 --- a/lorax-composer/_modules/pylorax/api/workspace.html +++ b/lorax-composer/_modules/pylorax/api/workspace.html @@ -8,7 +8,7 @@ - pylorax.api.workspace — Lorax 19.7.11 documentation + pylorax.api.workspace — Lorax 19.7.14 documentation @@ -16,7 +16,7 @@ - + @@ -38,7 +38,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • pylorax.api »
  • @@ -183,7 +183,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • pylorax.api »
  • diff --git a/lorax-composer/_modules/pylorax/api/yumbase.html b/lorax-composer/_modules/pylorax/api/yumbase.html index d3da1561..d143ed75 100644 --- a/lorax-composer/_modules/pylorax/api/yumbase.html +++ b/lorax-composer/_modules/pylorax/api/yumbase.html @@ -8,7 +8,7 @@ - pylorax.api.yumbase — Lorax 19.7.11 documentation + pylorax.api.yumbase — Lorax 19.7.14 documentation @@ -16,7 +16,7 @@ - + @@ -38,7 +38,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • pylorax.api »
  • @@ -75,7 +75,6 @@ import ConfigParser from fnmatch import fnmatchcase from glob import glob -from distutils.util import strtobool import os import yum # This is a hack to short circuit yum's internal logging @@ -93,6 +92,7 @@ """ cachedir = os.path.abspath(conf.get("composer", "cache_dir")) yumconf = os.path.abspath(conf.get("composer", "yum_conf")) + yumroot = os.path.abspath(conf.get("composer", "yum_root")) repodir = os.path.abspath(conf.get("composer", "repo_dir")) c = ConfigParser.ConfigParser() @@ -125,8 +125,7 @@ yb.preconf.fn = yumconf - # TODO How to handle this? - yb.preconf.root = "/var/tmp/composer/yum/root" + yb.preconf.root = yumroot if not os.path.isdir(yb.preconf.root): os.makedirs(yb.preconf.root) @@ -155,6 +154,15 @@ if any(map(lambda pattern: fnmatchcase(name, pattern), enabled_repos)): # pylint: disable=cell-var-from-loop yb.getReposFromConfigFile(repo_file) + # Update the metadata from the enabled repos to speed up later operations + log.info("Updating yum repository metadata") + for r in yb.repos.sort(): + r.metadata_expire = 0 + r.mdpolicy = "group:all" + yb.doRepoSetup() + yb.repos.doSetup() + yb.repos.populateSack(mdtype='all', cacheonly=1) + return yb @@ -189,7 +197,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • pylorax.api »
  • diff --git a/lorax-composer/_modules/pylorax/base.html b/lorax-composer/_modules/pylorax/base.html index e8d3d31b..649ca412 100644 --- a/lorax-composer/_modules/pylorax/base.html +++ b/lorax-composer/_modules/pylorax/base.html @@ -8,7 +8,7 @@ - pylorax.base — Lorax 19.7.11 documentation + pylorax.base — Lorax 19.7.14 documentation @@ -16,7 +16,7 @@ - + @@ -38,7 +38,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • @@ -150,7 +150,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • diff --git a/lorax-composer/_modules/pylorax/buildstamp.html b/lorax-composer/_modules/pylorax/buildstamp.html index 3bd478eb..2ca5f86d 100644 --- a/lorax-composer/_modules/pylorax/buildstamp.html +++ b/lorax-composer/_modules/pylorax/buildstamp.html @@ -8,7 +8,7 @@ - pylorax.buildstamp — Lorax 19.7.11 documentation + pylorax.buildstamp — Lorax 19.7.14 documentation @@ -16,7 +16,7 @@ - + @@ -38,7 +38,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • @@ -141,7 +141,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • diff --git a/lorax-composer/_modules/pylorax/creator.html b/lorax-composer/_modules/pylorax/creator.html index 118e801f..0c6f7be9 100644 --- a/lorax-composer/_modules/pylorax/creator.html +++ b/lorax-composer/_modules/pylorax/creator.html @@ -8,7 +8,7 @@ - pylorax.creator — Lorax 19.7.11 documentation + pylorax.creator — Lorax 19.7.14 documentation @@ -16,7 +16,7 @@ - + @@ -38,7 +38,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • @@ -485,7 +485,8 @@ log.error("Install failed: %s", e) if not opts.keep_image: log.info("Removing bad disk image") - os.unlink(disk_img) + if os.path.exists(disk_img): + os.unlink(disk_img) raise log.info("Disk Image install successful") @@ -696,7 +697,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • diff --git a/lorax-composer/_modules/pylorax/decorators.html b/lorax-composer/_modules/pylorax/decorators.html index 01f8846a..4d8ba3fa 100644 --- a/lorax-composer/_modules/pylorax/decorators.html +++ b/lorax-composer/_modules/pylorax/decorators.html @@ -8,7 +8,7 @@ - pylorax.decorators — Lorax 19.7.11 documentation + pylorax.decorators — Lorax 19.7.14 documentation @@ -16,7 +16,7 @@ - + @@ -38,7 +38,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • @@ -113,7 +113,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • diff --git a/lorax-composer/_modules/pylorax/discinfo.html b/lorax-composer/_modules/pylorax/discinfo.html index 4619dbae..c9ef1950 100644 --- a/lorax-composer/_modules/pylorax/discinfo.html +++ b/lorax-composer/_modules/pylorax/discinfo.html @@ -8,7 +8,7 @@ - pylorax.discinfo — Lorax 19.7.11 documentation + pylorax.discinfo — Lorax 19.7.14 documentation @@ -16,7 +16,7 @@ - + @@ -38,7 +38,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • @@ -122,7 +122,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • diff --git a/lorax-composer/_modules/pylorax/executils.html b/lorax-composer/_modules/pylorax/executils.html index af95bcf7..bb2fdb54 100644 --- a/lorax-composer/_modules/pylorax/executils.html +++ b/lorax-composer/_modules/pylorax/executils.html @@ -8,7 +8,7 @@ - pylorax.executils — Lorax 19.7.11 documentation + pylorax.executils — Lorax 19.7.14 documentation @@ -16,7 +16,7 @@ - + @@ -38,7 +38,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • @@ -508,7 +508,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • diff --git a/lorax-composer/_modules/pylorax/imgutils.html b/lorax-composer/_modules/pylorax/imgutils.html index 216ad1ea..e33cd997 100644 --- a/lorax-composer/_modules/pylorax/imgutils.html +++ b/lorax-composer/_modules/pylorax/imgutils.html @@ -8,7 +8,7 @@ - pylorax.imgutils — Lorax 19.7.11 documentation + pylorax.imgutils — Lorax 19.7.14 documentation @@ -16,7 +16,7 @@ - + @@ -38,7 +38,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • @@ -548,7 +548,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • diff --git a/lorax-composer/_modules/pylorax/installer.html b/lorax-composer/_modules/pylorax/installer.html index d39f2a3f..7037bcab 100644 --- a/lorax-composer/_modules/pylorax/installer.html +++ b/lorax-composer/_modules/pylorax/installer.html @@ -8,7 +8,7 @@ - pylorax.installer — Lorax 19.7.11 documentation + pylorax.installer — Lorax 19.7.14 documentation @@ -16,7 +16,7 @@ - + @@ -38,7 +38,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • @@ -284,7 +284,7 @@ selinux.security_setenforce(0) # Clean up /tmp/ from previous runs to prevent stale info from being used - for path in ["/tmp/yum.repos.d/", "/tmp/yum.cache/"]: + for path in ["/tmp/yum.repos.d/", "/tmp/yum.cache/", "/tmp/yum.root/", "/tmp/yum.pluginconf.d/"]: if os.path.isdir(path): shutil.rmtree(path) @@ -471,7 +471,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • diff --git a/lorax-composer/_modules/pylorax/logmonitor.html b/lorax-composer/_modules/pylorax/logmonitor.html index e101c133..0d7177dc 100644 --- a/lorax-composer/_modules/pylorax/logmonitor.html +++ b/lorax-composer/_modules/pylorax/logmonitor.html @@ -8,7 +8,7 @@ - pylorax.logmonitor — Lorax 19.7.11 documentation + pylorax.logmonitor — Lorax 19.7.14 documentation @@ -16,7 +16,7 @@ - + @@ -38,7 +38,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • @@ -206,7 +206,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • diff --git a/lorax-composer/_modules/pylorax/ltmpl.html b/lorax-composer/_modules/pylorax/ltmpl.html index ae35dbfd..fccd1b79 100644 --- a/lorax-composer/_modules/pylorax/ltmpl.html +++ b/lorax-composer/_modules/pylorax/ltmpl.html @@ -8,7 +8,7 @@ - pylorax.ltmpl — Lorax 19.7.11 documentation + pylorax.ltmpl — Lorax 19.7.14 documentation @@ -16,7 +16,7 @@ - + @@ -38,7 +38,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • @@ -270,8 +270,8 @@ # log the "ErrorType: this is what happened" line logger.error(" " + exclines[-1].strip()) # and log the entire traceback to the debug log - for line in ''.join(exclines).splitlines(): - logger.debug(" " + line) + for l in ''.join(exclines).splitlines(): + logger.debug(" " + l) if self.fatalerrors: raise @@ -748,7 +748,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • diff --git a/lorax-composer/_modules/pylorax/sysutils.html b/lorax-composer/_modules/pylorax/sysutils.html index 576aa7a6..690faf39 100644 --- a/lorax-composer/_modules/pylorax/sysutils.html +++ b/lorax-composer/_modules/pylorax/sysutils.html @@ -8,7 +8,7 @@ - pylorax.sysutils — Lorax 19.7.11 documentation + pylorax.sysutils — Lorax 19.7.14 documentation @@ -16,7 +16,7 @@ - + @@ -38,7 +38,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • @@ -191,7 +191,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • diff --git a/lorax-composer/_modules/pylorax/treebuilder.html b/lorax-composer/_modules/pylorax/treebuilder.html index 3770a870..1bc569ab 100644 --- a/lorax-composer/_modules/pylorax/treebuilder.html +++ b/lorax-composer/_modules/pylorax/treebuilder.html @@ -8,7 +8,7 @@ - pylorax.treebuilder — Lorax 19.7.11 documentation + pylorax.treebuilder — Lorax 19.7.14 documentation @@ -16,7 +16,7 @@ - + @@ -38,7 +38,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • @@ -403,7 +403,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • diff --git a/lorax-composer/_modules/pylorax/treeinfo.html b/lorax-composer/_modules/pylorax/treeinfo.html index a56176ce..88139d37 100644 --- a/lorax-composer/_modules/pylorax/treeinfo.html +++ b/lorax-composer/_modules/pylorax/treeinfo.html @@ -8,7 +8,7 @@ - pylorax.treeinfo — Lorax 19.7.11 documentation + pylorax.treeinfo — Lorax 19.7.14 documentation @@ -16,7 +16,7 @@ - + @@ -38,7 +38,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • @@ -140,7 +140,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • diff --git a/lorax-composer/_modules/pylorax/yumhelper.html b/lorax-composer/_modules/pylorax/yumhelper.html index 6e43a1f3..67f83995 100644 --- a/lorax-composer/_modules/pylorax/yumhelper.html +++ b/lorax-composer/_modules/pylorax/yumhelper.html @@ -8,7 +8,7 @@ - pylorax.yumhelper — Lorax 19.7.11 documentation + pylorax.yumhelper — Lorax 19.7.14 documentation @@ -16,7 +16,7 @@ - + @@ -38,7 +38,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • @@ -208,7 +208,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • Module code »
  • pylorax »
  • diff --git a/lorax-composer/_sources/composer.cli.txt b/lorax-composer/_sources/composer.cli.txt index ef03b94a..f24a0be8 100644 --- a/lorax-composer/_sources/composer.cli.txt +++ b/lorax-composer/_sources/composer.cli.txt @@ -9,6 +9,14 @@ cli Package :undoc-members: :show-inheritance: +:mod:`blueprints` Module +------------------------ + +.. automodule:: composer.cli.blueprints + :members: + :undoc-members: + :show-inheritance: + :mod:`compose` Module --------------------- @@ -33,14 +41,6 @@ cli Package :undoc-members: :show-inheritance: -:mod:`recipes` Module ---------------------- - -.. automodule:: composer.cli.recipes - :members: - :undoc-members: - :show-inheritance: - :mod:`utilities` Module ----------------------- diff --git a/lorax-composer/_sources/lorax-composer.txt b/lorax-composer/_sources/lorax-composer.txt index 5af3d0f6..5a2d65db 100644 --- a/lorax-composer/_sources/lorax-composer.txt +++ b/lorax-composer/_sources/lorax-composer.txt @@ -35,12 +35,12 @@ Quickstart 2. Remove any pre-existing socket directory with ``rm -rf /run/weldr/`` A new directory with correct permissions will be created the first time the server runs. 3. Either start it via systemd with ``systemctl start lorax-composer`` or - run it directly with ``lorax-composer /path/to/recipes/`` + run it directly with ``lorax-composer /path/to/blueprints/`` -The ``/path/to/recipes/`` is where the recipe's git repo will be created, and -all the recipes created with the ``/api/v0/recipes/new`` route will be stored. -If there are recipe ``.toml`` files in the top level of the directory they will -be imported into the recipe git storage. +The ``/path/to/blueprints/`` is where the blueprint's git repo will be created, and +all the blueprints created with the ``/api/v0/blueprints/new`` route will be stored. +If there are blueprint ``.toml`` files in the top level of the directory they will +be imported into the blueprint git storage. Composing Images ---------------- @@ -48,7 +48,7 @@ Composing Images As of version 19.7.7 lorax-composer can create ``tar`` output images. You can use curl to start a compose like this:: - curl --unix-socket /run/weldr/api.socket -X POST -H "Content-Type: application/json" -d '{"recipe_name": "http-server", "compose_type": "tar", "branch": "master"}' http:///api/v0/compose + curl --unix-socket /run/weldr/api.socket -X POST -H "Content-Type: application/json" -d '{"blueprint_name": "http-server", "compose_type": "tar", "branch": "master"}' http:///api/v0/compose And then monitor it by passing the returned build UUID to ``/compose/status/``. @@ -91,7 +91,7 @@ in ``./docs/rhel7-minimal.ks``. You should remove the ``url`` and ``repo`` commands, they will be added by the compose process. Make sure the bootloader packages are included in the ``%packages`` section at the end of the kickstart, and you will want to leave off the ``%end`` so that the compose can append the -list of packages from the recipe. +list of packages from the blueprint. The new ``_MAP`` entry should be a copy of one of the existing entries, but with ``make_disk`` set to ``True``. Make sure that none of the other ``make_*`` options are ``True``. The ``image_name`` is diff --git a/lorax-composer/composer.cli.html b/lorax-composer/composer.cli.html index b1f01fb1..6f861c7b 100644 --- a/lorax-composer/composer.cli.html +++ b/lorax-composer/composer.cli.html @@ -8,7 +8,7 @@ - cli Package — Lorax 19.7.11 documentation + cli Package — Lorax 19.7.14 documentation @@ -16,7 +16,7 @@ - + @@ -46,7 +46,7 @@
  • previous |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • src »
  • composer Package »
  • @@ -75,6 +75,363 @@ + +
    +

    blueprints Module¶

    +
    +
    +composer.cli.blueprints.blueprints_changes(socket_path, api_version, args, show_json=False)[source]¶
    +

    Display the changes for each of the blueprints

    + +++ + + + +
    Parameters:
      +
    • socket_path (str) – Path to the Unix socket to use for API communication
    • +
    • api_version (str) – Version of the API to talk to. eg. “0”
    • +
    • args (list of str) – List of remaining arguments from the cmdline
    • +
    • show_json (bool) – Set to True to show the JSON output instead of the human readable output
    • +
    +
    +

    blueprints changes <blueprint,...> Display the changes for each blueprint.

    +
    + +
    +
    +composer.cli.blueprints.blueprints_cmd(opts)[source]¶
    +

    Process blueprints commands

    + +++ + + + + + + + +
    Parameters:opts (argparse.Namespace) – Cmdline arguments
    Returns:Value to return from sys.exit()
    Return type:int
    +

    This dispatches the blueprints commands to a function

    +
    + +
    +
    +composer.cli.blueprints.blueprints_delete(socket_path, api_version, args, show_json=False)[source]¶
    +

    Delete a blueprint from the server

    + +++ + + + +
    Parameters:
      +
    • socket_path (str) – Path to the Unix socket to use for API communication
    • +
    • api_version (str) – Version of the API to talk to. eg. “0”
    • +
    • args (list of str) – List of remaining arguments from the cmdline
    • +
    • show_json (bool) – Set to True to show the JSON output instead of the human readable output
    • +
    +
    +

    delete <blueprint> Delete a blueprint from the server

    +
    + +
    +
    +composer.cli.blueprints.blueprints_depsolve(socket_path, api_version, args, show_json=False)[source]¶
    +

    Display the packages needed to install the blueprint

    + +++ + + + +
    Parameters:
      +
    • socket_path (str) – Path to the Unix socket to use for API communication
    • +
    • api_version (str) – Version of the API to talk to. eg. “0”
    • +
    • args (list of str) – List of remaining arguments from the cmdline
    • +
    • show_json (bool) – Set to True to show the JSON output instead of the human readable output
    • +
    +
    +

    blueprints depsolve <blueprint,...> Display the packages needed to install the blueprint.

    +
    + +
    +
    +composer.cli.blueprints.blueprints_diff(socket_path, api_version, args, show_json=False)[source]¶
    +

    Display the differences between 2 versions of a blueprint

    + +++ + + + +
    Parameters:
      +
    • socket_path (str) – Path to the Unix socket to use for API communication
    • +
    • api_version (str) – Version of the API to talk to. eg. “0”
    • +
    • args (list of str) – List of remaining arguments from the cmdline
    • +
    • show_json (bool) – Set to True to show the JSON output instead of the human readable output
    • +
    +
    +
    +
    blueprints diff <blueprint-name> Display the differences between 2 versions of a blueprint.
    +
    <from-commit> Commit hash or NEWEST +<to-commit> Commit hash, NEWEST, or WORKSPACE
    +
    +
    + +
    +
    +composer.cli.blueprints.blueprints_freeze(socket_path, api_version, args, show_json=False)[source]¶
    +

    Handle the blueprints freeze commands

    + +++ + + + +
    Parameters:
      +
    • socket_path (str) – Path to the Unix socket to use for API communication
    • +
    • api_version (str) – Version of the API to talk to. eg. “0”
    • +
    • args (list of str) – List of remaining arguments from the cmdline
    • +
    • show_json (bool) – Set to True to show the JSON output instead of the human readable output
    • +
    +
    +

    blueprints freeze <blueprint,...> Display the frozen blueprint’s modules and packages. +blueprints freeze show <blueprint,...> Display the frozen blueprint in TOML format. +blueprints freeze save <blueprint,...> Save the frozen blueprint to a file, <blueprint-name>.frozen.toml.

    +
    + +
    +
    +composer.cli.blueprints.blueprints_freeze_save(socket_path, api_version, args, show_json=False)[source]¶
    +

    Save the frozen blueprint to a TOML file

    + +++ + + + +
    Parameters:
      +
    • socket_path (str) – Path to the Unix socket to use for API communication
    • +
    • api_version (str) – Version of the API to talk to. eg. “0”
    • +
    • args (list of str) – List of remaining arguments from the cmdline
    • +
    • show_json (bool) – Set to True to show the JSON output instead of the human readable output
    • +
    +
    +

    blueprints freeze save <blueprint,...> Save the frozen blueprint to a file, <blueprint-name>.frozen.toml.

    +
    + +
    +
    +composer.cli.blueprints.blueprints_freeze_show(socket_path, api_version, args, show_json=False)[source]¶
    +

    Show the frozen blueprint in TOML format

    + +++ + + + +
    Parameters:
      +
    • socket_path (str) – Path to the Unix socket to use for API communication
    • +
    • api_version (str) – Version of the API to talk to. eg. “0”
    • +
    • args (list of str) – List of remaining arguments from the cmdline
    • +
    • show_json (bool) – Set to True to show the JSON output instead of the human readable output
    • +
    +
    +

    blueprints freeze show <blueprint,...> Display the frozen blueprint in TOML format.

    +
    + +
    +
    +composer.cli.blueprints.blueprints_list(socket_path, api_version, args, show_json=False)[source]¶
    +

    Output the list of available blueprints

    + +++ + + + +
    Parameters:
      +
    • socket_path (str) – Path to the Unix socket to use for API communication
    • +
    • api_version (str) – Version of the API to talk to. eg. “0”
    • +
    • args (list of str) – List of remaining arguments from the cmdline
    • +
    • show_json (bool) – Set to True to show the JSON output instead of the human readable output
    • +
    +
    +

    blueprints list

    +
    + +
    +
    +composer.cli.blueprints.blueprints_push(socket_path, api_version, args, show_json=False)[source]¶
    +

    Push a blueprint TOML file to the server, updating the blueprint

    + +++ + + + +
    Parameters:
      +
    • socket_path (str) – Path to the Unix socket to use for API communication
    • +
    • api_version (str) – Version of the API to talk to. eg. “0”
    • +
    • args (list of str) – List of remaining arguments from the cmdline
    • +
    • show_json (bool) – Set to True to show the JSON output instead of the human readable output
    • +
    +
    +

    push <blueprint> Push a blueprint TOML file to the server.

    +
    + +
    +
    +composer.cli.blueprints.blueprints_save(socket_path, api_version, args, show_json=False)[source]¶
    +

    Save the blueprint to a TOML file

    + +++ + + + +
    Parameters:
      +
    • socket_path (str) – Path to the Unix socket to use for API communication
    • +
    • api_version (str) – Version of the API to talk to. eg. “0”
    • +
    • args (list of str) – List of remaining arguments from the cmdline
    • +
    • show_json (bool) – Set to True to show the JSON output instead of the human readable output
    • +
    +
    +

    blueprints save <blueprint,...> Save the blueprint to a file, <blueprint-name>.toml

    +
    + +
    +
    +composer.cli.blueprints.blueprints_show(socket_path, api_version, args, show_json=False)[source]¶
    +

    Show the blueprints, in TOML format

    + +++ + + + +
    Parameters:
      +
    • socket_path (str) – Path to the Unix socket to use for API communication
    • +
    • api_version (str) – Version of the API to talk to. eg. “0”
    • +
    • args (list of str) – List of remaining arguments from the cmdline
    • +
    • show_json (bool) – Set to True to show the JSON output instead of the human readable output
    • +
    +
    +

    blueprints show <blueprint,...> Display the blueprint in TOML format.

    +

    Multiple blueprints will be separated by

    +
    + +
    +
    +composer.cli.blueprints.blueprints_tag(socket_path, api_version, args, show_json=False)[source]¶
    +

    Tag the most recent blueprint commit as a release

    + +++ + + + +
    Parameters:
      +
    • socket_path (str) – Path to the Unix socket to use for API communication
    • +
    • api_version (str) – Version of the API to talk to. eg. “0”
    • +
    • args (list of str) – List of remaining arguments from the cmdline
    • +
    • show_json (bool) – Set to True to show the JSON output instead of the human readable output
    • +
    +
    +

    blueprints tag <blueprint> Tag the most recent blueprint commit as a release.

    +
    + +
    +
    +composer.cli.blueprints.blueprints_undo(socket_path, api_version, args, show_json=False)[source]¶
    +

    Undo changes to a blueprint

    + +++ + + + +
    Parameters:
      +
    • socket_path (str) – Path to the Unix socket to use for API communication
    • +
    • api_version (str) – Version of the API to talk to. eg. “0”
    • +
    • args (list of str) – List of remaining arguments from the cmdline
    • +
    • show_json (bool) – Set to True to show the JSON output instead of the human readable output
    • +
    +
    +

    blueprints undo <blueprint> <commit> Undo changes to a blueprint by reverting to the selected commit.

    +
    + +
    +
    +composer.cli.blueprints.blueprints_workspace(socket_path, api_version, args, show_json=False)[source]¶
    +

    Push the blueprint TOML to the temporary workspace storage

    + +++ + + + +
    Parameters:
      +
    • socket_path (str) – Path to the Unix socket to use for API communication
    • +
    • api_version (str) – Version of the API to talk to. eg. “0”
    • +
    • args (list of str) – List of remaining arguments from the cmdline
    • +
    • show_json (bool) – Set to True to show the JSON output instead of the human readable output
    • +
    +
    +

    blueprints workspace <blueprint> Push the blueprint TOML to the temporary workspace storage.

    +
    + +
    +
    +composer.cli.blueprints.prettyCommitDetails(change, indent=4)[source]¶
    +

    Print the blueprint’s change in a nice way

    + +++ + + + +
    Parameters:
      +
    • change (dict) – The individual blueprint change dict
    • +
    • indent (int) – Number of spaces to indent
    • +
    +
    +
    + +
    +
    +composer.cli.blueprints.prettyDiffEntry(diff)[source]¶
    +

    Generate nice diff entry string.

    + +++ + + + + + +
    Parameters:diff (dict) – Difference entry dict
    Returns:Nice string
    +
    +

    compose Module¶

    @@ -91,6 +448,7 @@
  • api_version (str) – Version of the API to talk to. eg. “0”
  • args (list of str) – List of remaining arguments from the cmdline
  • show_json (bool) – Set to True to show the JSON output instead of the human readable output
  • +
  • testmode (int) – unused in this function
  • @@ -132,6 +490,7 @@
  • api_version (str) – Version of the API to talk to. eg. “0”
  • args (list of str) – List of remaining arguments from the cmdline
  • show_json (bool) – Set to True to show the JSON output instead of the human readable output
  • +
  • testmode (int) – unused in this function
  • @@ -155,13 +514,14 @@ or failed, not a running compose.

  • api_version (str) – Version of the API to talk to. eg. “0”
  • args (list of str) – List of remaining arguments from the cmdline
  • show_json (bool) – Set to True to show the JSON output instead of the human readable output
  • +
  • testmode (int) – unused in this function
  • compose details <uuid>

    -

    This returns information about the compose, including the recipe and the dependencies.

    +

    This returns information about the compose, including the blueprint and the dependencies.

    @@ -177,6 +537,7 @@ or failed, not a running compose.

  • api_version (str) – Version of the API to talk to. eg. “0”
  • args (list of str) – List of remaining arguments from the cmdline
  • show_json (bool) – Set to True to show the JSON output instead of the human readable output
  • +
  • testmode (int) – unused in this function
  • @@ -200,6 +561,7 @@ of compose that was selected.

  • api_version (str) – Version of the API to talk to. eg. “0”
  • args (list of str) – List of remaining arguments from the cmdline
  • show_json (bool) – Set to True to show the JSON output instead of the human readable output
  • +
  • testmode (int) – unused in this function
  • @@ -223,6 +585,7 @@ during the build.

  • api_version (str) – Version of the API to talk to. eg. “0”
  • args (list of str) – List of remaining arguments from the cmdline
  • show_json (bool) – Set to True to show the JSON output instead of the human readable output
  • +
  • testmode (int) – unused in this function
  • @@ -245,6 +608,7 @@ during the build.

  • api_version (str) – Version of the API to talk to. eg. “0”
  • args (list of str) – List of remaining arguments from the cmdline
  • show_json (bool) – Set to True to show the JSON output instead of the human readable output
  • +
  • testmode (int) – unused in this function
  • @@ -267,6 +631,7 @@ during the build.

  • api_version (str) – Version of the API to talk to. eg. “0”
  • args (list of str) – List of remaining arguments from the cmdline
  • show_json (bool) – Set to True to show the JSON output instead of the human readable output
  • +
  • testmode (int) – unused in this function
  • @@ -280,7 +645,7 @@ It is saved as uuid.tar

    composer.cli.compose.compose_start(socket_path, api_version, args, show_json=False, testmode=0)[source]¶
    -

    Start a new compose using the selected recipe and type

    +

    Start a new compose using the selected blueprint and type

    @@ -290,12 +655,13 @@ It is saved as uuid.tar

  • api_version (str) – Version of the API to talk to. eg. “0”
  • args (list of str) – List of remaining arguments from the cmdline
  • show_json (bool) – Set to True to show the JSON output instead of the human readable output
  • +
  • testmode (int) – Set to 1 to simulate a failed compose, set to 2 to simulate a finished one.
  • -

    compose start <recipe-name> <compose-type>

    +

    compose start <blueprint-name> <compose-type>

    @@ -311,6 +677,7 @@ It is saved as uuid.tar

  • api_version (str) – Version of the API to talk to. eg. “0”
  • args (list of str) – List of remaining arguments from the cmdline
  • show_json (bool) – Set to True to show the JSON output instead of the human readable output
  • +
  • testmode (int) – unused in this function
  • @@ -322,7 +689,7 @@ and failed so raw JSON output is not available.

    -composer.cli.compose.compose_types(socket_path, api_version, args, show_json=False)[source]¶
    +composer.cli.compose.compose_types(socket_path, api_version, args, show_json=False, testmode=0)[source]¶

    Return information about the supported compose types

    @@ -333,6 +700,7 @@ and failed so raw JSON output is not available.

  • api_version (str) – Version of the API to talk to. eg. “0”
  • args (list of str) – List of remaining arguments from the cmdline
  • show_json (bool) – Set to True to show the JSON output instead of the human readable output
  • +
  • testmode (int) – unused in this function
  • @@ -426,363 +794,6 @@ include this extra information.

    projects list

    - -
    -

    recipes Module¶

    -
    -
    -composer.cli.recipes.prettyCommitDetails(change, indent=4)[source]¶
    -

    Print the recipe’s change in a nice way

    -
    --- - - - -
    Parameters:
      -
    • change (dict) – The individual recipe change dict
    • -
    • indent (int) – Number of spaces to indent
    • -
    -
    -
    - -
    -
    -composer.cli.recipes.prettyDiffEntry(diff)[source]¶
    -

    Generate nice diff entry string.

    - --- - - - - - -
    Parameters:diff (dict) – Difference entry dict
    Returns:Nice string
    -
    - -
    -
    -composer.cli.recipes.recipes_changes(socket_path, api_version, args, show_json=False)[source]¶
    -

    Display the changes for each of the recipes

    - --- - - - -
    Parameters:
      -
    • socket_path (str) – Path to the Unix socket to use for API communication
    • -
    • api_version (str) – Version of the API to talk to. eg. “0”
    • -
    • args (list of str) – List of remaining arguments from the cmdline
    • -
    • show_json (bool) – Set to True to show the JSON output instead of the human readable output
    • -
    -
    -

    recipes changes <recipe,...> Display the changes for each recipe.

    -
    - -
    -
    -composer.cli.recipes.recipes_cmd(opts)[source]¶
    -

    Process recipes commands

    - --- - - - - - - - -
    Parameters:opts (argparse.Namespace) – Cmdline arguments
    Returns:Value to return from sys.exit()
    Return type:int
    -

    This dispatches the recipes commands to a function

    -
    - -
    -
    -composer.cli.recipes.recipes_delete(socket_path, api_version, args, show_json=False)[source]¶
    -

    Delete a recipe from the server

    - --- - - - -
    Parameters:
      -
    • socket_path (str) – Path to the Unix socket to use for API communication
    • -
    • api_version (str) – Version of the API to talk to. eg. “0”
    • -
    • args (list of str) – List of remaining arguments from the cmdline
    • -
    • show_json (bool) – Set to True to show the JSON output instead of the human readable output
    • -
    -
    -

    delete <recipe> Delete a recipe from the server

    -
    - -
    -
    -composer.cli.recipes.recipes_depsolve(socket_path, api_version, args, show_json=False)[source]¶
    -

    Display the packages needed to install the recipe

    - --- - - - -
    Parameters:
      -
    • socket_path (str) – Path to the Unix socket to use for API communication
    • -
    • api_version (str) – Version of the API to talk to. eg. “0”
    • -
    • args (list of str) – List of remaining arguments from the cmdline
    • -
    • show_json (bool) – Set to True to show the JSON output instead of the human readable output
    • -
    -
    -

    recipes depsolve <recipe,...> Display the packages needed to install the recipe.

    -
    - -
    -
    -composer.cli.recipes.recipes_diff(socket_path, api_version, args, show_json=False)[source]¶
    -

    Display the differences between 2 versions of a recipe

    - --- - - - -
    Parameters:
      -
    • socket_path (str) – Path to the Unix socket to use for API communication
    • -
    • api_version (str) – Version of the API to talk to. eg. “0”
    • -
    • args (list of str) – List of remaining arguments from the cmdline
    • -
    • show_json (bool) – Set to True to show the JSON output instead of the human readable output
    • -
    -
    -
    -
    recipes diff <recipe-name> Display the differences between 2 versions of a recipe.
    -
    <from-commit> Commit hash or NEWEST -<to-commit> Commit hash, NEWEST, or WORKSPACE
    -
    -
    - -
    -
    -composer.cli.recipes.recipes_freeze(socket_path, api_version, args, show_json=False)[source]¶
    -

    Handle the recipes freeze commands

    - --- - - - -
    Parameters:
      -
    • socket_path (str) – Path to the Unix socket to use for API communication
    • -
    • api_version (str) – Version of the API to talk to. eg. “0”
    • -
    • args (list of str) – List of remaining arguments from the cmdline
    • -
    • show_json (bool) – Set to True to show the JSON output instead of the human readable output
    • -
    -
    -

    recipes freeze <recipe,...> Display the frozen recipe’s modules and packages. -recipes freeze show <recipe,...> Display the frozen recipe in TOML format. -recipes freeze save <recipe,...> Save the frozen recipe to a file, <recipe-name>.frozen.toml.

    -
    - -
    -
    -composer.cli.recipes.recipes_freeze_save(socket_path, api_version, args, show_json=False)[source]¶
    -

    Save the frozen recipe to a TOML file

    - --- - - - -
    Parameters:
      -
    • socket_path (str) – Path to the Unix socket to use for API communication
    • -
    • api_version (str) – Version of the API to talk to. eg. “0”
    • -
    • args (list of str) – List of remaining arguments from the cmdline
    • -
    • show_json (bool) – Set to True to show the JSON output instead of the human readable output
    • -
    -
    -

    recipes freeze save <recipe,...> Save the frozen recipe to a file, <recipe-name>.frozen.toml.

    -
    - -
    -
    -composer.cli.recipes.recipes_freeze_show(socket_path, api_version, args, show_json=False)[source]¶
    -

    Show the frozen recipe in TOML format

    - --- - - - -
    Parameters:
      -
    • socket_path (str) – Path to the Unix socket to use for API communication
    • -
    • api_version (str) – Version of the API to talk to. eg. “0”
    • -
    • args (list of str) – List of remaining arguments from the cmdline
    • -
    • show_json (bool) – Set to True to show the JSON output instead of the human readable output
    • -
    -
    -

    recipes freeze show <recipe,...> Display the frozen recipe in TOML format.

    -
    - -
    -
    -composer.cli.recipes.recipes_list(socket_path, api_version, args, show_json=False)[source]¶
    -

    Output the list of available recipes

    - --- - - - -
    Parameters:
      -
    • socket_path (str) – Path to the Unix socket to use for API communication
    • -
    • api_version (str) – Version of the API to talk to. eg. “0”
    • -
    • args (list of str) – List of remaining arguments from the cmdline
    • -
    • show_json (bool) – Set to True to show the JSON output instead of the human readable output
    • -
    -
    -

    recipes list

    -
    - -
    -
    -composer.cli.recipes.recipes_push(socket_path, api_version, args, show_json=False)[source]¶
    -

    Push a recipe TOML file to the server, updating the recipe

    - --- - - - -
    Parameters:
      -
    • socket_path (str) – Path to the Unix socket to use for API communication
    • -
    • api_version (str) – Version of the API to talk to. eg. “0”
    • -
    • args (list of str) – List of remaining arguments from the cmdline
    • -
    • show_json (bool) – Set to True to show the JSON output instead of the human readable output
    • -
    -
    -

    push <recipe> Push a recipe TOML file to the server.

    -
    - -
    -
    -composer.cli.recipes.recipes_save(socket_path, api_version, args, show_json=False)[source]¶
    -

    Save the recipe to a TOML file

    - --- - - - -
    Parameters:
      -
    • socket_path (str) – Path to the Unix socket to use for API communication
    • -
    • api_version (str) – Version of the API to talk to. eg. “0”
    • -
    • args (list of str) – List of remaining arguments from the cmdline
    • -
    • show_json (bool) – Set to True to show the JSON output instead of the human readable output
    • -
    -
    -

    recipes save <recipe,...> Save the recipe to a file, <recipe-name>.toml

    -
    - -
    -
    -composer.cli.recipes.recipes_show(socket_path, api_version, args, show_json=False)[source]¶
    -

    Show the recipes, in TOML format

    - --- - - - -
    Parameters:
      -
    • socket_path (str) – Path to the Unix socket to use for API communication
    • -
    • api_version (str) – Version of the API to talk to. eg. “0”
    • -
    • args (list of str) – List of remaining arguments from the cmdline
    • -
    • show_json (bool) – Set to True to show the JSON output instead of the human readable output
    • -
    -
    -

    recipes show <recipe,...> Display the recipe in TOML format.

    -

    Multiple recipes will be separated by

    -
    - -
    -
    -composer.cli.recipes.recipes_tag(socket_path, api_version, args, show_json=False)[source]¶
    -

    Tag the most recent recipe commit as a release

    - --- - - - -
    Parameters:
      -
    • socket_path (str) – Path to the Unix socket to use for API communication
    • -
    • api_version (str) – Version of the API to talk to. eg. “0”
    • -
    • args (list of str) – List of remaining arguments from the cmdline
    • -
    • show_json (bool) – Set to True to show the JSON output instead of the human readable output
    • -
    -
    -

    recipes tag <recipe> Tag the most recent recipe commit as a release.

    -
    - -
    -
    -composer.cli.recipes.recipes_undo(socket_path, api_version, args, show_json=False)[source]¶
    -

    Undo changes to a recipe

    - --- - - - -
    Parameters:
      -
    • socket_path (str) – Path to the Unix socket to use for API communication
    • -
    • api_version (str) – Version of the API to talk to. eg. “0”
    • -
    • args (list of str) – List of remaining arguments from the cmdline
    • -
    • show_json (bool) – Set to True to show the JSON output instead of the human readable output
    • -
    -
    -

    recipes undo <recipe> <commit> Undo changes to a recipe by reverting to the selected commit.

    -
    - -
    -
    -composer.cli.recipes.recipes_workspace(socket_path, api_version, args, show_json=False)[source]¶
    -

    Push the recipe TOML to the temporary workspace storage

    - --- - - - -
    Parameters:
      -
    • socket_path (str) – Path to the Unix socket to use for API communication
    • -
    • api_version (str) – Version of the API to talk to. eg. “0”
    • -
    • args (list of str) – List of remaining arguments from the cmdline
    • -
    • show_json (bool) – Set to True to show the JSON output instead of the human readable output
    • -
    -
    -

    recipes workspace <recipe> Push the recipe TOML to the temporary workspace storage.

    -
    -

    utilities Module¶

    @@ -808,15 +819,15 @@ recipes freeze save <recipe,...> Save the frozen recipe to a file, <rec
    -composer.cli.utilities.frozen_toml_filename(recipe_name)[source]¶
    -

    Convert a recipe name into a filename.toml

    +composer.cli.utilities.frozen_toml_filename(blueprint_name)[source]¶ +

    Convert a blueprint name into a filename.toml

    - + - + @@ -858,15 +869,15 @@ recipes freeze save <recipe,...> Save the frozen recipe to a file, <rec
    -composer.cli.utilities.toml_filename(recipe_name)[source]¶
    -

    Convert a recipe name into a filename.toml

    +composer.cli.utilities.toml_filename(blueprint_name)[source]¶ +

    Convert a blueprint name into a filename.toml

    Parameters:recipe_name (str) – The recipe’s name
    Parameters:blueprint_name (str) – The blueprint’s name
    Returns:The recipe name with ‘ ‘ converted to - and .toml appended
    Returns:The blueprint name with ‘ ‘ converted to - and .toml appended
    Return type:str
    - + - + @@ -887,10 +898,10 @@ recipes freeze save <recipe,...> Save the frozen recipe to a file, <rec diff --git a/lorax-composer/composer.html b/lorax-composer/composer.html index 5760e7ff..e27aff08 100644 --- a/lorax-composer/composer.html +++ b/lorax-composer/composer.html @@ -8,7 +8,7 @@ - composer Package — Lorax 19.7.11 documentation + composer Package — Lorax 19.7.14 documentation @@ -16,7 +16,7 @@ - + @@ -46,7 +46,7 @@
  • previous |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • src »
  • @@ -250,7 +250,7 @@
    composer.http_client.post_url_toml(socket_path, url, body)[source]¶
    -

    POST a TOML recipe to the URL

    +

    POST a TOML string to the URL

    Parameters:recipe_name (str) – The recipe’s name
    Parameters:blueprint_name (str) – The blueprint’s name
    Returns:The recipe name with ‘ ‘ converted to - and .toml appended
    Returns:The blueprint name with ‘ ‘ converted to - and .toml appended
    Return type:str
    @@ -299,10 +299,10 @@ diff --git a/lorax-composer/genindex.html b/lorax-composer/genindex.html index 44ff1bf8..5fa93693 100644 --- a/lorax-composer/genindex.html +++ b/lorax-composer/genindex.html @@ -10,7 +10,7 @@ - Index — Lorax 19.7.11 documentation + Index — Lorax 19.7.14 documentation @@ -18,7 +18,7 @@ - + @@ -126,6 +126,68 @@ +
    blueprints_changes() (in module composer.cli.blueprints) +
    + + +
    blueprints_cmd() (in module composer.cli.blueprints) +
    + + +
    blueprints_delete() (in module composer.cli.blueprints) +
    + + +
    blueprints_depsolve() (in module composer.cli.blueprints) +
    + + +
    blueprints_diff() (in module composer.cli.blueprints) +
    + + +
    blueprints_freeze() (in module composer.cli.blueprints) +
    + + +
    blueprints_freeze_save() (in module composer.cli.blueprints) +
    + + +
    blueprints_freeze_show() (in module composer.cli.blueprints) +
    + + +
    blueprints_list() (in module composer.cli.blueprints) +
    + + + - - + + + + - - -
    + +
    blueprints_push() (in module composer.cli.blueprints) +
    + + +
    blueprints_save() (in module composer.cli.blueprints) +
    + + +
    blueprints_show() (in module composer.cli.blueprints) +
    + + +
    blueprints_tag() (in module composer.cli.blueprints) +
    + + +
    blueprints_undo() (in module composer.cli.blueprints) +
    + + +
    blueprints_workspace() (in module composer.cli.blueprints) +
    + +
    brace_expand() (in module pylorax.ltmpl)
    @@ -133,8 +195,6 @@
    build() (pylorax.treebuilder.TreeBuilder method)
    -
    build_status() (in module pylorax.api.queue)
    @@ -262,6 +322,10 @@ +
    composer.cli.blueprints (module) +
    + +
    composer.cli.compose (module)
    @@ -274,10 +338,6 @@ -
    composer.cli.recipes (module) -
    - -
    composer.cli.utilities (module)
    @@ -438,9 +498,15 @@ -
    estimate_size() (in module pylorax.imgutils) +
    estimate_size() (in module pylorax.api.projects)
    +
    + +
    (in module pylorax.imgutils) +
    + +
    event() (pylorax.yumhelper.LoraxRpmCallback method)
    @@ -564,12 +630,16 @@ -
    get_iso_label() (pylorax.installer.IsoMountpoint method) +
    get_image_name() (in module pylorax.api.queue)
    +
    get_iso_label() (pylorax.installer.IsoMountpoint method) +
    + +
    get_kernel_arch() (pylorax.creator.KernelInfo method)
    @@ -1040,11 +1110,11 @@ -
    prettyCommitDetails() (in module composer.cli.recipes) +
    prettyCommitDetails() (in module composer.cli.blueprints)
    -
    prettyDiffEntry() (in module composer.cli.recipes) +
    prettyDiffEntry() (in module composer.cli.blueprints)
    @@ -1056,6 +1126,10 @@ +
    projects_depsolve_with_size() (in module pylorax.api.projects) +
    + +
    projects_info() (in module composer.cli.projects)
    @@ -1274,68 +1348,6 @@ -
    recipes_changes() (in module composer.cli.recipes) -
    - - -
    recipes_cmd() (in module composer.cli.recipes) -
    - - -
    recipes_delete() (in module composer.cli.recipes) -
    - - -
    recipes_depsolve() (in module composer.cli.recipes) -
    - - -
    recipes_diff() (in module composer.cli.recipes) -
    - - -
    recipes_freeze() (in module composer.cli.recipes) -
    - - -
    recipes_freeze_save() (in module composer.cli.recipes) -
    - - -
    recipes_freeze_show() (in module composer.cli.recipes) -
    - - -
    recipes_list() (in module composer.cli.recipes) -
    - -
    - -
    recipes_push() (in module composer.cli.recipes) -
    - - -
    recipes_save() (in module composer.cli.recipes) -
    - - -
    recipes_show() (in module composer.cli.recipes) -
    - - -
    recipes_tag() (in module composer.cli.recipes) -
    - - -
    recipes_undo() (in module composer.cli.recipes) -
    - - -
    recipes_workspace() (in module composer.cli.recipes) -
    - -
    remove() (in module pylorax.sysutils)
    @@ -1345,6 +1357,8 @@
    +
    removefrom() (pylorax.ltmpl.LoraxTemplateRunner method)
    @@ -1726,7 +1740,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • @@ -125,7 +125,7 @@
  • next |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • @@ -161,7 +161,7 @@ upd-instroot and mk-images* scripts.

  • previous |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • @@ -446,7 +446,7 @@ report bugs against the lorax component.

  • previous |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • @@ -90,18 +90,18 @@ messages as well as extra debugging info and API requests.

  • Remove any pre-existing socket directory with rm -rf /run/weldr/ A new directory with correct permissions will be created the first time the server runs.
  • Either start it via systemd with systemctl start lorax-composer or -run it directly with lorax-composer /path/to/recipes/
  • +run it directly with lorax-composer /path/to/blueprints/ -

    The /path/to/recipes/ is where the recipe’s git repo will be created, and -all the recipes created with the /api/v0/recipes/new route will be stored. -If there are recipe .toml files in the top level of the directory they will -be imported into the recipe git storage.

    +

    The /path/to/blueprints/ is where the blueprint’s git repo will be created, and +all the blueprints created with the /api/v0/blueprints/new route will be stored. +If there are blueprint .toml files in the top level of the directory they will +be imported into the blueprint git storage.

    Composing Images¶

    As of version 19.7.7 lorax-composer can create tar output images. You can use curl to start a compose like this:

    -
    curl --unix-socket /run/weldr/api.socket -X POST -H "Content-Type: application/json" -d '{"recipe_name": "http-server", "compose_type": "tar", "branch": "master"}' http:///api/v0/compose
    +
    curl --unix-socket /run/weldr/api.socket -X POST -H "Content-Type: application/json" -d '{"blueprint_name": "http-server", "compose_type": "tar", "branch": "master"}' http:///api/v0/compose

    And then monitor it by passing the returned build UUID to /compose/status/<uuid>.

    Version 19.7.10 adds support for live-iso and partitioned-disk

    @@ -139,7 +139,7 @@ in ./docs/rhel7-minimal.ks commands, they will be added by the compose process. Make sure the bootloader packages are included in the %packages section at the end of the kickstart, and you will want to leave off the %end so that the compose can append the -list of packages from the recipe.

    +list of packages from the blueprint.

    The new _MAP entry should be a copy of one of the existing entries, but with make_disk set to True. Make sure that none of the other make_* options are True. The image_name is what the name of the final image will be.

    @@ -215,7 +215,7 @@ the contents of the iso as well as the boot.iso itself.

  • previous |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • @@ -254,7 +254,7 @@ into another directory and then select the new template directory by passing
  • previous |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • @@ -65,10 +65,10 @@
  • Subpackages
  • previous |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • @@ -127,7 +127,7 @@ command or the installpkgs paramater of previous | -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • @@ -72,6 +72,11 @@
        composer.cli
        + composer.cli.blueprints +
        @@ -87,11 +92,6 @@     composer.cli.projects
        - composer.cli.recipes -
        @@ -280,7 +280,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • +
    +
    +pylorax.api.projects.projects_depsolve_with_size(yb, project_names, with_core=True)[source]¶
    +

    Return the dependencies and installed size for a list of projects

    + +++ + + + + + + + +
    Parameters:
      +
    • yb (YumBase) – yum base object
    • +
    • project_names (List of Strings) – The projects to find the dependencies for
    • +
    +
    Returns:

    installed size and a list of NEVRA’s of the project and its dependencies

    +
    Return type:

    tuple of (int, list of dicts)

    +
    +
    +
    pylorax.api.projects.projects_info(yb, project_names)[source]¶
    @@ -540,6 +591,8 @@ Use queue_status() for those.

    Return type:dict +Raises :IOError if it cannot read the directory, STATUS, or blueprint file. +

    The following details are included in the dict:

    @@ -548,8 +601,9 @@ Use queue_status() for those.

  • queue_status - The final status of the composition (FINISHED or FAILED)
  • timestamp - The time of the last status change
  • compose_type - The type of output generated (tar, iso, etc.)
  • -
  • recipe - Recipe name
  • -
  • version - Recipe version
  • +
  • blueprint - Blueprint name
  • +
  • version - Blueprint version
  • +
  • image_size - Size of the image, if finished. 0 otherwise.
  • @@ -573,6 +627,26 @@ Use queue_status() for those.

    +
    +
    +pylorax.api.queue.get_image_name(uuid_dir)[source]¶
    +

    Return the filename and full path of the build’s image file

    + +++ + + + + + + + + + +
    Parameters:uuid (str) – The UUID of the build
    Returns:The image filename and full path
    Return type:tuple of strings
    Raises :RuntimeError if there was a problem (eg. invalid uuid, missing config file)
    +
    +
    pylorax.api.queue.make_compose(cfg, results_dir)[source]¶
    @@ -777,8 +851,8 @@ and “run” has the uuids that are being built (currently limited to 1
    • id - The uuid of the comoposition
    • config - containing the configuration settings used to run Anaconda
    • -
    • recipe - The depsolved recipe used to generate the kickstart
    • -
    • commit - The (local) git commit hash for the recipe used
    • +
    • blueprint - The depsolved blueprint used to generate the kickstart
    • +
    • commit - The (local) git commit hash for the blueprint used
    • deps - The NEVRA of all of the dependencies used in the composition
    • compose_type - The type of output generated (tar, iso, etc.)
    • queue_status - The final status of the composition (FINISHED or FAILED)
    • @@ -1875,47 +1949,26 @@ error response with it set to false and an error message included.

    Error response:

    -
    {
    -  "error": {
    -    "msg": "ggit-error: Failed to remove entry. File isn't in the tree - jboss.toml (-1)"
    -  },
    -  "status": false
    -}
    -
    +
    {
    +  "errors": ["ggit-error: Failed to remove entry. File isn't in the tree - jboss.toml (-1)"]
    +  "status": false
    +}

    API Routes¶

    -

    All of the recipes routes support the optional branch argument. If it is not -used then the API will use the master branch for recipes. If you want to create +

    All of the blueprints routes support the optional branch argument. If it is not +used then the API will use the master branch for blueprints. If you want to create a new branch use the new or workspace routes with ?branch=<branch-name> to -store the new recipe on the new branch.

    -
    -

    /api/v0/test¶

    +store the new blueprint on the new branch.

    +
    +

    /api/v0/blueprints/list¶

    -
    Return a test string. It is not JSON encoded.
    -
    -
    -

    /api/v0/status¶

    -
    -

    Return the status of the API Server:

    -
    { "api": "0",
    -  "build": "devel",
    -  "db_supported": false,
    -  "db_version": "0",
    -  "schema_version": "0" }
    -
    -
    -
    -
    -
    -

    /api/v0/recipes/list¶

    -
    -

    List the available recipes:

    +

    List the available blueprints:

    { "limit": 20,
       "offset": 0,
    -  "recipes": [
    +  "blueprints": [
         "atlas",
         "development",
         "glusterfs",
    @@ -1927,13 +1980,13 @@ store the new recipe on the new branch.

    -
    -

    /api/v0/recipes/info/<recipe_names>¶

    +
    +

    /api/v0/blueprints/info/<blueprint_names>¶

    -

    Return the JSON representation of the recipe. This includes 3 top level +

    Return the JSON representation of the blueprint. This includes 3 top level objects. changes which lists whether or not the workspace is different from -the most recent commit. recipes which lists the JSON representation of the -recipe, and errors which will list any errors, like non-existant recipes.

    +the most recent commit. blueprints which lists the JSON representation of the +blueprint, and errors which will list any errors, like non-existant blueprints.

    Example:

    {
       "changes": [
    @@ -1943,7 +1996,7 @@ recipe, and errors which will list any errors, like non-existant re
         }
       ],
       "errors": [],
    -  "recipes": [
    +  "blueprints": [
         {
           "description": "An example GlusterFS server with samba",
           "modules": [
    @@ -1974,68 +2027,62 @@ recipe, and errors which will list any errors, like non-existant re
     

    Error example:

    -
    {
    -  "changes": [],
    -  "errors": [
    -    {
    -      "msg": "ggit-error: the path 'missing.toml' does not exist in the given tree (-3)",
    -      "recipe": "missing"
    -    }
    -  ],
    -  "recipes": []
    -}
    -
    +
    {
    +  "changes": [],
    +  "errors": ["ggit-error: the path 'missing.toml' does not exist in the given tree (-3)"]
    +  "blueprints": []
    +}
    -
    -

    /api/v0/recipes/changes/<recipe_names>[?offset=0&limit=20]¶

    +
    +

    /api/v0/blueprints/changes/<blueprint_names>[?offset=0&limit=20]¶

    -

    Return the commits to a recipe. By default it returns the first 20 commits, this +

    Return the commits to a blueprint. By default it returns the first 20 commits, this can be changed by passing offset and/or limit. The response will include the commit hash, summary, timestamp, and optionally the revision number. The commit -hash can be passed to /api/v0/recipes/diff/ to retrieve the exact changes.

    +hash can be passed to /api/v0/blueprints/diff/ to retrieve the exact changes.

    Example:

    {
       "errors": [],
       "limit": 20,
       "offset": 0,
    -  "recipes": [
    +  "blueprints": [
         {
           "changes": [
             {
               "commit": "e083921a7ed1cf2eec91ad12b9ad1e70ef3470be",
    -          "message": "Recipe glusterfs, version 0.0.6 saved.",
    +          "message": "blueprint glusterfs, version 0.0.6 saved.",
               "revision": null,
               "timestamp": "2017-11-23T00:18:13Z"
             },
             {
               "commit": "cee5f4c20fc33ea4d54bfecf56f4ad41ad15f4f3",
    -          "message": "Recipe glusterfs, version 0.0.5 saved.",
    +          "message": "blueprint glusterfs, version 0.0.5 saved.",
               "revision": null,
               "timestamp": "2017-11-11T01:00:28Z"
             },
             {
               "commit": "29b492f26ed35d80800b536623bafc51e2f0eff2",
    -          "message": "Recipe glusterfs, version 0.0.4 saved.",
    +          "message": "blueprint glusterfs, version 0.0.4 saved.",
               "revision": null,
               "timestamp": "2017-11-11T00:28:30Z"
             },
             {
               "commit": "03374adbf080fe34f5c6c29f2e49cc2b86958bf2",
    -          "message": "Recipe glusterfs, version 0.0.3 saved.",
    +          "message": "blueprint glusterfs, version 0.0.3 saved.",
               "revision": null,
               "timestamp": "2017-11-10T23:15:52Z"
             },
             {
               "commit": "0e08ecbb708675bfabc82952599a1712a843779d",
    -          "message": "Recipe glusterfs, version 0.0.2 saved.",
    +          "message": "blueprint glusterfs, version 0.0.2 saved.",
               "revision": null,
               "timestamp": "2017-11-10T23:14:56Z"
             },
             {
               "commit": "3e11eb87a63d289662cba4b1804a0947a6843379",
    -          "message": "Recipe glusterfs, version 0.0.1 saved.",
    +          "message": "blueprint glusterfs, version 0.0.1 saved.",
               "revision": null,
               "timestamp": "2017-11-08T00:02:47Z"
             }
    @@ -2049,70 +2096,70 @@ hash can be passed to /api/v0/recipes/diff/ to retrieve the exact c
     
    -
    -

    POST /api/v0/recipes/new¶

    +
    +

    POST /api/v0/blueprints/new¶

    -

    Create a new recipe, or update an existing recipe. This supports both JSON and TOML -for the recipe format. The recipe should be in the body of the request with the +

    Create a new blueprint, or update an existing blueprint. This supports both JSON and TOML +for the blueprint format. The blueprint should be in the body of the request with the Content-Type header set to either application/json or text/x-toml.

    The response will be a status response with status set to true, or an error response with it set to false and an error message included.

    -
    -

    DELETE /api/v0/recipes/delete/<recipe_name>¶

    +
    +

    DELETE /api/v0/blueprints/delete/<blueprint_name>¶

    -

    Delete a recipe. The recipe is deleted from the branch, and will no longer -be listed by the list route. A recipe can be undeleted using the undo route +

    Delete a blueprint. The blueprint is deleted from the branch, and will no longer +be listed by the list route. A blueprint can be undeleted using the undo route to revert to a previous commit.

    The response will be a status response with status set to true, or an error response with it set to false and an error message included.

    -
    -

    POST /api/v0/recipes/workspace¶

    +
    +

    POST /api/v0/blueprints/workspace¶

    -

    Write a recipe to the temporary workspace. This works exactly the same as new except +

    Write a blueprint to the temporary workspace. This works exactly the same as new except that it does not create a commit. JSON and TOML bodies are supported.

    -

    The workspace is meant to be used as a temporary recipe storage for clients. +

    The workspace is meant to be used as a temporary blueprint storage for clients. It will be read by the info and diff routes if it is different from the most recent commit.

    The response will be a status response with status set to true, or an error response with it set to false and an error message included.

    -
    -

    DELETE /api/v0/recipes/workspace/<recipe_name>¶

    +
    +

    DELETE /api/v0/blueprints/workspace/<blueprint_name>¶

    -

    Remove the temporary workspace copy of a recipe. The info route will now -return the most recent commit of the recipe. Any changes that were in the +

    Remove the temporary workspace copy of a blueprint. The info route will now +return the most recent commit of the blueprint. Any changes that were in the workspace will be lost.

    The response will be a status response with status set to true, or an error response with it set to false and an error message included.

    -
    -

    POST /api/v0/recipes/undo/<recipe_name>/<commit>¶

    +
    +

    POST /api/v0/blueprints/undo/<blueprint_name>/<commit>¶

    -

    This will revert the recipe to a previous commit. The commit hash from the changes +

    This will revert the blueprint to a previous commit. The commit hash from the changes route can be used in this request.

    The response will be a status response with status set to true, or an error response with it set to false and an error message included.

    -
    -

    POST /api/v0/recipes/tag/<recipe_name>¶

    +
    +

    POST /api/v0/blueprints/tag/<blueprint_name>¶

    -

    Tag a recipe as a new release. This uses git tags with a special format. -refs/tags/<branch>/<filename>/r<revision>. Only the most recent recipe commit +

    Tag a blueprint as a new release. This uses git tags with a special format. +refs/tags/<branch>/<filename>/r<revision>. Only the most recent blueprint commit can be tagged. Revisions start at 1 and increment for each new tag -(per-recipe). If the commit has already been tagged it will return false.

    +(per-blueprint). If the commit has already been tagged it will return false.

    The response will be a status response with status set to true, or an error response with it set to false and an error message included.

    -
    -

    /api/v0/recipes/diff/<recipe_name>/<from_commit>/<to_commit>¶

    +
    +

    /api/v0/blueprints/diff/<blueprint_name>/<from_commit>/<to_commit>¶

    Return the differences between two commits, or the workspace. The commit hash from the changes response can be used here, or several special strings:

    @@ -2120,13 +2167,13 @@ from the changes response can be used here, or several special stri
  • NEWEST will select the newest git commit. This works for from_commit or to_commit
  • WORKSPACE will select the workspace copy. This can only be used in to_commit
  • -

    eg. /api/v0/recipes/diff/glusterfs/NEWEST/WORKSPACE will return the differences +

    eg. /api/v0/blueprints/diff/glusterfs/NEWEST/WORKSPACE will return the differences between the most recent git commit and the contents of the workspace.

    -

    Each entry in the response’s diff object contains the old recipe value and the new one. +

    Each entry in the response’s diff object contains the old blueprint value and the new one. If old is null and new is set, then it was added. If new is null and old is set, then it was removed. If both are set, then it was changed.

    -

    The old/new entries will have the name of the recipe field that was changed. This +

    The old/new entries will have the name of the blueprint field that was changed. This can be one of: Name, Description, Version, Module, or Package. The contents for these will be the old/new values for them.

    In the example below the version was changed and the ping package was added.

    @@ -2156,17 +2203,17 @@ The contents for these will be the old/new values for them.

    -
    -

    /api/v0/recipes/freeze/<recipe_names>¶

    +
    +

    /api/v0/blueprints/freeze/<blueprint_names>¶

    -

    Return a JSON representation of the recipe with the package and module versions set -to the exact versions chosen by depsolving the recipe.

    +

    Return a JSON representation of the blueprint with the package and module versions set +to the exact versions chosen by depsolving the blueprint.

    Example:

    {
       "errors": [],
    -  "recipes": [
    +  "blueprints": [
         {
    -      "recipe": {
    +      "blueprint": {
             "description": "An example GlusterFS server with samba",
             "modules": [
               {
    @@ -2198,17 +2245,17 @@ to the exact versions chosen by depsolving the recipe.

    -
    -

    /api/v0/recipes/depsolve/<recipe_names>¶

    +
    +

    /api/v0/blueprints/depsolve/<blueprint_names>¶

    -

    Depsolve the recipe using yum, return the recipe used, and the NEVRAs of the packages -chosen to satisfy the recipe’s requirements. The response will include a list of results, -with the full dependency list in dependencies, the NEVRAs for the recipe’s direct modules +

    Depsolve the blueprint using yum, return the blueprint used, and the NEVRAs of the packages +chosen to satisfy the blueprint’s requirements. The response will include a list of results, +with the full dependency list in dependencies, the NEVRAs for the blueprint’s direct modules and packages in modules, and any error will be in errors.

    Example:

    {
       "errors": [],
    -  "recipes": [
    +  "blueprints": [
         {
           "dependencies": [
             {
    @@ -2258,7 +2305,7 @@ and packages in modules, and any error will be in errors
     

    Start a compose. The content type should be ‘application/json’ and the body of the POST should look like this:

    {
    -  "recipe_name": "http-server",
    +  "blueprint_name": "http-server",
       "compose_type": "tar",
       "branch": "master"
     }
     
    -

    Pass it the name of the recipe, the type of output (from ‘/api/v0/compose/types’), and the -recipe branch to use. ‘branch’ is optional and will default to master. It will create a new +

    Pass it the name of the blueprint, the type of output (from ‘/api/v0/compose/types’), and the +blueprint branch to use. ‘branch’ is optional and will default to master. It will create a new build and add it to the queue. It returns the build uuid and a status if it succeeds:

    {
       "build_id": "e6fa6db4-9c81-4b70-870f-a697ca405cdf",
    @@ -2520,14 +2567,14 @@ and the build that is running.

    "new": [ { "id": "45502a6d-06e8-48a5-a215-2b4174b3614b", - "recipe": "glusterfs", + "blueprint": "glusterfs", "queue_status": "WAITING", "timestamp": 1517362647.4570868, "version": "0.0.6" }, { "id": "6d292bd0-bec7-4825-8d7d-41ef9c3e4b73", - "recipe": "kubernetes", + "blueprint": "kubernetes", "queue_status": "WAITING", "timestamp": 1517362659.0034983, "version": "0.0.1" @@ -2536,7 +2583,7 @@ and the build that is running.

    "run": [ { "id": "745712b2-96db-44c0-8014-fe925c35e795", - "recipe": "glusterfs", + "blueprint": "glusterfs", "queue_status": "RUNNING", "timestamp": 1517362633.7965999, "version": "0.0.6" @@ -2556,14 +2603,14 @@ and the build that is running.

    "finished": [ { "id": "70b84195-9817-4b8a-af92-45e380f39894", - "recipe": "glusterfs", + "blueprint": "glusterfs", "queue_status": "FINISHED", "timestamp": 1517351003.8210032, "version": "0.0.6" }, { "id": "e695affd-397f-4af9-9022-add2636e7459", - "recipe": "glusterfs", + "blueprint": "glusterfs", "queue_status": "FINISHED", "timestamp": 1517362289.7193348, "version": "0.0.6" @@ -2583,7 +2630,7 @@ and the build that is running.

    "failed": [ { "id": "8c8435ef-d6bd-4c68-9bf1-a2ef832e6b1a", - "recipe": "http-server", + "blueprint": "http-server", "queue_status": "FAILED", "timestamp": 1517523249.9301329, "version": "0.0.2" @@ -2603,14 +2650,14 @@ and the build that is running.

    "uuids": [ { "id": "8c8435ef-d6bd-4c68-9bf1-a2ef832e6b1a", - "recipe": "http-server", + "blueprint": "http-server", "queue_status": "FINISHED", "timestamp": 1517523644.2384307, "version": "0.0.2" }, { "id": "45502a6d-06e8-48a5-a215-2b4174b3614b", - "recipe": "glusterfs", + "blueprint": "glusterfs", "queue_status": "FINISHED", "timestamp": 1517363442.188399, "version": "0.0.6" @@ -2621,8 +2668,8 @@ and the build that is running.

    -
    -

    DELETE /api/v0/recipes/cancel/<uuid>¶

    +
    +

    DELETE /api/v0/blueprints/cancel/<uuid>¶

    Cancel the build, if it is not finished, and delete the results. It will return a status of True if it is successful.

    @@ -2662,8 +2709,8 @@ contain the following information:

    @@ -116,27 +116,27 @@

    Bases: object

    -pcritical(msg, fobj=<open file '<stdout>', mode 'w' at 0x7f4f7f21e150>)[source]¶
    +pcritical(msg, fobj=<open file '<stdout>', mode 'w' at 0x7f1c44b99150>)[source]¶
    -pdebug(msg, fobj=<open file '<stdout>', mode 'w' at 0x7f4f7f21e150>)[source]¶
    +pdebug(msg, fobj=<open file '<stdout>', mode 'w' at 0x7f1c44b99150>)[source]¶
    -perror(msg, fobj=<open file '<stdout>', mode 'w' at 0x7f4f7f21e150>)[source]¶
    +perror(msg, fobj=<open file '<stdout>', mode 'w' at 0x7f1c44b99150>)[source]¶
    -pinfo(msg, fobj=<open file '<stdout>', mode 'w' at 0x7f4f7f21e150>)[source]¶
    +pinfo(msg, fobj=<open file '<stdout>', mode 'w' at 0x7f1c44b99150>)[source]¶
    -pwarning(msg, fobj=<open file '<stdout>', mode 'w' at 0x7f4f7f21e150>)[source]¶
    +pwarning(msg, fobj=<open file '<stdout>', mode 'w' at 0x7f1c44b99150>)[source]¶
    @@ -1477,20 +1477,18 @@ image is built with the filename “${prefix}-${kernel.version}.img”v0 Module
    diff --git a/lorax-composer/search.html b/lorax-composer/search.html index 73cdf6ef..258c390a 100644 --- a/lorax-composer/search.html +++ b/lorax-composer/search.html @@ -8,7 +8,7 @@ - Search — Lorax 19.7.11 documentation + Search — Lorax 19.7.14 documentation @@ -16,7 +16,7 @@ - + @@ -43,7 +43,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »
  • @@ -94,7 +94,7 @@
  • modules |
  • -
  • Lorax 19.7.11 documentation »
  • +
  • Lorax 19.7.14 documentation »