File 0024-lio_node-do-not-fail-if-target-port-is-already-disab.patch of Package lio-utils.216
From 7948ff48615b3102c44a860fe21ef1d17bae63b5 Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Mon, 31 Mar 2014 14:36:02 +0200
Subject: lio_node: do not fail if target port is already disabled
When calling 'lio_node --unload' the command should not fail
if the target port is already disabled.
References: bnc#863284
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
lio-py/lio_node.py | 31 ++++++++++++++++++++-----------
1 file changed, 20 insertions(+), 11 deletions(-)
diff --git a/lio-py/lio_node.py b/lio-py/lio_node.py
index d1cf7ee..51faef6 100755
--- a/lio-py/lio_node.py
+++ b/lio-py/lio_node.py
@@ -83,7 +83,6 @@ def lio_alua_process_secondary_md(option, opt_str, value, parser):
# LIO-Target endpoint (iqn+tpgt) exists..
lio_alua_check_secondary_md(iqn, tpgt)
lio_alua_set_secondary_write_md(iqn, tpgt, lun)
- lio_err("Unable to locate ALUA secondary metadata file: " + alua_sec_md_file)
return
# print "Using alua_sec_md_file: " + alua_sec_md_file
@@ -188,10 +187,15 @@ def __lio_target_del_tpg(option, opt_str, value, parser, delete_tpg_md):
# This will set TPG Status to INACTIVE force all of the iSCSI sessions for this
# tiqn+tpgt tuple to be released.
- disable_op = "echo 0 > " + lio_root + "/" + iqn + "/tpgt_" + tpgt + "/enable"
- ret = os.system(disable_op)
- if ret:
- print "Unable to disable TPG: " + iqn + " TPGT: " + tpgt
+ enable_path = lio_root + "/" + iqn + "/tpgt_" + tpgt + "/enable"
+ p = os.open(enable_path, 0);
+ value = os.read(p, 8)
+ os.close(p)
+ if value.rstrip() == "1":
+ disable_op = "echo 0 > " + enable_path
+ ret = os.system(disable_op)
+ if ret:
+ lio_err("Unable to disable TPG: " + iqn + " TPGT: " + tpgt)
np_root = os.listdir(lio_root + "/" + iqn + "/tpgt_" + tpgt + "/np")
for np in np_root:
@@ -508,12 +512,17 @@ def lio_target_disable_tpg(option, opt_str, value, parser):
iqn = iqn.lower();
tpgt = str(value[1]);
- disable_op = "echo 0 > " + lio_root + "/" + iqn + "/tpgt_" + tpgt + "/enable"
- ret = os.system(disable_op)
- if ret:
- lio_err("Unable to disable iSCSI Target Portal Group: " + iqn + " " + tpgt)
- else:
- lio_dbg("Successfully disabled iSCSI Target Portal Group: " + iqn + " " + tpgt)
+ enable_path = lio_root + "/" + iqn + "/tpgt_" + tpgt + "/enable"
+ p = os.open(enable_path, 0)
+ value = os.read(p, 8)
+ os.close(p)
+ if value.rstrip() == "1":
+ disable_op = "echo 0 > " + enable_path
+ ret = os.system(disable_op)
+ if ret:
+ lio_err("Unable to disable iSCSI Target Portal Group: " + iqn + " " + tpgt)
+ else:
+ lio_dbg("Successfully disabled iSCSI Target Portal Group: " + iqn + " " + tpgt)
return
--
1.8.1.4