Merge "Improve api_paste_config file searching"
This commit is contained in:
@@ -129,23 +129,15 @@ def get_handler_cls():
|
|||||||
|
|
||||||
def load_app():
|
def load_app():
|
||||||
# Build the WSGI app
|
# Build the WSGI app
|
||||||
cfg_file = cfg.CONF.api_paste_config
|
cfg_file = None
|
||||||
LOG.info("WSGI config requested: %s" % cfg_file)
|
cfg_path = cfg.CONF.api_paste_config
|
||||||
if not os.path.exists(cfg_file):
|
if not os.path.isabs(cfg_path):
|
||||||
# this code is to work around chicken-egg dependency between
|
cfg_file = CONF.find_file(cfg_path)
|
||||||
# ceilometer gate jobs use of devstack and this change.
|
elif os.path.exists(cfg_path):
|
||||||
# The gate job uses devstack to run tempest.
|
cfg_file = cfg_path
|
||||||
# devstack does not copy api_paste.ini into /etc/ceilometer because it
|
|
||||||
# is introduced in this change. Once this is merged, we will change
|
if not cfg_file:
|
||||||
# devstack to copy api_paste.ini and once that is merged will remove
|
raise cfg.ConfigFilesNotFoundError([cfg.CONF.api_paste_config])
|
||||||
# this code.
|
|
||||||
root = os.path.abspath(os.path.join(os.path.dirname(__file__),
|
|
||||||
'..', '..', 'etc', 'ceilometer'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
cfg_file = os.path.join(root, cfg_file)
|
|
||||||
if not os.path.exists(cfg_file):
|
|
||||||
raise Exception('api_paste_config file not found')
|
|
||||||
LOG.info("Full WSGI config used: %s" % cfg_file)
|
LOG.info("Full WSGI config used: %s" % cfg_file)
|
||||||
return deploy.loadapp("config:" + cfg_file)
|
return deploy.loadapp("config:" + cfg_file)
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
|
import mock
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
from oslo.config import fixture as fixture_config
|
from oslo.config import fixture as fixture_config
|
||||||
|
|
||||||
@@ -42,3 +43,9 @@ class TestApp(base.BaseTestCase):
|
|||||||
self.CONF.set_override('host', 'ddddd', group='api')
|
self.CONF.set_override('host', 'ddddd', group='api')
|
||||||
server_cls = app.get_server_cls(cfg.CONF.api.host)
|
server_cls = app.get_server_cls(cfg.CONF.api.host)
|
||||||
self.assertEqual(server_cls.address_family, socket.AF_INET)
|
self.assertEqual(server_cls.address_family, socket.AF_INET)
|
||||||
|
|
||||||
|
def test_api_paste_file_not_exist(self):
|
||||||
|
self.CONF.set_override('api_paste_config', 'non-existent-file')
|
||||||
|
with mock.patch.object(self.CONF, 'find_file') as ff:
|
||||||
|
ff.return_value = None
|
||||||
|
self.assertRaises(cfg.ConfigFilesNotFoundError, app.load_app)
|
||||||
|
|||||||
Reference in New Issue
Block a user