File 0021-lio_dump-Error-checking-in-startup-script.patch of Package lio-utils.216

From 4d066c3367b339cf1070924f1a46a0c1cc14f865 Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Fri, 1 Feb 2013 15:20:29 +0100
Subject: lio_dump: Error checking in startup script

When generating the startup script we should be inserting some
error checking to allow the startup to report errors.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 lio-py/lio_dump.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lio-py/lio_dump.py b/lio-py/lio_dump.py
index 2a88f3a..c6a3600 100755
--- a/lio-py/lio_dump.py
+++ b/lio-py/lio_dump.py
@@ -21,7 +21,7 @@ def lio_target_configfs_dump(option, opt_str, value, parser):
 
 	# This will load up iscsi_target_mod.ko
 	print "mkdir " + lio_root
-
+	print "[ $? -eq 0 ] || exit 1"
 	print "#### iSCSI Discovery authentication information"
 	auth_dir = lio_root + "/discovery_auth"
 	if os.path.isdir(auth_dir) == True:
@@ -62,6 +62,7 @@ def lio_target_configfs_dump(option, opt_str, value, parser):
 			for np in np_root:
 				np_path = lio_root + "/" + iqn + "/tpgt_" + tpgt + "/np/" + np
 				print "mkdir -p " + np_path
+				print "[ $? -eq 0 ] || exit 1"
 				np_path_iser = np_path + "/iser"
 				if os.path.isfile(np_path_iser):
 					iser_fd = open(np_path_iser, 'r')
@@ -78,6 +79,7 @@ def lio_target_configfs_dump(option, opt_str, value, parser):
 				
 				lun_dir = lio_root + "/" + iqn + "/tpgt_" + tpgt + "/lun/lun_" + lun
 				print "mkdir -p " + lun_dir
+				print "[ $? -eq 0 ] || exit 1"
 
 				port_root = os.listdir(lun_dir)
 				for port in port_root:
@@ -97,6 +99,7 @@ def lio_target_configfs_dump(option, opt_str, value, parser):
 					sourcelink = os.readlink(port_link)
 					sourcelink2 = os.path.join(os.path.dirname(port_link), sourcelink)
 					print "ln -s " + sourcelink2 + " " + port_link
+					print "[ $? -eq 0 ] || exit 1"
 
 				# Dump ALUA Target Port Group
 				tg_pt_gp_file = lun_dir + "/alua_tg_pt_gp"
@@ -120,6 +123,7 @@ def lio_target_configfs_dump(option, opt_str, value, parser):
 						print "echo " + tg_pt_gp_name + " > " + tg_pt_gp_file
 
 					print "lio_node --aluasecmd " + iqn + " " + tpgt + " " + lun
+					print "[ $? -eq 0 ] || exit 1"
 
 			# Dump values of iscsi/iqn/tpgt/attrib/
 			print "#### Attributes for iSCSI Target Portal Group"
@@ -165,6 +169,7 @@ def lio_target_configfs_dump(option, opt_str, value, parser):
 			nacl_root = os.listdir(nacl_dir)
 			for nacl in nacl_root:
 				print "mkdir -p " + nacl_dir + nacl
+				print "[ $? -eq 0 ] || exit 1"
 				tcq_depth_file = nacl_dir + nacl + "/cmdsn_depth"
 				p = os.open(tcq_depth_file, 0)
 				value = os.read(p, 8)
@@ -206,6 +211,7 @@ def lio_target_configfs_dump(option, opt_str, value, parser):
 						continue
 					lun_link_dir = nacl_dir + nacl + "/" + lun_acl
 					print "mkdir -p " + lun_link_dir
+					print "[ $? -eq 0 ] || exit 1"
 
 					for lun_acl_link in os.listdir(lun_link_dir):
 						if lun_acl_link == "write_protect":
-- 
1.8.1.4

openSUSE Build Service is sponsored by