File lio-utils-dump-skeleton-file-when-no-targets.patch of Package lio-utils.10501

From: Lee Duncan <lduncan@suse.com>
Date: Fri Nov 20 15:24:01 PST 2015
Subject: dump skeleton file when no targets
Reference: bsc#934521

When there is not target directory go ahead and
dump an empty skeleton target, since this happens
if there are no targets configured.

signed-off-by: Lee Duncan <lduncan@suse.com>
---
---
 lio-py/lio_dump.py |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

--- a/lio-py/lio_dump.py
+++ b/lio-py/lio_dump.py
@@ -10,18 +10,18 @@ lio_root = "/sys/kernel/config/target/is
 
 def lio_target_configfs_dump(option, opt_str, value, parser):
 
-	if not os.path.isdir(lio_root):
-		print "Unable to access lio_root: " + lio_root
-		sys.exit(1)
-
-	iqn_root = os.listdir(lio_root)
-
 	# Add proper shell header
 	print "#!/bin/bash"
 
 	# This will load up iscsi_target_mod.ko
 	print "mkdir " + lio_root
 	print "[ $? -eq 0 ] || exit 1"
+
+	# skip the rest if no lio_root
+	if not os.path.isdir(lio_root):
+		print >>sys.stderr, "No targets? Unable to access lio_root: " + lio_root
+		sys.exit(0)
+
 	print "#### iSCSI Discovery authentication information"
 	auth_dir = lio_root + "/discovery_auth"
 	if os.path.isdir(auth_dir) == True:
openSUSE Build Service is sponsored by