From 66008dd93ce0105089edd537b4b1d82f66b3d688 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Thu, 28 Mar 2024 23:16:00 +0000 Subject: [PATCH] api: Keep track of extension controllers We need to be able to resolve the original, unversioned controllers, so that we can retrieve additional attributes of those controller (namely, the 'versioned_methods' attributes, which contains references to the original versioned methods rather than the 'version_select' magic method). Register these things slightly differently. It would likely be better to fold these action controllers into the main controllers, but that's a lot of code motion that I don't really want to do right now. Change-Id: I174c3bae39625b74e4b416e3559eb79ad8d34948 Signed-off-by: Stephen Finucane --- cinder/api/openstack/wsgi.py | 7 +++++++ cinder/api/v3/router.py | 1 - 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cinder/api/openstack/wsgi.py b/cinder/api/openstack/wsgi.py index 4bdb352625a..671a04bf5c3 100644 --- a/cinder/api/openstack/wsgi.py +++ b/cinder/api/openstack/wsgi.py @@ -640,6 +640,7 @@ class Resource(wsgi.Application): """ self.controller = controller + self.extension_controllers = set() default_deserializers = dict(json=JSONDeserializer) default_deserializers.update(deserializers) @@ -669,6 +670,12 @@ class Resource(wsgi.Application): def register_extensions(self, controller): """Registers controller extensions with this resource.""" + self.extension_controllers.add(controller) + + actions = getattr(controller, 'wsgi_actions', {}) + for key, method_name in actions.items(): + self.wsgi_actions[key] = getattr(controller, method_name) + extensions = getattr(controller, 'wsgi_extensions', []) for method_name, action_name in extensions: # Look up the extending method diff --git a/cinder/api/v3/router.py b/cinder/api/v3/router.py index 0b44a36a3bf..7baa1ab2bd3 100644 --- a/cinder/api/v3/router.py +++ b/cinder/api/v3/router.py @@ -160,7 +160,6 @@ class APIRouter(base_wsgi.Router): ) resource = self.resources[collection] - resource.register_actions(controller) resource.register_extensions(controller) def _setup_routes(self, mapper, ext_mgr):