summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@gmail.com>2013-12-12 11:28:05 -0500
committerScott Moser <smoser@ubuntu.com>2013-12-12 11:28:05 -0500
commit84df36df0fbe23bf6adacd0aa531765dbda6f27a (patch)
treee707e0e0f4a575edca2ffce4cce33b88587e709d
parentee9fbafae1abfd7ba3f4bece11f722519116ca81 (diff)
parent47d15924ea38f249a2c54d33dd24c3c284c4eb72 (diff)
downloadvyos-cloud-init-84df36df0fbe23bf6adacd0aa531765dbda6f27a.tar.gz
vyos-cloud-init-84df36df0fbe23bf6adacd0aa531765dbda6f27a.zip
Add a log message around import failures.
Since the import failure can be an expected failure do not log that failure at a WARNING level, but to start log it at a DEBUG level. This will help in figuring out why imports fail (if they ever do) for developer and cloud-init users. Previously it is hard to know if a module fails importing for a valid reason (not existent) or an invalid reason (the module exists but the module has a dependency which is not satisfied).
-rw-r--r--ChangeLog1
-rw-r--r--cloudinit/importer.py6
2 files changed, 5 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 8113da9c..e39cf0ca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
0.7.5:
- open 0.7.5
+ - Add a debug log message around import failures
0.7.4:
- fix issue mounting 'ephemeral0' if ephemeral0 was an alias for a
partitioned block device with target filesystem on ephemeral0.1.
diff --git a/cloudinit/importer.py b/cloudinit/importer.py
index 71cf2726..a094141a 100644
--- a/cloudinit/importer.py
+++ b/cloudinit/importer.py
@@ -36,6 +36,7 @@ def find_module(base_name, search_paths, required_attrs=None):
found_places = []
if not required_attrs:
required_attrs = []
+ # NOTE(harlowja): translate the search paths to include the base name.
real_paths = []
for path in search_paths:
real_path = []
@@ -50,8 +51,9 @@ def find_module(base_name, search_paths, required_attrs=None):
mod = None
try:
mod = import_module(full_path)
- except ImportError:
- pass
+ except ImportError as e:
+ LOG.debug("Failed at attempted import of '%s' due to: %s",
+ full_path, e)
if not mod:
continue
found_attrs = 0