Add error IDs for common source-related errors.
This commit is contained in:
parent
2adcfc9563
commit
e43adfc7af
@ -29,6 +29,9 @@ BUILD_IN_WRONG_STATE = "BuildInWrongState"
|
|||||||
# given that contains invalid characters.
|
# given that contains invalid characters.
|
||||||
INVALID_NAME = "InvalidName"
|
INVALID_NAME = "InvalidName"
|
||||||
|
|
||||||
|
# Returned from the API when someone tries to modify an immutable system source.
|
||||||
|
SYSTEM_SOURCE = "SystemSource"
|
||||||
|
|
||||||
# Returned from the API when a blueprint that was requested does not exist.
|
# Returned from the API when a blueprint that was requested does not exist.
|
||||||
UNKNOWN_BLUEPRINT = "UnknownBlueprint"
|
UNKNOWN_BLUEPRINT = "UnknownBlueprint"
|
||||||
|
|
||||||
@ -41,5 +44,8 @@ UNKNOWN_MODULE = "UnknownModule"
|
|||||||
# Returned from the API when a project that was requested does not exist.
|
# Returned from the API when a project that was requested does not exist.
|
||||||
UNKNOWN_PROJECT = "UnknownProject"
|
UNKNOWN_PROJECT = "UnknownProject"
|
||||||
|
|
||||||
|
# Returned from the API when a source that was requested does not exist.
|
||||||
|
UNKNOWN_SOURCE = "UnknownSource"
|
||||||
|
|
||||||
# Returned from the API when a UUID that was requested does not exist.
|
# Returned from the API when a UUID that was requested does not exist.
|
||||||
UNKNOWN_UUID = "UnknownUUID"
|
UNKNOWN_UUID = "UnknownUUID"
|
||||||
|
@ -1572,7 +1572,7 @@ def v0_api(api):
|
|||||||
with api.config["YUMLOCK"].lock:
|
with api.config["YUMLOCK"].lock:
|
||||||
repo = api.config["YUMLOCK"].yb.repos.repos.get(source, None)
|
repo = api.config["YUMLOCK"].yb.repos.repos.get(source, None)
|
||||||
if not repo:
|
if not repo:
|
||||||
errors.append("%s is not a valid source" % source)
|
errors.append({"id": UNKNOWN_SOURCE, "msg": "%s is not a valid source" % source})
|
||||||
continue
|
continue
|
||||||
sources[repo.id] = repo_to_source(repo, repo.id in system_sources)
|
sources[repo.id] = repo_to_source(repo, repo.id in system_sources)
|
||||||
|
|
||||||
@ -1596,7 +1596,7 @@ def v0_api(api):
|
|||||||
|
|
||||||
system_sources = get_repo_sources("/etc/yum.repos.d/*.repo")
|
system_sources = get_repo_sources("/etc/yum.repos.d/*.repo")
|
||||||
if source["name"] in system_sources:
|
if source["name"] in system_sources:
|
||||||
return jsonify(status=False, errors=["%s is a system source, it cannot be changed." % source["name"]]), 400
|
return jsonify(status=False, errors=[{"id": SYSTEM_SOURCE, "msg": "%s is a system source, it cannot be changed." % source["name"]}]), 400
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Delete it from yum (if it exists) and replace it with the new one
|
# Delete it from yum (if it exists) and replace it with the new one
|
||||||
@ -1659,7 +1659,7 @@ def v0_api(api):
|
|||||||
|
|
||||||
system_sources = get_repo_sources("/etc/yum.repos.d/*.repo")
|
system_sources = get_repo_sources("/etc/yum.repos.d/*.repo")
|
||||||
if source_name in system_sources:
|
if source_name in system_sources:
|
||||||
return jsonify(status=False, errors=["%s is a system source, it cannot be deleted." % source_name]), 400
|
return jsonify(status=False, errors=[{"id": SYSTEM_SOURCE, "msg": "%s is a system source, it cannot be deleted." % source_name}]), 400
|
||||||
share_dir = api.config["COMPOSER_CFG"].get("composer", "repo_dir")
|
share_dir = api.config["COMPOSER_CFG"].get("composer", "repo_dir")
|
||||||
try:
|
try:
|
||||||
# Remove the file entry for the source
|
# Remove the file entry for the source
|
||||||
@ -1679,7 +1679,7 @@ def v0_api(api):
|
|||||||
|
|
||||||
except ProjectsError as e:
|
except ProjectsError as e:
|
||||||
log.error("(v0_projects_source_delete) %s", str(e))
|
log.error("(v0_projects_source_delete) %s", str(e))
|
||||||
return jsonify(status=False, errors=[str(e)]), 400
|
return jsonify(status=False, errors=[{"id": UNKNOWN_SOURCE, "msg": str(e)}]), 400
|
||||||
|
|
||||||
return jsonify(status=True)
|
return jsonify(status=True)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user