From 7404a37e7052efdc92f235945034ebf397a5641b Mon Sep 17 00:00:00 2001 From: Michael Krotscheck Date: Fri, 13 Nov 2015 15:00:48 -0800 Subject: Add oslo_config program support to paste middleware oslo_config's configfile autodiscovery permits an additional parameter named 'prog', which will add an additional file name to the possible files that are checked in oslo_config directories. This patch adds this parameter to paste-ini initialization, permitting access to more configuration files. This feature is required by glance, as glance does not make use of ./glance/glance.conf. Instead, they use ./glance/glance-api.conf. The appropriate middleware configuration in this case would then be: oslo_config_project=glance oslog_config_program=glance-api Change-Id: Ie530e4fac8076dc46b705770d12940ef91cb4644 --- doc/source/cors.rst | 10 ++++++++++ doc/source/oslo_config.rst | 4 ++++ oslo_middleware/base.py | 10 +++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/doc/source/cors.rst b/doc/source/cors.rst index 890f7fd..11cb043 100644 --- a/doc/source/cors.rst +++ b/doc/source/cors.rst @@ -104,6 +104,16 @@ will add CORS support. To add multiple domains, simply add another filter.:: allow_headers=Content-Type,Cache-Control,Content-Language,Expires,Last-Modified,Pragma,X-Custom-Header expose_headers=Content-Type,Cache-Control,Content-Language,Expires,Last-Modified,Pragma,X-Custom-Header +If your application is using pastedeploy, but would also like to use the +existing configuration from oslo_config in order to simplify the points of +configuration, this may be done as follows.:: + + [filter:cors] + paste.filter_factory = oslo_middleware.cors:filter_factory + oslo_config_project = oslo_project_name + + # Optional field, in case the program name is different from the project: + oslo_config_program = oslo_project_name-api Configuration Options --------------------- diff --git a/doc/source/oslo_config.rst b/doc/source/oslo_config.rst index 09c83c6..6e772c6 100644 --- a/doc/source/oslo_config.rst +++ b/doc/source/oslo_config.rst @@ -29,6 +29,10 @@ The paste filter (in /etc/my_app/api-paste.ini) will looks like:: # the application configuration, by setting this: # oslo_config_project = my_app + # In some cases, you may need to specify the program name for the project + # as well. + # oslo_config_program = my_app-api + The oslo.config file of the application (eg: /etc/my_app/my_app.conf) will looks like:: [oslo_middleware] diff --git a/oslo_middleware/base.py b/oslo_middleware/base.py index 86f2249..a98a058 100644 --- a/oslo_middleware/base.py +++ b/oslo_middleware/base.py @@ -67,8 +67,16 @@ class ConfigurableMiddleware(object): default_config_files = [self.conf['oslo_config_file']] else: default_config_files = None + + if 'oslo_config_program' in self.conf: + program = self.conf['oslo_config_program'] + else: + program = None + self.oslo_conf = cfg.ConfigOpts() - self.oslo_conf([], project=self.conf['oslo_config_project'], + self.oslo_conf([], + project=self.conf['oslo_config_project'], + prog=program, default_config_files=default_config_files, validate_default_values=True) -- cgit v1.2.1