config options: Move wsgi options into a group
Move all wsgi configuration into [wsgi] group. Update references to these configuration options to reflect new group. Change-Id: I1a0a0ce1b0c1bdf60114caf6f5d4e28fd2c3cda5
This commit is contained in:
parent
8f678cbe70
commit
0b9e378cca
@ -15,9 +15,14 @@
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
wsgi_group = cfg.OptGroup(
|
||||
'wsgi',
|
||||
title='WSGI Options')
|
||||
|
||||
api_paste_config_opt = cfg.StrOpt('api_paste_config',
|
||||
default="api-paste.ini",
|
||||
help='File name for the paste.deploy config for nova-api')
|
||||
help='File name for the paste.deploy config for nova-api',
|
||||
deprecated_group='DEFAULT')
|
||||
|
||||
wsgi_log_format_opt = cfg.StrOpt('wsgi_log_format',
|
||||
default='%(client_ip)s "%(request_line)s" status: %(status_code)s'
|
||||
@ -25,50 +30,60 @@ wsgi_log_format_opt = cfg.StrOpt('wsgi_log_format',
|
||||
help='A python format string that is used as the template to '
|
||||
'generate log lines. The following values can be formatted '
|
||||
'into it: client_ip, date_time, request_line, status_code, '
|
||||
'body_length, wall_seconds.')
|
||||
'body_length, wall_seconds.',
|
||||
deprecated_group='DEFAULT')
|
||||
|
||||
secure_proxy_ssl_header_opt = cfg.StrOpt('secure_proxy_ssl_header',
|
||||
help='The HTTP header used to determine the scheme for the '
|
||||
'original request, even if it was removed by an SSL '
|
||||
'terminating proxy. Typical value is '
|
||||
'"HTTP_X_FORWARDED_PROTO".')
|
||||
'"HTTP_X_FORWARDED_PROTO".',
|
||||
deprecated_group='DEFAULT')
|
||||
|
||||
ssl_ca_file_opt = cfg.StrOpt('ssl_ca_file',
|
||||
help="CA certificate file to use to verify "
|
||||
"connecting clients")
|
||||
"connecting clients",
|
||||
deprecated_group='DEFAULT')
|
||||
|
||||
ssl_cert_file_opt = cfg.StrOpt('ssl_cert_file',
|
||||
help="SSL certificate of API server")
|
||||
help="SSL certificate of API server",
|
||||
deprecated_group='DEFAULT')
|
||||
|
||||
ssl_key_file_opt = cfg.StrOpt('ssl_key_file',
|
||||
help="SSL private key of API server")
|
||||
help="SSL private key of API server",
|
||||
deprecated_group='DEFAULT')
|
||||
|
||||
tcp_keepidle_opt = cfg.IntOpt('tcp_keepidle',
|
||||
default=600,
|
||||
help="Sets the value of TCP_KEEPIDLE in seconds for each "
|
||||
"server socket. Not supported on OS X.")
|
||||
"server socket. Not supported on OS X.",
|
||||
deprecated_group='DEFAULT')
|
||||
|
||||
wsgi_default_pool_size_opt = cfg.IntOpt('wsgi_default_pool_size',
|
||||
default=1000,
|
||||
help="Size of the pool of greenthreads used by wsgi")
|
||||
help="Size of the pool of greenthreads used by wsgi",
|
||||
deprecated_group='DEFAULT')
|
||||
|
||||
max_header_line_opt = cfg.IntOpt('max_header_line',
|
||||
default=16384,
|
||||
help="Maximum line size of message headers to be accepted. "
|
||||
"max_header_line may need to be increased when using "
|
||||
"large tokens (typically those generated by the "
|
||||
"Keystone v3 API with big service catalogs).")
|
||||
"Keystone v3 API with big service catalogs).",
|
||||
deprecated_group='DEFAULT')
|
||||
|
||||
wsgi_keep_alive_opt = cfg.BoolOpt('wsgi_keep_alive',
|
||||
default=True,
|
||||
help="If False, closes the client socket connection "
|
||||
"explicitly.")
|
||||
"explicitly.",
|
||||
deprecated_group='DEFAULT')
|
||||
|
||||
client_socket_timeout_opt = cfg.IntOpt('client_socket_timeout', default=900,
|
||||
help="Timeout for client connections' socket operations. "
|
||||
"If an incoming connection is idle for this number of "
|
||||
"seconds it will be closed. A value of '0' means "
|
||||
"wait forever.")
|
||||
"wait forever.",
|
||||
deprecated_group='DEFAULT')
|
||||
|
||||
ALL_OPTS = [api_paste_config_opt,
|
||||
wsgi_log_format_opt,
|
||||
@ -85,8 +100,9 @@ ALL_OPTS = [api_paste_config_opt,
|
||||
|
||||
|
||||
def register_opts(conf):
|
||||
conf.register_opts(ALL_OPTS)
|
||||
conf.register_group(wsgi_group)
|
||||
conf.register_opts(ALL_OPTS, group=wsgi_group)
|
||||
|
||||
|
||||
def list_opts():
|
||||
return {"DEFAULT": ALL_OPTS}
|
||||
return {wsgi_group: ALL_OPTS}
|
||||
|
@ -34,15 +34,17 @@ class ApiPasteV21Fixture(fixtures.Fixture):
|
||||
def setUp(self):
|
||||
super(ApiPasteV21Fixture, self).setUp()
|
||||
CONF.set_default('api_paste_config',
|
||||
paths.state_path_def('etc/nova/api-paste.ini'))
|
||||
paths.state_path_def('etc/nova/api-paste.ini'),
|
||||
group='wsgi')
|
||||
tmp_api_paste_dir = self.useFixture(fixtures.TempDir())
|
||||
tmp_api_paste_file_name = os.path.join(tmp_api_paste_dir.path,
|
||||
'fake_api_paste.ini')
|
||||
with open(CONF.api_paste_config, 'r') as orig_api_paste:
|
||||
with open(CONF.wsgi.api_paste_config, 'r') as orig_api_paste:
|
||||
with open(tmp_api_paste_file_name, 'w') as tmp_file:
|
||||
for line in orig_api_paste:
|
||||
self._replace_line(tmp_file, line)
|
||||
CONF.set_override('api_paste_config', tmp_api_paste_file_name)
|
||||
CONF.set_override('api_paste_config', tmp_api_paste_file_name,
|
||||
group='wsgi')
|
||||
|
||||
|
||||
class ApiPasteLegacyV2Fixture(ApiPasteV21Fixture):
|
||||
|
@ -512,7 +512,8 @@ class VersionsTestV21(test.NoDBTestCase):
|
||||
class VersionBehindSslTestCase(test.NoDBTestCase):
|
||||
def setUp(self):
|
||||
super(VersionBehindSslTestCase, self).setUp()
|
||||
self.flags(secure_proxy_ssl_header='HTTP_X_FORWARDED_PROTO')
|
||||
self.flags(secure_proxy_ssl_header='HTTP_X_FORWARDED_PROTO',
|
||||
group='wsgi')
|
||||
|
||||
@property
|
||||
def wsgi_app(self):
|
||||
|
@ -38,7 +38,8 @@ class ConfFixture(config_fixture.Config):
|
||||
def setUp(self):
|
||||
super(ConfFixture, self).setUp()
|
||||
self.conf.set_default('api_paste_config',
|
||||
paths.state_path_def('etc/nova/api-paste.ini'))
|
||||
paths.state_path_def('etc/nova/api-paste.ini'),
|
||||
group='wsgi')
|
||||
self.conf.set_default('host', 'fake-mini')
|
||||
self.conf.set_default('compute_driver',
|
||||
'nova.virt.fake.SmallFakeDriver')
|
||||
|
@ -63,10 +63,10 @@ class TestConfFixture(testtools.TestCase):
|
||||
|
||||
"""
|
||||
def _test_override(self):
|
||||
self.assertEqual('api-paste.ini', CONF.api_paste_config)
|
||||
self.assertEqual('api-paste.ini', CONF.wsgi.api_paste_config)
|
||||
self.assertFalse(CONF.fake_network)
|
||||
self.useFixture(conf_fixture.ConfFixture())
|
||||
CONF.set_default('api_paste_config', 'foo')
|
||||
CONF.set_default('api_paste_config', 'foo', group='wsgi')
|
||||
self.assertTrue(CONF.fake_network)
|
||||
|
||||
def test_override1(self):
|
||||
|
@ -359,7 +359,7 @@ class TestWSGIService(test.NoDBTestCase):
|
||||
test_service.reset()
|
||||
test_service.start()
|
||||
self.assertEqual(test_service.server._pool.size,
|
||||
CONF.wsgi_default_pool_size)
|
||||
CONF.wsgi.wsgi_default_pool_size)
|
||||
|
||||
|
||||
class TestLauncher(test.NoDBTestCase):
|
||||
|
@ -47,14 +47,14 @@ class TestLoaderNothingExists(test.NoDBTestCase):
|
||||
self.stub_out('os.path.exists', lambda _: False)
|
||||
|
||||
def test_relpath_config_not_found(self):
|
||||
self.flags(api_paste_config='api-paste.ini')
|
||||
self.flags(api_paste_config='api-paste.ini', group='wsgi')
|
||||
self.assertRaises(
|
||||
nova.exception.ConfigNotFound,
|
||||
nova.wsgi.Loader,
|
||||
)
|
||||
|
||||
def test_asbpath_config_not_found(self):
|
||||
self.flags(api_paste_config='/etc/nova/api-paste.ini')
|
||||
self.flags(api_paste_config='/etc/nova/api-paste.ini', group='wsgi')
|
||||
self.assertRaises(
|
||||
nova.exception.ConfigNotFound,
|
||||
nova.wsgi.Loader,
|
||||
@ -105,9 +105,10 @@ class TestWSGIServer(test.NoDBTestCase):
|
||||
self.assertEqual("test_app", server.name)
|
||||
|
||||
def test_custom_max_header_line(self):
|
||||
self.flags(max_header_line=4096) # Default value is 16384.
|
||||
self.flags(max_header_line=4096, group='wsgi') # Default is 16384
|
||||
nova.wsgi.Server("test_custom_max_header_line", None)
|
||||
self.assertEqual(CONF.max_header_line, eventlet.wsgi.MAX_HEADER_LINE)
|
||||
self.assertEqual(CONF.wsgi.max_header_line,
|
||||
eventlet.wsgi.MAX_HEADER_LINE)
|
||||
|
||||
def test_start_random_port(self):
|
||||
server = nova.wsgi.Server("test_random_port", None,
|
||||
@ -132,7 +133,7 @@ class TestWSGIServer(test.NoDBTestCase):
|
||||
'1436895 and 1467145')
|
||||
def test_socket_options_for_simple_server(self):
|
||||
# test normal socket options has set properly
|
||||
self.flags(tcp_keepidle=500)
|
||||
self.flags(tcp_keepidle=500, group='wsgi')
|
||||
server = nova.wsgi.Server("test_socket_options", None,
|
||||
host="127.0.0.1", port=0)
|
||||
server.start()
|
||||
@ -142,7 +143,7 @@ class TestWSGIServer(test.NoDBTestCase):
|
||||
self.assertEqual(1, sock.getsockopt(socket.SOL_SOCKET,
|
||||
socket.SO_KEEPALIVE))
|
||||
if hasattr(socket, 'TCP_KEEPIDLE'):
|
||||
self.assertEqual(CONF.tcp_keepidle,
|
||||
self.assertEqual(CONF.wsgi.tcp_keepidle,
|
||||
sock.getsockopt(socket.IPPROTO_TCP,
|
||||
socket.TCP_KEEPIDLE))
|
||||
server.stop()
|
||||
@ -190,10 +191,10 @@ class TestWSGIServer(test.NoDBTestCase):
|
||||
# Resetting pool size to default
|
||||
server.reset()
|
||||
server.start()
|
||||
self.assertEqual(server._pool.size, CONF.wsgi_default_pool_size)
|
||||
self.assertEqual(server._pool.size, CONF.wsgi.wsgi_default_pool_size)
|
||||
|
||||
def test_client_socket_timeout(self):
|
||||
self.flags(client_socket_timeout=5)
|
||||
self.flags(client_socket_timeout=5, group='wsgi')
|
||||
|
||||
# mocking eventlet spawn method to check it is called with
|
||||
# configured 'client_socket_timeout' value.
|
||||
@ -203,12 +204,12 @@ class TestWSGIServer(test.NoDBTestCase):
|
||||
host="127.0.0.1", port=0)
|
||||
server.start()
|
||||
_, kwargs = mock_spawn.call_args
|
||||
self.assertEqual(CONF.client_socket_timeout,
|
||||
self.assertEqual(CONF.wsgi.client_socket_timeout,
|
||||
kwargs['socket_timeout'])
|
||||
server.stop()
|
||||
|
||||
def test_wsgi_keep_alive(self):
|
||||
self.flags(wsgi_keep_alive=False)
|
||||
self.flags(wsgi_keep_alive=False, group='wsgi')
|
||||
|
||||
# mocking eventlet spawn method to check it is called with
|
||||
# configured 'wsgi_keep_alive' value.
|
||||
@ -218,7 +219,7 @@ class TestWSGIServer(test.NoDBTestCase):
|
||||
host="127.0.0.1", port=0)
|
||||
server.start()
|
||||
_, kwargs = mock_spawn.call_args
|
||||
self.assertEqual(CONF.wsgi_keep_alive,
|
||||
self.assertEqual(CONF.wsgi.wsgi_keep_alive,
|
||||
kwargs['keepalive'])
|
||||
server.stop()
|
||||
|
||||
@ -228,9 +229,11 @@ class TestWSGIServerWithSSL(test.NoDBTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestWSGIServerWithSSL, self).setUp()
|
||||
self.flags(enabled_ssl_apis=['fake_ssl'],
|
||||
self.flags(enabled_ssl_apis=['fake_ssl'])
|
||||
self.flags(
|
||||
ssl_cert_file=os.path.join(SSL_CERT_DIR, 'certificate.crt'),
|
||||
ssl_key_file=os.path.join(SSL_CERT_DIR, 'privatekey.key'))
|
||||
ssl_key_file=os.path.join(SSL_CERT_DIR, 'privatekey.key'),
|
||||
group='wsgi')
|
||||
|
||||
def test_ssl_server(self):
|
||||
|
||||
@ -287,7 +290,7 @@ class TestWSGIServerWithSSL(test.NoDBTestCase):
|
||||
'1436895 and 1467145')
|
||||
def test_socket_options_for_ssl_server(self):
|
||||
# test normal socket options has set properly
|
||||
self.flags(tcp_keepidle=500)
|
||||
self.flags(tcp_keepidle=500, group='wsgi')
|
||||
server = nova.wsgi.Server("test_socket_options", None,
|
||||
host="127.0.0.1", port=0,
|
||||
use_ssl=True)
|
||||
@ -298,7 +301,7 @@ class TestWSGIServerWithSSL(test.NoDBTestCase):
|
||||
self.assertEqual(1, sock.getsockopt(socket.SOL_SOCKET,
|
||||
socket.SO_KEEPALIVE))
|
||||
if hasattr(socket, 'TCP_KEEPIDLE'):
|
||||
self.assertEqual(CONF.tcp_keepidle,
|
||||
self.assertEqual(CONF.wsgi.tcp_keepidle,
|
||||
sock.getsockopt(socket.IPPROTO_TCP,
|
||||
socket.TCP_KEEPIDLE))
|
||||
server.stop()
|
||||
|
26
nova/wsgi.py
26
nova/wsgi.py
@ -49,7 +49,7 @@ LOG = logging.getLogger(__name__)
|
||||
class Server(service.ServiceBase):
|
||||
"""Server class to manage a WSGI server, serving a WSGI application."""
|
||||
|
||||
default_pool_size = CONF.wsgi_default_pool_size
|
||||
default_pool_size = CONF.wsgi.wsgi_default_pool_size
|
||||
|
||||
def __init__(self, name, app, host='0.0.0.0', port=0, pool_size=None,
|
||||
protocol=eventlet.wsgi.HttpProtocol, backlog=128,
|
||||
@ -67,7 +67,7 @@ class Server(service.ServiceBase):
|
||||
:raises: nova.exception.InvalidInput
|
||||
"""
|
||||
# Allow operators to customize http requests max header line size.
|
||||
eventlet.wsgi.MAX_HEADER_LINE = CONF.max_header_line
|
||||
eventlet.wsgi.MAX_HEADER_LINE = CONF.wsgi.max_header_line
|
||||
self.name = name
|
||||
self.app = app
|
||||
self._server = None
|
||||
@ -77,7 +77,7 @@ class Server(service.ServiceBase):
|
||||
self._logger = logging.getLogger("nova.%s.wsgi.server" % self.name)
|
||||
self._use_ssl = use_ssl
|
||||
self._max_url_len = max_url_len
|
||||
self.client_socket_timeout = CONF.client_socket_timeout or None
|
||||
self.client_socket_timeout = CONF.wsgi.client_socket_timeout or None
|
||||
|
||||
if backlog < 1:
|
||||
raise exception.InvalidInput(
|
||||
@ -129,13 +129,13 @@ class Server(service.ServiceBase):
|
||||
if hasattr(socket, 'TCP_KEEPIDLE'):
|
||||
dup_socket.setsockopt(socket.IPPROTO_TCP,
|
||||
socket.TCP_KEEPIDLE,
|
||||
CONF.tcp_keepidle)
|
||||
CONF.wsgi.tcp_keepidle)
|
||||
|
||||
if self._use_ssl:
|
||||
try:
|
||||
ca_file = CONF.ssl_ca_file
|
||||
cert_file = CONF.ssl_cert_file
|
||||
key_file = CONF.ssl_key_file
|
||||
ca_file = CONF.wsgi.ssl_ca_file
|
||||
cert_file = CONF.wsgi.ssl_cert_file
|
||||
key_file = CONF.wsgi.ssl_key_file
|
||||
|
||||
if cert_file and not os.path.exists(cert_file):
|
||||
raise RuntimeError(
|
||||
@ -161,7 +161,7 @@ class Server(service.ServiceBase):
|
||||
'cert_reqs': ssl.CERT_NONE,
|
||||
}
|
||||
|
||||
if CONF.ssl_ca_file:
|
||||
if CONF.wsgi.ssl_ca_file:
|
||||
ssl_kwargs['ca_certs'] = ca_file
|
||||
ssl_kwargs['cert_reqs'] = ssl.CERT_REQUIRED
|
||||
|
||||
@ -181,9 +181,9 @@ class Server(service.ServiceBase):
|
||||
'protocol': self._protocol,
|
||||
'custom_pool': self._pool,
|
||||
'log': self._logger,
|
||||
'log_format': CONF.wsgi_log_format,
|
||||
'log_format': CONF.wsgi.wsgi_log_format,
|
||||
'debug': False,
|
||||
'keepalive': CONF.wsgi_keep_alive,
|
||||
'keepalive': CONF.wsgi.wsgi_keep_alive,
|
||||
'socket_timeout': self.client_socket_timeout
|
||||
}
|
||||
|
||||
@ -234,8 +234,8 @@ class Server(service.ServiceBase):
|
||||
|
||||
class Request(webob.Request):
|
||||
def __init__(self, environ, *args, **kwargs):
|
||||
if CONF.secure_proxy_ssl_header:
|
||||
scheme = environ.get(CONF.secure_proxy_ssl_header)
|
||||
if CONF.wsgi.secure_proxy_ssl_header:
|
||||
scheme = environ.get(CONF.wsgi.secure_proxy_ssl_header)
|
||||
if scheme:
|
||||
environ['wsgi.url_scheme'] = scheme
|
||||
super(Request, self).__init__(environ, *args, **kwargs)
|
||||
@ -474,7 +474,7 @@ class Loader(object):
|
||||
"""
|
||||
self.config_path = None
|
||||
|
||||
config_path = config_path or CONF.api_paste_config
|
||||
config_path = config_path or CONF.wsgi.api_paste_config
|
||||
if not os.path.isabs(config_path):
|
||||
self.config_path = CONF.find_file(config_path)
|
||||
elif os.path.exists(config_path):
|
||||
|
@ -0,0 +1,4 @@
|
||||
---
|
||||
upgrade:
|
||||
- All WSGI configuration options have been added to the 'wsgi' group.
|
||||
They should no longer be included in the 'DEFAULT' group.
|
Loading…
Reference in New Issue
Block a user