Skip to content

Commit

Permalink
disable volume during undeploy
Browse files Browse the repository at this point in the history
  • Loading branch information
kvaps committed Apr 4, 2019
1 parent 24daea5 commit 421c6e3
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/tm_mad/fs_lvm/mv
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ DST_PATH=`arg_path $DST`
SRC_HOST=`arg_host $SRC`
DST_HOST=`arg_host $DST`

SRC_DIR=`dirname $SRC_PATH`
DST_DIR=`dirname $DST_PATH`

SRC_DS_DIR=`dirname $SRC_PATH`
Expand Down Expand Up @@ -81,17 +82,30 @@ if [ `is_disk $DST_PATH` -eq 1 ]; then

LCM_STATE="${XPATH_ELEMENTS[j++]}"

# Ignore EPILOG_UNDEPLOY
if [ "${LCM_STATE}" = "30" ]; then
exit 0
fi

LV_NAME="lv-one-${VMID}-${DISK_ID}"
SRC_VG_NAME="vg-one-${SRC_DS_SYS_ID}"
SRC_DEV="/dev/${SRC_VG_NAME}/${LV_NAME}"
DST_VG_NAME="vg-one-${DST_DS_SYS_ID}"
DST_DEV="/dev/${DST_VG_NAME}/${LV_NAME}"

# undeploy operation
if [ "${LCM_STATE}" = "30" ]; then
# deactivate
CMD=$(cat <<EOF
set -ex -o pipefail
${SUDO} ${SYNC}
${SUDO} ${LVSCAN}
${SUDO} ${LVCHANGE} -an "${SRC_DEV}"
rm -f "${SRC_DIR}/.host" || :
EOF
)
ssh_exec_and_log "$SRC_HOST" "$CMD" \
"Error deactivating disk $SRC_PATH"

exit 0
fi

# copy volume between datastores
if [ "${SRC_PATH}" != "${DST_PATH}" ]; then
# create new volume
Expand Down

0 comments on commit 421c6e3

Please sign in to comment.