From fc71fb891e55b2a870444650ed718c897c096edc Mon Sep 17 00:00:00 2001 From: Chris Dent Date: Fri, 8 Dec 2017 14:40:59 +0000 Subject: [PATCH] [placement] annotate loadapp as public interface When Change-Id: I61d20c5d19797f7e66648c7864a632f3328be8ce was under review there were questions about why the interface on deploy() was not changed to remove the no-longer used project_name kwarg. I mistakenly asserted that this was because it was a public interface for building a Placement WSGI application. That's not the case. loadapp() is the public interface. This change annotates loadapp() as such, and removes the unused arg deploy(). Change-Id: I9f3d03d964654ab1b9515ecd6fe35c518d5f496a Related-Bug: #1734491 --- nova/api/openstack/placement/deploy.py | 18 ++++++++++++++++-- .../api/openstack/placement/test_deploy.py | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/nova/api/openstack/placement/deploy.py b/nova/api/openstack/placement/deploy.py index fe440cf1f5fb..053e43dd6911 100644 --- a/nova/api/openstack/placement/deploy.py +++ b/nova/api/openstack/placement/deploy.py @@ -32,7 +32,7 @@ NAME = "nova" objects.register_all() -def deploy(conf, project_name): +def deploy(conf): """Assemble the middleware pipeline leading to the placement app.""" if conf.api.auth_strategy == 'noauth2': auth_middleware = auth.NoAuthMiddleware @@ -83,6 +83,20 @@ def deploy(conf, project_name): return application +# NOTE(cdent): Althought project_name is no longer used because of the +# resolution of https://bugs.launchpad.net/nova/+bug/1734491, loadapp() +# is considered a public interface for the creation of a placement +# WSGI app so must maintain its interface. The canonical placement WSGI +# app is created by init_application in wsgi.py, but this is not +# required and in fact can be limiting. loadapp() may be used from +# fixtures or arbitrary WSGI frameworks and loaders. def loadapp(config, project_name=NAME): - application = deploy(config, project_name) + """WSGI application creator for placement. + + :param config: An olso_config.cfg.ConfigOpts containing placement + configuration. + :param project_name: oslo_config project name. Ignored, preserved for + backwards compatibility + """ + application = deploy(config) return application diff --git a/nova/tests/unit/api/openstack/placement/test_deploy.py b/nova/tests/unit/api/openstack/placement/test_deploy.py index 7413d07fcd7e..403df8a7a5df 100644 --- a/nova/tests/unit/api/openstack/placement/test_deploy.py +++ b/nova/tests/unit/api/openstack/placement/test_deploy.py @@ -34,7 +34,7 @@ class DeployTest(test.NoDBTestCase): self.flags(auth_uri=auth_uri, group='keystone_authtoken') # ensure that the auth_token middleware is chosen self.flags(auth_strategy='keystone', group='api') - app = deploy.deploy(CONF, 'nova') + app = deploy.deploy(CONF) req = webob.Request.blank('/resource_providers', method="GET") response = req.get_response(app)