From 47342ca6ace4289a64789feed82c3631540a55ef Mon Sep 17 00:00:00 2001
From: Constantinos Venetsanopoulos <cven@grnet.gr>
Date: Fri, 21 Sep 2012 12:24:24 +0300
Subject: [PATCH] Check if extstorage's log dir exists

Check if extstorage's log dir exists on the host machine, before
providing a logfile name. We need to be sure the dir exists,
otherwise RunCmd will fail ugly when passed a logfile that cannot
be opened.

Signed-off-by: Constantinos Venetsanopoulos <cven@grnet.gr>
---
 lib/bdev.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/bdev.py b/lib/bdev.py
index f3e5fc155..7b330bc42 100644
--- a/lib/bdev.py
+++ b/lib/bdev.py
@@ -2968,6 +2968,10 @@ def _VolumeLogName(kind, es_name, volume):
   @param volume: the name of the Volume inside the External Storage
 
   """
+  # Check if the extstorage log dir is a valid dir
+  if not os.path.isdir(constants.LOG_ES_DIR):
+    _ThrowError("Cannot find log directory: %s", constants.LOG_ES_DIR)
+
   # TODO: Use tempfile.mkstemp to create unique filename
   base = ("%s-%s-%s-%s.log" %
           (kind, es_name, volume, utils.TimestampForFilename()))
-- 
GitLab