merge_ssh.patch
src/tm_mad/iscsi/ln | ||
---|---|---|
58 | 58 |
TARGET_DEV="/dev/$VG_NAME/$LV_NAME" |
59 | 59 |
TARGET_HOST=${TARGET%.$VG_NAME.$LV_NAME} |
60 | 60 | |
61 |
DISCOVER_CMD=$(cat <<EOF
|
|
61 |
LINK_CMD=$(cat <<EOF
|
|
62 | 62 |
set -e |
63 | ||
64 |
# discover and login |
|
63 | 65 |
mkdir -p $DST_DIR |
64 | 66 |
$SUDO $(iscsiadm_discovery "$TARGET_HOST") |
65 | 67 |
$SUDO $(iscsiadm_login "$IQN" "$TARGET_HOST") |
66 |
EOF |
|
67 |
) |
|
68 | ||
69 |
ssh_exec_and_log "$DST_HOST" "$DISCOVER_CMD" \ |
|
70 |
"Error discovering $DST_HOST:$DEV" |
|
71 | 68 | |
72 |
TEST_CMD=$(cat <<EOF |
|
73 |
set -e |
|
69 |
# poll |
|
74 | 70 |
while [ ! -L /dev/disk/by-path/*$IQN-lun-1 ]; do |
75 |
sleep 1
|
|
71 |
sleep 1
|
|
76 | 72 |
done |
77 |
EOF |
|
78 |
) |
|
79 | ||
80 |
ssh_exec_and_log "$DST_HOST" "$TEST_CMD" \ |
|
81 |
"Error waiting for $IQN iSCSI LUN to appear in $DST_HOST" |
|
82 | 73 | |
83 |
LINK_CMD=$(cat <<EOF |
|
84 |
set -e |
|
74 |
# link |
|
85 | 75 |
DISK_BY_PATH=\$(ls /dev/disk/by-path/*$IQN-lun-1) |
86 | 76 |
ln -s "\$DISK_BY_PATH" "$DST_PATH" |
87 |
DISK_DEVNAME=\$(readlink -f \$DISK_BY_PATH | awk -F'/' '{ print \$NF }') |
|
88 | 77 |
EOF |
89 | 78 |
) |
90 | 79 | |
91 | 80 |
ssh_exec_and_log "$DST_HOST" "$LINK_CMD" \ |
92 |
"Error linking $DST_HOST:$DEV" |
|
93 | ||
81 |
"Error linking $DST_HOST:$TARGET_DEV" |
|
94 | 82 | |
95 | 83 |
exit 0 |