Revision 78e300e5

View differences:

src/tm_mad/iscsi/clone
92 92
ssh_exec_and_log "$TARGET_HOST" "$CLONE_CMD" \
93 93
        "Error cloning $DST_HOST:$TARGET_DEV"
94 94

  
95
DISCOVERY_CMD=$(cat <<EOF
95
LINK_CMD=$(cat <<EOF
96 96
    set -e
97

  
98
    # discover and login
97 99
    mkdir -p $DST_DIR
98 100
    $SUDO $(iscsiadm_discovery "$TARGET_HOST")
99 101
    $SUDO $(iscsiadm_login "$NEW_IQN" "$TARGET_HOST")
100
EOF
101
)
102

  
103
ssh_exec_and_log "$DST_HOST" "$DISCOVERY_CMD" \
104
        "Error discovering $NEW_IQN in $DST_HOST"
105 102

  
106
TEST_CMD=$(cat <<EOF
107
    set -e
103
    # poll
108 104
    while [ ! -L /dev/disk/by-path/*$NEW_IQN-lun-1 ]; do
109
	sleep 1
105
	   sleep 1
110 106
    done
111
EOF
112
)
113

  
114
ssh_exec_and_log "$DST_HOST" "$TEST_CMD" \
115
        "Error waiting for $NEW_IQN iSCSI LUN to appear in $DST_HOST"
116 107

  
117

  
118
LINK_CMD=$(cat <<EOF
119
    set -e
108
    # link
120 109
    DISK_BY_PATH=\$(ls /dev/disk/by-path/*$NEW_IQN-lun-1)
121 110
    ln -s "\$DISK_BY_PATH" "$DST_PATH"
122 111
    DISK_DEVNAME=\$(readlink -f \$DISK_BY_PATH  | awk -F'/' '{ print \$NF }')
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
src/tm_mad/iscsi/mv
114 114

  
115 115
    TARGET_HOST=$(iqn_get_host "$IQN")
116 116

  
117
LOGIN_CMD=$(cat <<EOF
118
        set -e
119
        mkdir -p $DST_DIR
120
        $SUDO $(iscsiadm_discovery "$TARGET_HOST")
121
        $SUDO $(iscsiadm_login "$IQN" "$TARGET_HOST")
122
EOF
123
)
117
    LINK_CMD=$(cat <<EOF
118
    set -e
124 119

  
125
ssh_exec_and_log "$DST_HOST" "$LOGIN_CMD" \
126
    "Error logging in $IQN"
120
    # discover and login
121
    mkdir -p $DST_DIR
122
    $SUDO $(iscsiadm_discovery "$TARGET_HOST")
123
    $SUDO $(iscsiadm_login "$IQN" "$TARGET_HOST")
127 124

  
128
TEST_CMD=$(cat <<EOF
129
    set -e
125
    # poll
130 126
    while [ ! -L /dev/disk/by-path/*$IQN-lun-1 ]; do
131 127
        sleep 1
132 128
    done
133
EOF
134
)
135 129

  
136
ssh_exec_and_log "$DST_HOST" "$TEST_CMD" \
137
        "Error waiting for $IQN iSCSI LUN to appear in $DST_HOST"
138

  
139
LINK_CMD=$(cat <<EOF
140
        set -e
141
        DISK_BY_PATH=\$(ls /dev/disk/by-path/*$IQN-lun-1)
142
        ln -sf "\$DISK_BY_PATH" "$DST_PATH"
130
    # link
131
    DISK_BY_PATH=\$(ls /dev/disk/by-path/*$IQN-lun-1)
132
    ln -sf "\$DISK_BY_PATH" "$DST_PATH"
143 133
EOF
144 134
)
145 135

  
146
ssh_exec_and_log "$DST_HOST" "$LINK_CMD" \
147
    "Error linking to $DISK_BY_PATH $DST_PATH"
136
    ssh_exec_and_log "$DST_HOST" "$LINK_CMD" \
137
        "Error linking to $DISK_BY_PATH $DST_PATH"
148 138

  
149 139

  
150 140
fi

Also available in: Unified diff