api: move API options to their own api group
We already have an 'api' group, let's use it for real. Change-Id: I6ebbcfeddd51d66de436c218819c20e319ccf03e
This commit is contained in:
parent
a9f0eff3b0
commit
adaf14ab3f
@ -54,7 +54,7 @@ def setup_app(pecan_config=PECAN_CONFIG, conf=None):
|
||||
|
||||
# NOTE(sileht): pecan debug won't work in multi-process environment
|
||||
pecan_debug = conf.api.pecan_debug
|
||||
if conf.api_workers != 1 and pecan_debug:
|
||||
if conf.api.workers != 1 and pecan_debug:
|
||||
pecan_debug = False
|
||||
LOG.warning(_LW('pecan_debug cannot be enabled, if workers is > 1, '
|
||||
'the value is overrided with False'))
|
||||
@ -73,14 +73,14 @@ def setup_app(pecan_config=PECAN_CONFIG, conf=None):
|
||||
def load_app(conf):
|
||||
# Build the WSGI app
|
||||
cfg_file = None
|
||||
cfg_path = conf.api_paste_config
|
||||
cfg_path = conf.api.paste_config
|
||||
if not os.path.isabs(cfg_path):
|
||||
cfg_file = conf.find_file(cfg_path)
|
||||
elif os.path.exists(cfg_path):
|
||||
cfg_file = cfg_path
|
||||
|
||||
if not cfg_file:
|
||||
raise cfg.ConfigFilesNotFoundError([conf.api_paste_config])
|
||||
raise cfg.ConfigFilesNotFoundError([conf.api.paste_config])
|
||||
LOG.info("Full WSGI config used: %s" % cfg_file)
|
||||
return deploy.loadapp("config:" + cfg_file)
|
||||
|
||||
@ -103,7 +103,7 @@ def build_server(conf):
|
||||
{'host': host, 'port': port}))
|
||||
|
||||
serving.run_simple(host, port,
|
||||
app, processes=conf.api_workers)
|
||||
app, processes=conf.api.workers)
|
||||
|
||||
|
||||
def _app():
|
||||
|
22
aodh/opts.py
22
aodh/opts.py
@ -30,16 +30,6 @@ def list_opts():
|
||||
return [
|
||||
('DEFAULT',
|
||||
itertools.chain(
|
||||
[
|
||||
cfg.StrOpt(
|
||||
'api_paste_config',
|
||||
default="api_paste.ini",
|
||||
help="Configuration file for WSGI definition of API."),
|
||||
cfg.IntOpt(
|
||||
'api_workers', default=1,
|
||||
min=1,
|
||||
help='Number of workers for aodh API server.'),
|
||||
],
|
||||
aodh.evaluator.OPTS,
|
||||
aodh.evaluator.gnocchi.OPTS,
|
||||
aodh.notifier.rest.OPTS,
|
||||
@ -51,6 +41,18 @@ def list_opts():
|
||||
itertools.chain(
|
||||
aodh.api.OPTS,
|
||||
[
|
||||
cfg.StrOpt(
|
||||
'paste_config',
|
||||
deprecated_name='api_paste_config',
|
||||
deprecated_group='DEFAULT',
|
||||
default="api_paste.ini",
|
||||
help="Configuration file for WSGI definition of API."),
|
||||
cfg.IntOpt(
|
||||
'workers', default=1,
|
||||
deprecated_name='api_workers',
|
||||
deprecated_group='DEFAULT',
|
||||
min=1,
|
||||
help='Number of workers for aodh API server.'),
|
||||
cfg.BoolOpt('pecan_debug',
|
||||
default=False,
|
||||
help='Toggle Pecan Debug Middleware.'),
|
||||
|
@ -32,7 +32,7 @@ class TestApp(base.BaseTestCase):
|
||||
self.CONF = self.useFixture(fixture_config.Config(conf)).conf
|
||||
|
||||
def test_api_paste_file_not_exist(self):
|
||||
self.CONF.set_override('api_paste_config', 'non-existent-file')
|
||||
self.CONF.set_override('paste_config', 'non-existent-file', "api")
|
||||
with mock.patch.object(self.CONF, 'find_file') as ff:
|
||||
ff.return_value = None
|
||||
self.assertRaises(cfg.ConfigFilesNotFoundError,
|
||||
@ -46,7 +46,7 @@ class TestApp(base.BaseTestCase):
|
||||
self.CONF.set_override('debug', g_debug)
|
||||
if p_debug is not None:
|
||||
self.CONF.set_override('pecan_debug', p_debug, group='api')
|
||||
self.CONF.set_override('api_workers', workers)
|
||||
self.CONF.set_override('workers', workers, 'api')
|
||||
app.setup_app(conf=self.CONF)
|
||||
args, kwargs = mocked.call_args
|
||||
self.assertEqual(expected, kwargs.get('debug'))
|
||||
|
@ -92,7 +92,7 @@ class TestAPIACL(v2.FunctionalTest,
|
||||
def _make_app(self):
|
||||
self.CONF.set_override("cache", "fake.cache", 'keystone_authtoken')
|
||||
file_name = self.path_get('etc/aodh/api_paste.ini')
|
||||
self.CONF.set_override("api_paste_config", file_name)
|
||||
self.CONF.set_override("paste_config", file_name, "api")
|
||||
# We need the other call to prepare_service in app.py to return the
|
||||
# same tweaked conf object.
|
||||
with mock.patch('aodh.service.prepare_service') as ps:
|
||||
|
@ -147,8 +147,8 @@ class BinApiTestCase(base.BaseTestCase):
|
||||
"auth_strategy=noauth\n"
|
||||
"debug=true\n"
|
||||
"pipeline_cfg_file={0}\n"
|
||||
"api_paste_config={2}\n"
|
||||
"[api]\n"
|
||||
"paste_config={2}\n"
|
||||
"port={3}\n"
|
||||
"[oslo_policy]\n"
|
||||
"policy_file={1}\n"
|
||||
|
Loading…
Reference in New Issue
Block a user