Do not log unconfigured collector as warning

The configuration will dictate whether or not something is configured.
If it is not, this is a normal state and should not be logged as a
warning.

Change-Id: I479f0aed5837871009bc69fa028f5eb64a060c53
Closes-Bug: #1321551
This commit is contained in:
Clint Byrum 2014-07-08 14:13:37 -07:00
parent 42efe2b969
commit 79efeba4c3
3 changed files with 23 additions and 3 deletions

View File

@ -134,6 +134,9 @@ def collect_all(collectors, store=False, collector_kwargs_map=None):
except exc.SourceNotAvailable:
logger.warn('Source [%s] Unavailable.' % collector)
continue
except exc.SourceNotConfigured:
logger.debug('Source [%s] Not configured.' % collector)
continue
if store:
for output_key, output_content in content:

View File

@ -18,6 +18,10 @@ class SourceNotAvailable(RuntimeError):
"""The requested data source is unavailable."""
class SourceNotConfigured(RuntimeError):
"""The requested data source is not configured."""
class Ec2MetadataNotAvailable(SourceNotAvailable):
"""The EC2 metadata service is not available."""
@ -30,11 +34,11 @@ class HeatMetadataNotAvailable(SourceNotAvailable):
"""The heat metadata service is not available."""
class CfnMetadataNotConfigured(SourceNotAvailable):
class CfnMetadataNotConfigured(SourceNotConfigured):
"""The cfn metadata service is not fully configured."""
class HeatMetadataNotConfigured(SourceNotAvailable):
class HeatMetadataNotConfigured(SourceNotConfigured):
"""The heat metadata service is not fully configured."""

View File

@ -300,7 +300,7 @@ class TestCollect(testtools.TestCase):
class TestCollectAll(testtools.TestCase):
def setUp(self):
super(TestCollectAll, self).setUp()
self.useFixture(fixtures.FakeLogger())
self.log = self.useFixture(fixtures.FakeLogger())
collect.setup_conf()
self.cache_dir = self.useFixture(fixtures.TempDir())
self.backup_cache_dir = self.useFixture(fixtures.TempDir())
@ -440,6 +440,19 @@ class TestCollectAll(testtools.TestCase):
self.assertThat(content, matchers.IsInstance(dict))
self.assertNotIn('ec2', content)
def test_collect_all_cfn_unconfigured(self):
collector_kwargs_map = {
'cfn': {'requests_impl': test_cfn.FakeRequests(self)}
}
cfg.CONF.cfn.metadata_url = None
(changed_keys, content) = self._call_collect_all(
store=False, collector_kwargs_map=collector_kwargs_map,
collectors=['heat_local', 'cfn'])
self.assertIn('No metadata_url configured', self.log.output)
self.assertNotIn('cfn', content)
self.assertIn('heat_local', content)
self.assertEqual(test_heat_local.META_DATA, content['heat_local'])
class TestConf(testtools.TestCase):