File 0108-Handle-exception-in-cases-where-the-path-is-not-avai.patch of Package lio-utils

From 341f8838824c35d84637de8592dbe5c72e7749bf Mon Sep 17 00:00:00 2001
From: Ritesh Raj Sarraf <rrs@researchut.com>
Date: Fri, 16 Mar 2012 01:51:17 +0530
Subject: Handle exception in cases where the path is not available

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@researchut.com>
Signed-off-by: Nicholas Bellinger <nab@risingtidesystems.com>
---
 tcm-py/tcm_fabric.py | 5 +++++
 tcm-py/tcm_node.py   | 5 +++++
 2 files changed, 10 insertions(+)

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.8.1.4