Merge "Handle missing local collector directory"
This commit is contained in:
commit
72bd2854f6
@ -59,6 +59,11 @@ class Collector(object):
|
|||||||
raise exc.LocalMetadataNotAvailable
|
raise exc.LocalMetadataNotAvailable
|
||||||
final_content = []
|
final_content = []
|
||||||
for local_path in cfg.CONF.local.path:
|
for local_path in cfg.CONF.local.path:
|
||||||
|
try:
|
||||||
|
os.stat(local_path)
|
||||||
|
except OSError:
|
||||||
|
logger.warning("%s not found. Skipping", local_path)
|
||||||
|
continue
|
||||||
if _dest_looks_insecure(local_path):
|
if _dest_looks_insecure(local_path):
|
||||||
raise exc.LocalMetadataNotAvailable
|
raise exc.LocalMetadataNotAvailable
|
||||||
for data_file in os.listdir(local_path):
|
for data_file in os.listdir(local_path):
|
||||||
|
@ -140,3 +140,11 @@ class TestLocal(testtools.TestCase):
|
|||||||
badjson.write('{')
|
badjson.write('{')
|
||||||
self.assertRaises(exc.LocalMetadataNotAvailable, self._call_collect)
|
self.assertRaises(exc.LocalMetadataNotAvailable, self._call_collect)
|
||||||
self.assertIn('is not valid JSON', self.log.output)
|
self.assertIn('is not valid JSON', self.log.output)
|
||||||
|
|
||||||
|
def test_collect_local_path_nonexist(self):
|
||||||
|
cfg.CONF.set_override(name='path',
|
||||||
|
override=['/this/doesnt/exist'],
|
||||||
|
group='local')
|
||||||
|
local_md = self._call_collect()
|
||||||
|
self.assertThat(local_md, matchers.IsInstance(list))
|
||||||
|
self.assertEqual(0, len(local_md))
|
||||||
|
Loading…
Reference in New Issue
Block a user