From 5057fef24811207bd5bc31c4146f32b823d79484 Mon Sep 17 00:00:00 2001 From: David Shea Date: Thu, 9 Aug 2018 10:25:01 -0400 Subject: [PATCH] Allow '*' as a uuid in /compose/status/ This will display all UUIDs that match the filter arguments (cherry picked from commit deff4d325f65d8b470ff2c11344ec54aa22f95b8) --- src/pylorax/api/v0.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/pylorax/api/v0.py b/src/pylorax/api/v0.py index e233dfdb..f075ce1e 100644 --- a/src/pylorax/api/v0.py +++ b/src/pylorax/api/v0.py @@ -804,7 +804,8 @@ POST `/api/v0/compose` `/api/v0/compose/status/[?blueprint=&status=&type=]` ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - Return the details for each of the comma-separated list of uuids. + Return the details for each of the comma-separated list of uuids. A uuid of '*' will return + details for all composes. Example:: @@ -1828,13 +1829,22 @@ def v0_api(api): results = [] errors = [] - for uuid in [n.strip().lower() for n in uuids.split(",")]: - details = uuid_status(api.config["COMPOSER_CFG"], uuid) - if details is None: - errors.append({"id": UNKNOWN_UUID, "msg": "%s is not a valid build uuid" % uuid}) - continue + if uuids.strip() == '*': + queue_status_dict = queue_status(api.config["COMPOSER_CFG"]) + queue_new = queue_status_dict["new"] + queue_running = queue_status_dict["run"] + candidates = queue_new + queue_running + build_status(api.config["COMPOSER_CFG"]) + else: + candidates = [] + for uuid in [n.strip().lower() for n in uuids.split(",")]: + details = uuid_status(api.config["COMPOSER_CFG"], uuid) + if details is None: + errors.append({"id": UNKNOWN_UUID, "msg": "%s is not a valid build uuid" % uuid}) + else: + candidates.append(details) + for details in candidates: if blueprint is not None and details['blueprint'] != blueprint: continue