Make default-types APIs compatible with V3.67

In microversion 3.67, we made project_id optional in the URL
for all Cinder APIs.
However, the default-types APIs (set, unset, get, list) were
implemented without the project_id in the URL to make it
ready for SRBAC and anticipating the new endpoint for cinder
without project_id.

This is causing issues while implementing the SDK support for
default-types APIs since we fetch the endpoint containing
project_id (http://127.0.0.1/volume/v3/<project_id>/default-types)
but the default-types API doesn't expect it
(http://127.0.0.1/volume/v3/default-types) resulting in 404
resource not found error.

ResourceNotFound: 404: Client Error for url:
http://127.0.0.1/volume/v3/default_types/12a1b5e507e7497db79707b0ddedf1a4,
: 404 Not Found: The resource could not be found.

This patch makes the default-types APIs consistent with the
other cinder APIs that accept URL with/without project_id.

NOTE: This patch doesn't require a microversion bump or releasenote
since the expectation with MV3.67 is that all APIs support
request irrespective of project_id in the URL and this change is
making default-types APIs consisitent with MV3.67.
Also MV3.67 is just an indication of the behavior change otherwise
supplying URLs without project ID with MV < 3.67 also works.

Change-Id: I63efc0598d501d77474588a02582f5338bb8d345
(cherry picked from commit 9afa19e9c9)
This commit is contained in:
Rajat Dhasmana 2024-05-23 22:56:55 +05:30
parent 530376bc5d
commit 2bb2f13de3

View File

@ -210,22 +210,28 @@ class APIRouter(cinder.api.openstack.APIRouter):
member={'accept': 'POST'})
self.resources['default_types'] = default_types.create_resource()
mapper.connect("default-types", "/default-types/{id}",
controller=self.resources['default_types'],
action='create_update',
conditions={"method": ['PUT']})
for path_prefix in ['/{project_id}', '']:
# project_id is optional
mapper.connect(
"default-types", "%s/default-types/{id}" % path_prefix,
controller=self.resources['default_types'],
action='create_update',
conditions={"method": ['PUT']})
mapper.connect("default-types", "/default-types",
controller=self.resources['default_types'],
action='index',
conditions={"method": ['GET']})
mapper.connect(
"default-types", "%s/default-types" % path_prefix,
controller=self.resources['default_types'],
action='index',
conditions={"method": ['GET']})
mapper.connect("default-types", "/default-types/{id}",
controller=self.resources['default_types'],
action='detail',
conditions={"method": ['GET']})
mapper.connect(
"default-types", "%s/default-types/{id}" % path_prefix,
controller=self.resources['default_types'],
action='detail',
conditions={"method": ['GET']})
mapper.connect("default-types", "/default-types/{id}",
controller=self.resources['default_types'],
action='delete',
conditions={"method": ['DELETE']})
mapper.connect(
"default-types", "%s/default-types/{id}" % path_prefix,
controller=self.resources['default_types'],
action='delete',
conditions={"method": ['DELETE']})