|
|
a56a5e |
From 20700e3dea3c10aa2c9d4a724ec3d671455d556f Mon Sep 17 00:00:00 2001
|
|
|
a56a5e |
From: Harald Hoyer <harald@redhat.com>
|
|
|
a56a5e |
Date: Mon, 12 Jan 2015 14:06:10 +0100
|
|
|
a56a5e |
Subject: [PATCH] net-lib.sh:parse_iscsi_root() fix target parsing
|
|
|
a56a5e |
|
|
|
a56a5e |
For targets with colons in the iSCSI target name:
|
|
|
a56a5e |
"iqn.2000-09.com.foo:storage-system.e2000:00000001cm1p1"
|
|
|
a56a5e |
|
|
|
a56a5e |
the parser was confused with the optional iscsi_iface_name and
|
|
|
a56a5e |
iscsi_netdev_name.
|
|
|
a56a5e |
|
|
|
a56a5e |
This patch reintroduces the old IQN, EUI and NAA parsing and enhances
|
|
|
a56a5e |
the fallback parser by checking the LUN for a numerical value.
|
|
|
a56a5e |
|
|
|
a56a5e |
(cherry picked from commit 36e8ce4fb01824b49697bd0e7ad3ca3c4cfd4297)
|
|
|
a56a5e |
---
|
|
|
49e6a8 |
modules.d/40network/net-lib.sh | 50 ++++++++++++++++++++++++++--------
|
|
|
a56a5e |
1 file changed, 38 insertions(+), 12 deletions(-)
|
|
|
a56a5e |
|
|
|
a56a5e |
diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh
|
|
|
1755ca |
index 337817e3..f0850207 100755
|
|
|
a56a5e |
--- a/modules.d/40network/net-lib.sh
|
|
|
a56a5e |
+++ b/modules.d/40network/net-lib.sh
|
|
|
a56a5e |
@@ -310,6 +310,23 @@ parse_iscsi_root()
|
|
|
a56a5e |
;;
|
|
|
a56a5e |
esac
|
|
|
a56a5e |
|
|
|
a56a5e |
+ unset iscsi_target_name
|
|
|
a56a5e |
+ # extract target name
|
|
|
a56a5e |
+ case "$v" in
|
|
|
a56a5e |
+ *:iqn.*)
|
|
|
a56a5e |
+ iscsi_target_name=iqn.${v##*:iqn.}
|
|
|
a56a5e |
+ v=${v%:iqn.*}:
|
|
|
a56a5e |
+ ;;
|
|
|
a56a5e |
+ *:eui.*)
|
|
|
a56a5e |
+ iscsi_target_name=iqn.${v##*:eui.}
|
|
|
a56a5e |
+ v=${v%:iqn.*}:
|
|
|
a56a5e |
+ ;;
|
|
|
a56a5e |
+ *:naa.*)
|
|
|
a56a5e |
+ iscsi_target_name=iqn.${v##*:naa.}
|
|
|
a56a5e |
+ v=${v%:iqn.*}:
|
|
|
a56a5e |
+ ;;
|
|
|
a56a5e |
+ esac
|
|
|
a56a5e |
+
|
|
|
a56a5e |
# parse the rest
|
|
|
a56a5e |
OLDIFS="$IFS"
|
|
|
a56a5e |
IFS=:
|
|
|
a56a5e |
@@ -319,24 +336,33 @@ parse_iscsi_root()
|
|
|
a56a5e |
iscsi_protocol=$1; shift # ignored
|
|
|
a56a5e |
iscsi_target_port=$1; shift
|
|
|
a56a5e |
|
|
|
a56a5e |
- if [ $# -gt 3 ] && [ -n "$1$2" ]; then
|
|
|
a56a5e |
- iscsi_iface_name=$1; shift
|
|
|
a56a5e |
- iscsi_netdev_name=$1; shift
|
|
|
a56a5e |
+ if [ -n "$iscsi_target_name" ]; then
|
|
|
a56a5e |
+ if [ $# -eq 3 ]; then
|
|
|
a56a5e |
+ iscsi_iface_name=$1; shift
|
|
|
a56a5e |
+ fi
|
|
|
a56a5e |
+ if [ $# -eq 2 ]; then
|
|
|
a56a5e |
+ iscsi_netdev_name=$1; shift
|
|
|
a56a5e |
+ fi
|
|
|
a56a5e |
+ iscsi_lun=$1; shift
|
|
|
a56a5e |
+ if [ $# -ne 0 ]; then
|
|
|
a56a5e |
+ warn "Invalid parameter in iscsi: parameter!"
|
|
|
a56a5e |
+ return 1
|
|
|
a56a5e |
+ fi
|
|
|
a56a5e |
+ return 0
|
|
|
a56a5e |
fi
|
|
|
a56a5e |
|
|
|
a56a5e |
- iscsi_lun=$1; shift
|
|
|
a56a5e |
|
|
|
a56a5e |
- if [ $# -gt 2 ]; then
|
|
|
a56a5e |
- warn "Invalid parameter in iscsi: parameter!"
|
|
|
a56a5e |
- return 1
|
|
|
a56a5e |
+ if [ $# -gt 3 ] && [ -n "$1$2" ]; then
|
|
|
a56a5e |
+ if [ -z "$3" ] || [ "$3" -ge 0 ] 2>/dev/null ; then
|
|
|
a56a5e |
+ iscsi_iface_name=$1; shift
|
|
|
a56a5e |
+ iscsi_netdev_name=$1; shift
|
|
|
a56a5e |
+ fi
|
|
|
a56a5e |
fi
|
|
|
a56a5e |
|
|
|
a56a5e |
- if [ $# -eq 2 ]; then
|
|
|
a56a5e |
- iscsi_target_name="$1:$2"
|
|
|
a56a5e |
- else
|
|
|
a56a5e |
- iscsi_target_name="$1"
|
|
|
a56a5e |
- fi
|
|
|
a56a5e |
+ iscsi_lun=$1; shift
|
|
|
a56a5e |
|
|
|
a56a5e |
+ iscsi_target_name=$(printf "%s:" "$@")
|
|
|
a56a5e |
+ iscsi_target_name=${iscsi_target_name%:}
|
|
|
a56a5e |
}
|
|
|
a56a5e |
|
|
|
a56a5e |
ip_to_var() {
|