When pool is defined in config but the directory entered there does not
exist, lnst-ctl ends in OSError exception. This patch prevents that with
warning user that on entered path no directory exists and skips
processing it.
Fixes #173
Signed-off-by: Jiri Prochazka <jprochaz(a)redhat.com>
---
lnst/Controller/SlavePool.py | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/lnst/Controller/SlavePool.py b/lnst/Controller/SlavePool.py
index 02715ed..ddd4168 100644
--- a/lnst/Controller/SlavePool.py
+++ b/lnst/Controller/SlavePool.py
@@ -65,7 +65,14 @@ class SlavePool:
dir_path))
pool = self._pools[pool_name]
- dentries = os.listdir(dir_path)
+ try:
+ dentries = os.listdir(dir_path)
+ except OSError:
+ logging.warn("Directory '%s' does not exist for pool
'%s'" %
+ (dir_path,
+ pool_name))
+ return
+
for dirent in dentries:
m_id, m = self.add_file(pool_name, dir_path, dirent)
if m_id != None and m != None:
--
2.4.11