Enhance tgt cleanup in unstack.sh
*Check that tgt driver is in good state when we start if not try to just restart it *Remove targets based on iqn entries in persist files *Remove the persist files themeselves *Stop the tgt service Updated to use *_STATE_DIR vars Change-Id: I3ba9f2b8c099c7f290696760527fe2147d9b1d38
This commit is contained in:
parent
6cab01c01f
commit
d53bedc6bb
42
unstack.sh
42
unstack.sh
@ -18,6 +18,13 @@ source $TOP_DIR/functions
|
|||||||
# Load local configuration
|
# Load local configuration
|
||||||
source $TOP_DIR/stackrc
|
source $TOP_DIR/stackrc
|
||||||
|
|
||||||
|
# Destination path for service data
|
||||||
|
DATA_DIR=${DATA_DIR:-${DEST}/data}
|
||||||
|
|
||||||
|
# Get project function libraries
|
||||||
|
source $TOP_DIR/lib/cinder
|
||||||
|
source $TOP_DIR/lib/n-vol
|
||||||
|
|
||||||
# Determine what system we are running on. This provides ``os_VENDOR``,
|
# Determine what system we are running on. This provides ``os_VENDOR``,
|
||||||
# ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME``
|
# ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME``
|
||||||
GetOSVersion
|
GetOSVersion
|
||||||
@ -45,14 +52,41 @@ if is_service_enabled horizon; then
|
|||||||
stop_service apache2
|
stop_service apache2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
SCSI_PERSIST_DIR=$CINDER_STATE_PATH/volumes/*
|
||||||
|
|
||||||
# Get the iSCSI volumes
|
# Get the iSCSI volumes
|
||||||
if is_service_enabled cinder n-vol; then
|
if is_service_enabled cinder n-vol; then
|
||||||
|
if is_service_enabled n-vol; then
|
||||||
|
SCSI_PERSIST_DIR=$NOVA_STATE_PATH/volumes/*
|
||||||
|
fi
|
||||||
|
|
||||||
TARGETS=$(sudo tgtadm --op show --mode target)
|
TARGETS=$(sudo tgtadm --op show --mode target)
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
# If tgt driver isn't running this won't work obviously
|
||||||
|
# So check the response and restart if need be
|
||||||
|
echo "tgtd seems to be in a bad state, restarting..."
|
||||||
|
if [[ "$os_PACKAGE" = "deb" ]]; then
|
||||||
|
restart_service tgt
|
||||||
|
else
|
||||||
|
restart_service tgtd
|
||||||
|
fi
|
||||||
|
TARGETS=$(sudo tgtadm --op show --mode target)
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -n "$TARGETS" ]]; then
|
if [[ -n "$TARGETS" ]]; then
|
||||||
# FIXME(dtroyer): this could very well require more here to
|
iqn_list=( $(grep --no-filename -r iqn $SCSI_PERSIST_DIR | sed 's/<target //' | sed 's/>//') )
|
||||||
# clean up left-over volumes
|
for i in "${iqn_list[@]}"; do
|
||||||
echo "iSCSI target cleanup needed:"
|
echo removing iSCSI target: $i
|
||||||
echo "$TARGETS"
|
sudo tgt-admin --delete $i
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if is_service_enabled cinder; then
|
||||||
|
sudo rm -rf $CINDER_STATE_PATH/volumes/*
|
||||||
|
fi
|
||||||
|
|
||||||
|
if is_service_enabled n-vol; then
|
||||||
|
sudo rm -rf $NOVA_STATE_PATH/volumes/*
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$os_PACKAGE" = "deb" ]]; then
|
if [[ "$os_PACKAGE" = "deb" ]]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user