deb-oslo.middleware/doc/source/oslo_config.rst
Michael Krotscheck 7404a37e70 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
2015-11-13 15:00:48 -08:00

1.7 KiB

Middlewares and configuration

Middlewares can be configured in multiple fashion depending of the application needs. Here is some use-cases:

Configuration from the application

The application code will looks like:

from oslo_middleware import sizelimit
from oslo_config import cfg

conf = cfg.ConfigOpts()
app = sizelimit.RequestBodySizeLimiter(your_wsgi_application, conf)

Configuration with paste-deploy and the oslo.config

The paste filter (in /etc/my_app/api-paste.ini) will looks like:

[filter:sizelimit]
paste.filter_factory = oslo_middleware.sizelimit:RequestBodySizeLimiter.factory
# In case of the application doesn't use the global oslo.config 
# object. The middleware must known the app name to load 
# 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]
max_request_body_size=1000

Configuration with pastedeploy only

The paste filter (in /etc/my_app/api-paste.ini) will looks like:

[filter:sizelimit]
paste.filter_factory = oslo_middleware.sizelimit:RequestBodySizeLimiter.factory
max_request_body_size=1000

This will override any configuration done via oslo.config

Note

healtcheck middleware does not yet use oslo.config, see healthcheck_plugins