Fix error message when deleting a non-existing AZ

Deleting a non-existing AZ returned an error message from the API
because the request included "?id=<az_name>" in the URL while id is not
a valid parameter for AZs.

Closes-Bug: #2081189
Change-Id: Ia2a3870fb402435a9b9524ab6aefced70f33405e
This commit is contained in:
Gregory Thiemonge 2024-09-20 07:45:40 +02:00
parent e11e3daa18
commit ba7d98ea46
2 changed files with 12 additions and 3 deletions

View File

@ -111,9 +111,11 @@ def _find_resource(list_funct, resource_name, root_tag, name, parent=None):
raise osc_exc.CommandError(msg)
# Try by ID next
resource = list_funct(*parent_args, id=name)[root_tag]
if len(resource) == 1:
return resource[0]
# Availability Zones don't support the id parameter
if resource_name != "availability_zones":
resource = list_funct(*parent_args, id=name)[root_tag]
if len(resource) == 1:
return resource[0]
# We didn't find what we were looking for, raise a consistent error.
msg = "Unable to locate {0} in {1}".format(name, resource_name)

View File

@ -0,0 +1,7 @@
---
fixes:
- |
Fixed the incorrect error message returned when deleting a non-existing
availability zone, it now explicitly mentions that the availability zone
does not exist.