File 0120-lio-node-Add-iser-network-portal-attribute-ib_isert-.patch of Package lio-utils.9620

From 3143009d99e854f23cff437df1812cc39c14a42b Mon Sep 17 00:00:00 2001
From: Nicholas Bellinger <nab@risingtidesystems.com>
Date: Thu, 11 Apr 2013 20:32:40 -0700
Subject: lio-node: Add iser network portal attribute + ib_isert shutdown
 support

Signed-off-by: Nicholas Bellinger <nab@risingtidesystems.com>
---
 lio-py/lio_node.py | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/lio-py/lio_node.py b/lio-py/lio_node.py
index c7082e8..02e661b 100755
--- a/lio-py/lio_node.py
+++ b/lio-py/lio_node.py
@@ -277,7 +277,20 @@ def lio_target_del_np(option, opt_str, value, parser):
 	tpgt = str(value[1]);
 	np = str(value[2]);
 
-	rmdir_op = "rmdir " + lio_root + "/" + iqn + "/tpgt_" + tpgt + "/np/" + np
+	path = lio_root + "/" + iqn + "/tpgt_" + tpgt + "/np/" + np
+
+	path_iser = path + "/iser"
+	if os.path.isfile(path_iser):
+		fd = open(path_iser, 'r')
+		s = fd.read()
+		set_iser_attr = s.strip()
+		fd.close()
+		if set_iser_attr == "1":
+			fd = open(path_iser, 'w')
+			fd.write("0")
+			fd.close()
+
+	rmdir_op = "rmdir " + path
 #	print "rmdir_op: " + rmdir_op
 	ret = os.system(rmdir_op)
 	if not ret:
@@ -1230,6 +1243,15 @@ def lio_target_unload(option, opt_str, value, parser):
 		if ret:
 			print "Unable to remove lio_root: " + lio_root
 
+	fd = open("/proc/modules", 'r')
+	buf = fd.read()
+	fd.close()
+	if re.search('ib_isert', buf):
+	        rmmod_op = "rmmod ib_isert"
+	        ret = os.system(rmmod_op)
+	        if ret:
+	                print "Unable to unload ib_isert"
+
 	rmmod_op = "rmmod iscsi_target_mod"
 	ret = os.system(rmmod_op)
 	if ret:
-- 
1.8.1.4
openSUSE Build Service is sponsored by