From c8236141f86fc609ee9901a42bbcffe60bd66e40 Mon Sep 17 00:00:00 2001 From: Okeke Christian Date: Thu, 7 Mar 2024 14:03:13 +0100 Subject: [PATCH] Fix the link to get the next share replica The url to get the next share replica is broken when performing pagination. The new API uses underscore to represent resource. This fix resolves the broken link for share replicas by using alias. Closes-bug: #2023754 Change-Id: I31e32c0bcfb60b53121da9a96df3b44ad2b3ac67 --- manila/api/common.py | 21 ++++++++++++++++--- manila/api/views/share_replicas.py | 1 + ...ix-share-replica-url-367797a27a9c314d.yaml | 6 ++++++ 3 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/bug-2023754-fix-share-replica-url-367797a27a9c314d.yaml diff --git a/manila/api/common.py b/manila/api/common.py index 2b58e00ee8..5d66a9ad26 100644 --- a/manila/api/common.py +++ b/manila/api/common.py @@ -302,6 +302,7 @@ class ViewBuilder(object): """Model API responses as dictionaries.""" _collection_name = None + _collection_route_name = None _detail_version_modifiers = [] def _get_project_id(self, request): @@ -325,20 +326,30 @@ class ViewBuilder(object): """Return href string with proper limit and marker params.""" params = request.params.copy() params["marker"] = identifier + url = "" + collection_route_name = ( + self._collection_route_name + or self._collection_name + ) prefix = self._update_link_prefix(request.application_url, CONF.osapi_share_base_URL) url = os.path.join(prefix, self._get_project_id(request), - self._collection_name) + collection_route_name) + return "%s?%s" % (url, dict_to_query_str(params)) def _get_href_link(self, request, identifier): """Return an href string pointing to this object.""" + collection_route_name = ( + self._collection_route_name + or self._collection_name + ) prefix = self._update_link_prefix(request.application_url, CONF.osapi_share_base_URL) return os.path.join(prefix, self._get_project_id(request), - self._collection_name, + collection_route_name, str(identifier)) def _get_bookmark_link(self, request, identifier): @@ -346,9 +357,13 @@ class ViewBuilder(object): base_url = remove_version_from_href(request.application_url) base_url = self._update_link_prefix(base_url, CONF.osapi_share_base_URL) + collection_route_name = ( + self._collection_route_name + or self._collection_name + ) return os.path.join(base_url, self._get_project_id(request), - self._collection_name, + collection_route_name, str(identifier)) def _get_collection_links(self, request, items, id_key="uuid"): diff --git a/manila/api/views/share_replicas.py b/manila/api/views/share_replicas.py index 5bcbeb2c5f..7f9eab7375 100644 --- a/manila/api/views/share_replicas.py +++ b/manila/api/views/share_replicas.py @@ -20,6 +20,7 @@ class ReplicationViewBuilder(common.ViewBuilder): """Model a server API response as a python dictionary.""" _collection_name = 'share_replicas' + _collection_route_name = "share-replicas" _collection_links = 'share_replica_links' _detail_version_modifiers = [ diff --git a/releasenotes/notes/bug-2023754-fix-share-replica-url-367797a27a9c314d.yaml b/releasenotes/notes/bug-2023754-fix-share-replica-url-367797a27a9c314d.yaml new file mode 100644 index 0000000000..3bc8509c44 --- /dev/null +++ b/releasenotes/notes/bug-2023754-fix-share-replica-url-367797a27a9c314d.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Launchpad `bug 2023754 `_ + has been fixed for "next links" broken for limited share replicas api. +