[PATCH] Handle exception in cases where the path is not available

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Ritesh Raj Sarraf <rrs@xxxxxxxxxxxxxx>

Please see, Debian bug:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=652052

This happens if you have lio installed but not enabled to start. Upon a
new version installation, the pkg manager calls the stop target. With no
kernel module loaded, this leads to tcm_fabric and tcm_node throwing out
exceptions

Signed-off-by: Ritesh Raj Sarraf <rrs@xxxxxxxxxxxxxx>
---
 tcm-py/tcm_fabric.py |    5 +++++
 tcm-py/tcm_node.py   |    5 +++++
 2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/tcm-py/tcm_fabric.py b/tcm-py/tcm_fabric.py
index 49768e7..2bdc77a 100755
--- a/tcm-py/tcm_fabric.py
+++ b/tcm-py/tcm_fabric.py
@@ -472,6 +472,11 @@ def fabric_unloadall():
 			continue
 
 		fabric_unload(fabric_name, fabric_root, module_name)
+	except OSError, (errno, strerror):
+		if errno == 2:
+			print "%s %s\n" % (target_root, strerror)
+			print "Is kernel module loaded?\n"
+			exit 1
 		
 
 def do_work(stdout_enable, stdout_enable_all, date_time, unload, unloadall, fabric_name, fabric_root, module_name):
diff --git a/tcm-py/tcm_node.py b/tcm-py/tcm_node.py
index 4504d9b..b7c05cf 100755
--- a/tcm-py/tcm_node.py
+++ b/tcm-py/tcm_node.py
@@ -25,6 +25,11 @@ def tcm_err(msg):
 def tcm_read(filename):
 	with open(filename) as f:
 		return f.read()
+	except IOError, (errno, strerror):
+		if errno == 2:
+			print "%s %s\n" % (filename, strerror)
+			print "Is kernel module loaded?\n"
+			exit 1
 
 def tcm_write(filename, value, newline=True):
 	with open(filename, "w") as f:
-- 
1.7.9.1

--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux SCSI]     [Kernel Newbies]     [Linux SCSI Target Infrastructure]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Device Mapper]

  Powered by Linux