Return a status of false if the uuid isn't valid
This commit is contained in:
parent
072aa720ff
commit
caee8e7cdf
@ -1382,6 +1382,9 @@ def v0_api(api):
|
|||||||
def v0_compose_cancel(uuid):
|
def v0_compose_cancel(uuid):
|
||||||
"""Cancel a running compose and delete its results directory"""
|
"""Cancel a running compose and delete its results directory"""
|
||||||
status = uuid_status(api.config["COMPOSER_CFG"], uuid)
|
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
|
||||||
|
|
||||||
if status["queue_status"] not in ["WAITING", "RUNNING"]:
|
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, "uuid": uuid, "msg": "Cannot cancel a build that is in the %s state" % status["queue_status"]})
|
||||||
|
|
||||||
@ -1400,7 +1403,9 @@ def v0_api(api):
|
|||||||
errors = []
|
errors = []
|
||||||
for uuid in [n.strip().lower() for n in uuids.split(",")]:
|
for uuid in [n.strip().lower() for n in uuids.split(",")]:
|
||||||
status = uuid_status(api.config["COMPOSER_CFG"], uuid)
|
status = uuid_status(api.config["COMPOSER_CFG"], uuid)
|
||||||
if status["queue_status"] not in ["FINISHED", "FAILED"]:
|
if status is None:
|
||||||
|
errors.append({"uuid": uuid, "msg": "Not a valid build uuid"})
|
||||||
|
elif status["queue_status"] not in ["FINISHED", "FAILED"]:
|
||||||
errors.append({"uuid":uuid, "msg":"Build not in FINISHED or FAILED."})
|
errors.append({"uuid":uuid, "msg":"Build not in FINISHED or FAILED."})
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
@ -1427,6 +1432,8 @@ def v0_api(api):
|
|||||||
def v0_compose_metadata(uuid):
|
def v0_compose_metadata(uuid):
|
||||||
"""Return a tar of the metadata for the build"""
|
"""Return a tar of the metadata for the build"""
|
||||||
status = uuid_status(api.config["COMPOSER_CFG"], uuid)
|
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
|
||||||
if status["queue_status"] not in ["FINISHED", "FAILED"]:
|
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, "uuid":uuid, "msg":"Build not in FINISHED or FAILED."})
|
||||||
else:
|
else:
|
||||||
@ -1440,7 +1447,9 @@ def v0_api(api):
|
|||||||
def v0_compose_results(uuid):
|
def v0_compose_results(uuid):
|
||||||
"""Return a tar of the metadata and the results for the build"""
|
"""Return a tar of the metadata and the results for the build"""
|
||||||
status = uuid_status(api.config["COMPOSER_CFG"], uuid)
|
status = uuid_status(api.config["COMPOSER_CFG"], uuid)
|
||||||
if status["queue_status"] not in ["FINISHED", "FAILED"]:
|
if status is None:
|
||||||
|
return jsonify(status=False, msg="%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, "uuid":uuid, "msg":"Build not in FINISHED or FAILED."})
|
||||||
else:
|
else:
|
||||||
return Response(uuid_tar(api.config["COMPOSER_CFG"], uuid, metadata=True, image=True, logs=True),
|
return Response(uuid_tar(api.config["COMPOSER_CFG"], uuid, metadata=True, image=True, logs=True),
|
||||||
@ -1453,7 +1462,9 @@ def v0_api(api):
|
|||||||
def v0_compose_logs(uuid):
|
def v0_compose_logs(uuid):
|
||||||
"""Return a tar of the metadata for the build"""
|
"""Return a tar of the metadata for the build"""
|
||||||
status = uuid_status(api.config["COMPOSER_CFG"], uuid)
|
status = uuid_status(api.config["COMPOSER_CFG"], uuid)
|
||||||
if status["queue_status"] not in ["FINISHED", "FAILED"]:
|
if status is None:
|
||||||
|
return jsonify(status=False, msg="%s is not a valid build 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, "uuid":uuid, "msg":"Build not in FINISHED or FAILED."})
|
||||||
else:
|
else:
|
||||||
return Response(uuid_tar(api.config["COMPOSER_CFG"], uuid, metadata=False, image=False, logs=True),
|
return Response(uuid_tar(api.config["COMPOSER_CFG"], uuid, metadata=False, image=False, logs=True),
|
||||||
@ -1466,7 +1477,9 @@ def v0_api(api):
|
|||||||
def v0_compose_image(uuid):
|
def v0_compose_image(uuid):
|
||||||
"""Return the output image for the build"""
|
"""Return the output image for the build"""
|
||||||
status = uuid_status(api.config["COMPOSER_CFG"], uuid)
|
status = uuid_status(api.config["COMPOSER_CFG"], uuid)
|
||||||
if status["queue_status"] not in ["FINISHED", "FAILED"]:
|
if status is None:
|
||||||
|
return jsonify(status=False, msg="%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, "uuid":uuid, "msg":"Build not in FINISHED or FAILED."})
|
||||||
else:
|
else:
|
||||||
image_name, image_path = uuid_image(api.config["COMPOSER_CFG"], uuid)
|
image_name, image_path = uuid_image(api.config["COMPOSER_CFG"], uuid)
|
||||||
|
Loading…
Reference in New Issue
Block a user