Adds better logging to the domain config finder

There was no feedback for files that did't match the pattern at all. So
if you had a config keystone.domain.confg (because of a mistype) you
wouldn't get feedback saying that your config was or wasn't being used.

Change-Id: I53b446d0413bd1acda420626d4a7e111e4b97f4f
Related-Bug: 1472059
This commit is contained in:
David Stanek 2016-02-11 18:57:46 +00:00
parent 61706dc818
commit 36f7aa0e56
2 changed files with 13 additions and 7 deletions

View File

@ -508,6 +508,7 @@ def _domain_config_finder(conf_dir):
:returns: generator yeilding (filename, domain_name) tuples
"""
LOG.info(_LI('Scanning %r for domain config files'), conf_dir)
for r, d, f in os.walk(conf_dir):
for fname in f:
if (fname.startswith(DOMAIN_CONF_FHEAD) and
@ -516,9 +517,10 @@ def _domain_config_finder(conf_dir):
domain_name = fname[len(DOMAIN_CONF_FHEAD):
-len(DOMAIN_CONF_FTAIL)]
yield (os.path.join(r, fname), domain_name)
else:
LOG.warning(_LW('Ignoring file (%s) while scanning '
'domain config directory'), fname)
continue
LOG.warning(_LW('Ignoring file (%s) while scanning '
'domain config directory'), fname)
class DomainConfigUploadFiles(object):

View File

@ -384,7 +384,11 @@ class TestDomainConfigFinder(unit.BaseTestCase):
self.assertThat(domain_configs,
matchers.Equals(expected_domain_configs))
expected_msg = ('Ignoring file (keystone.conf) while scanning domain '
'config directory')
self.assertThat(self.logging.output,
matchers.Contains(expected_msg))
expected_msg_template = ('Ignoring file (%s) while scanning '
'domain config directory')
self.assertThat(
self.logging.output,
matchers.Contains(expected_msg_template % 'file.txt'))
self.assertThat(
self.logging.output,
matchers.Contains(expected_msg_template % 'keystone.conf'))