diff --git a/os_collect_config/local.py b/os_collect_config/local.py index 8da1a26..a811167 100644 --- a/os_collect_config/local.py +++ b/os_collect_config/local.py @@ -59,6 +59,11 @@ class Collector(object): raise exc.LocalMetadataNotAvailable final_content = [] 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): raise exc.LocalMetadataNotAvailable for data_file in os.listdir(local_path): diff --git a/os_collect_config/tests/test_local.py b/os_collect_config/tests/test_local.py index 22f5d16..9e51517 100644 --- a/os_collect_config/tests/test_local.py +++ b/os_collect_config/tests/test_local.py @@ -140,3 +140,11 @@ class TestLocal(testtools.TestCase): badjson.write('{') self.assertRaises(exc.LocalMetadataNotAvailable, self._call_collect) 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))