PasteConfigNotFound also raised when keystone.conf not found
Although keystone is looking for paste configuration on startup, this exception can also be raised when keystone attempts to look in the regular keystone.conf file for paste configuration, and can't find that file either. The solution here is just to make the exception slightly more generic (ConfigFileNotFound), along with it's rendered error message and improve surrounding comments to better explain the scenario. Change-Id: I88f1d987113884097b1cdf8c120613613abfb8c9 Closes-Bug: 1254036
This commit is contained in:
@@ -30,16 +30,20 @@ configure = config.configure
|
||||
|
||||
|
||||
def find_paste_config():
|
||||
"""Selects Keystone paste.deploy configuration file.
|
||||
"""Find Keystone's paste.deploy configuration file.
|
||||
|
||||
Keystone's paste.deploy configuration file is specified in the
|
||||
``[paste_deploy]`` section of the main Keystone configuration file,
|
||||
``keystone.conf``.
|
||||
|
||||
For example::
|
||||
|
||||
Keystone paste.deploy configuration file is selectd in [paste_deploy]
|
||||
section of the main Keystone configuration file.
|
||||
For example:
|
||||
[paste_deploy]
|
||||
config_file = keystone-paste.ini
|
||||
|
||||
:returns: The selected configuration filename
|
||||
:raises: exception.PasteConfigNotFound
|
||||
:raises: exception.ConfigFileNotFound
|
||||
|
||||
"""
|
||||
if CONF.paste_deploy.config_file:
|
||||
paste_config = CONF.paste_deploy.config_file
|
||||
@@ -50,8 +54,11 @@ def find_paste_config():
|
||||
paste_config = CONF.config_file[0]
|
||||
paste_config_value = paste_config
|
||||
else:
|
||||
# this provides backwards compatibility for keystone.conf files that
|
||||
# still have the entire paste configuration included, rather than just
|
||||
# a [paste_deploy] configuration section referring to an external file
|
||||
paste_config = CONF.find_file('keystone.conf')
|
||||
paste_config_value = 'keystone.conf'
|
||||
if not paste_config or not os.path.exists(paste_config):
|
||||
raise exception.PasteConfigNotFound(config_file=paste_config_value)
|
||||
raise exception.ConfigFileNotFound(config_file=paste_config_value)
|
||||
return paste_config
|
||||
|
||||
@@ -241,6 +241,6 @@ class NotImplemented(Error):
|
||||
title = 'Not Implemented'
|
||||
|
||||
|
||||
class PasteConfigNotFound(UnexpectedError):
|
||||
message_format = _("The Keystone paste configuration file"
|
||||
" %(config_file)s could not be found.")
|
||||
class ConfigFileNotFound(UnexpectedError):
|
||||
message_format = _("The Keystone configuration file %(config_file)s could "
|
||||
"not be found.")
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
|
||||
from keystone import config
|
||||
from keystone import exception
|
||||
from keystone import tests
|
||||
@@ -26,8 +28,8 @@ class ConfigTestCase(tests.TestCase):
|
||||
def test_paste_config(self):
|
||||
self.assertEqual(config.find_paste_config(),
|
||||
tests.etcdir('keystone-paste.ini'))
|
||||
self.opt_in_group('paste_deploy', config_file='XYZ')
|
||||
self.assertRaises(exception.PasteConfigNotFound,
|
||||
self.opt_in_group('paste_deploy', config_file=uuid.uuid4().hex)
|
||||
self.assertRaises(exception.ConfigFileNotFound,
|
||||
config.find_paste_config)
|
||||
self.opt_in_group('paste_deploy', config_file='')
|
||||
self.assertEqual(config.find_paste_config(),
|
||||
|
||||
Reference in New Issue
Block a user