From 233fe1865feab34d7d75332267613e640d8f552f Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Mon, 25 Mar 2024 19:07:55 +0000 Subject: [PATCH] api: Keep track of action controllers We need to be able to resolve the original, unversioned methods. 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: Iee37500e6b2dbacf0c1514bfc52ef2dfe8ceb94f Signed-off-by: Stephen Finucane --- nova/api/openstack/compute/routes.py | 2 +- nova/api/openstack/wsgi.py | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/nova/api/openstack/compute/routes.py b/nova/api/openstack/compute/routes.py index 5b1eeefe8b..91f068daef 100644 --- a/nova/api/openstack/compute/routes.py +++ b/nova/api/openstack/compute/routes.py @@ -94,7 +94,7 @@ def _create_controller(main_controller, action_controller_list): controller = wsgi.Resource(main_controller()) for ctl in action_controller_list: - controller.register_actions(ctl()) + controller.register_subcontroller_actions(ctl()) return controller diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py index 271ce5d313..1ef8e962b2 100644 --- a/nova/api/openstack/wsgi.py +++ b/nova/api/openstack/wsgi.py @@ -396,8 +396,8 @@ class Resource(wsgi.Application): """:param controller: object that implement methods created by routes lib """ - self.controller = controller + self.sub_controllers = [] self.default_serializers = dict(json=JSONDictSerializer) @@ -413,6 +413,13 @@ class Resource(wsgi.Application): for key, method_name in actions.items(): self.wsgi_actions[key] = getattr(controller, method_name) + def register_subcontroller_actions(self, sub_controller): + """Registers sub-controller actions with this resource.""" + self.sub_controllers.append(sub_controller) + actions = getattr(sub_controller, 'wsgi_actions', {}) + for key, method_name in actions.items(): + self.wsgi_actions[key] = getattr(sub_controller, method_name) + def get_action_args(self, request_environment): """Parse dictionary created by routes library."""