diff --git a/lorax-composer/.buildinfo b/lorax-composer/.buildinfo index 130de2d2..3c3eb358 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: 66d7c44afa220f9e7a6f61390f7186ec +config: 06e0a93740d8be1d7bb18b9ff5eed1aa tags: fbb0d17656682115ca4d033fb2f83ba1 diff --git a/lorax-composer/.doctrees/composer-cli.doctree b/lorax-composer/.doctrees/composer-cli.doctree index c5e4f7f9..349f3496 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.cli.doctree b/lorax-composer/.doctrees/composer.cli.doctree index 3a8e3b49..f031a718 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 46f0423b..fdc8580d 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 73e5f721..60149ef0 100644 Binary files a/lorax-composer/.doctrees/environment.pickle and b/lorax-composer/.doctrees/environment.pickle differ diff --git a/lorax-composer/.doctrees/index.doctree b/lorax-composer/.doctrees/index.doctree index 00292331..cd64c804 100644 Binary files a/lorax-composer/.doctrees/index.doctree and b/lorax-composer/.doctrees/index.doctree differ diff --git a/lorax-composer/.doctrees/intro.doctree b/lorax-composer/.doctrees/intro.doctree index ae15758e..004bc8f6 100644 Binary files a/lorax-composer/.doctrees/intro.doctree and b/lorax-composer/.doctrees/intro.doctree differ diff --git a/lorax-composer/.doctrees/livemedia-creator.doctree b/lorax-composer/.doctrees/livemedia-creator.doctree index 01cd323b..96d09883 100644 Binary files a/lorax-composer/.doctrees/livemedia-creator.doctree and b/lorax-composer/.doctrees/livemedia-creator.doctree differ diff --git a/lorax-composer/.doctrees/lorax-composer.doctree b/lorax-composer/.doctrees/lorax-composer.doctree index dbc6176c..3f411994 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 c87f93db..c4730d86 100644 Binary files a/lorax-composer/.doctrees/lorax.doctree and b/lorax-composer/.doctrees/lorax.doctree differ diff --git a/lorax-composer/.doctrees/modules.doctree b/lorax-composer/.doctrees/modules.doctree index 01a71d71..e0b19e52 100644 Binary files a/lorax-composer/.doctrees/modules.doctree and b/lorax-composer/.doctrees/modules.doctree differ diff --git a/lorax-composer/.doctrees/product-images.doctree b/lorax-composer/.doctrees/product-images.doctree index 10c47522..494ffddb 100644 Binary files a/lorax-composer/.doctrees/product-images.doctree and b/lorax-composer/.doctrees/product-images.doctree differ diff --git a/lorax-composer/.doctrees/pylorax.api.doctree b/lorax-composer/.doctrees/pylorax.api.doctree index 367b13dc..dac98f24 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 9322d0eb..0b789463 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 965dad1b..3e7fe20c 100644 --- a/lorax-composer/_modules/composer/cli.html +++ b/lorax-composer/_modules/composer/cli.html @@ -8,7 +8,7 @@
-
+#
+# 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")
+
+from composer import http_client as client
+from composer.cli.help import status_help
+from composer.cli.utilities import handle_api_result
+
+[docs]def status_cmd(opts):
+ """Process status commands
+
+ :param opts: Cmdline arguments
+ :type opts: argparse.Namespace
+ :returns: Value to return from sys.exit()
+ :rtype: int
+ """
+ if opts.args[1] == "help" or opts.args[1] == "--help":
+ print(status_help)
+ return 0
+ elif opts.args[1] != "show":
+ log.error("Unknown status command: %s", opts.args[1])
+ return 1
+
+ result = client.get_url_json(opts.socket, "/api/status")
+ (rc, exit_now) = handle_api_result(result, opts.json)
+ if exit_now:
+ return rc
+
+ print("API server status:")
+ print(" Database version: " + result["db_version"])
+ print(" Database supported: %s" % result["db_supported"])
+ print(" Schema version: " + result["schema_version"])
+ print(" API version: " + result["api"])
+ print(" Backend: " + result["backend"])
+ print(" Build: " + result["build"])
+
+ if result["msgs"]:
+ print("Error messages:")
+ print("\n".join([" " + r for r in result["msgs"]]))
+
+ return rc
+
+#
+# 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("lorax-composer")
+
+from flask import jsonify
+from functools import update_wrapper
+
+# A decorator for checking the parameters provided to the API route implementing
+# functions. The tuples parameter is a list of tuples. Each tuple is the string
+# name of a parameter ("blueprint_name", not blueprint_name), the value it's set
+# to by flask if the caller did not provide it, and a message to be returned to
+# the user.
+#
+# If the parameter is set to its default, the error message is returned. Otherwise,
+# the decorated function is called and its return value is returned.
+[docs]def checkparams(tuples):
+ def decorator(f):
+ def wrapped_function(*args, **kwargs):
+ for tup in tuples:
+ if kwargs[tup[0]] == tup[1]:
+ log.error("(%s) %s", f.__name__, tup[2])
+ return jsonify(status=False, errors=[tup[2]]), 400
+
+ return f(*args, **kwargs)
+
+ return update_wrapper(wrapped_function, f)
+
+ return decorator
+
+#
+# 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 pytoml as toml
+import time
+
+from pylorax.sysutils import joinpaths
+
+TS_CREATED = "created"
+TS_STARTED = "started"
+TS_FINISHED = "finished"
+
+[docs]def write_timestamp(destdir, ty):
+ path = joinpaths(destdir, "times.toml")
+
+ try:
+ contents = toml.loads(open(path, "r").read())
+ except IOError:
+ contents = toml.loads("")
+
+ if ty == TS_CREATED:
+ contents[TS_CREATED] = time.time()
+ elif ty == TS_STARTED:
+ contents[TS_STARTED] = time.time()
+ elif ty == TS_FINISHED:
+ contents[TS_FINISHED] = time.time()
+
+ with open(path, "w") as f:
+ f.write(toml.dumps(contents).encode("UTF-8"))
+
+[docs]def timestamp_dict(destdir):
+ path = joinpaths(destdir, "times.toml")
+
+ try:
+ return toml.loads(open(path, "r").read())
+ except IOError:
+ return toml.loads("")
+