From ba7d98ea4680f9994ac5397de8194ce32086dc92 Mon Sep 17 00:00:00 2001 From: Gregory Thiemonge Date: Fri, 20 Sep 2024 07:45:40 +0200 Subject: [PATCH] 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=" in the URL while id is not a valid parameter for AZs. Closes-Bug: #2081189 Change-Id: Ia2a3870fb402435a9b9524ab6aefced70f33405e --- octaviaclient/osc/v2/utils.py | 8 +++++--- .../notes/fix-delete-az-message-9caf48f7c685d80e.yaml | 7 +++++++ 2 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/fix-delete-az-message-9caf48f7c685d80e.yaml diff --git a/octaviaclient/osc/v2/utils.py b/octaviaclient/osc/v2/utils.py index 15ab11c..07588aa 100644 --- a/octaviaclient/osc/v2/utils.py +++ b/octaviaclient/osc/v2/utils.py @@ -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) diff --git a/releasenotes/notes/fix-delete-az-message-9caf48f7c685d80e.yaml b/releasenotes/notes/fix-delete-az-message-9caf48f7c685d80e.yaml new file mode 100644 index 0000000..2cb463d --- /dev/null +++ b/releasenotes/notes/fix-delete-az-message-9caf48f7c685d80e.yaml @@ -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. +