labs: osbash CLI default changes

This patch changes the default behavior of osbash in order to improve
useability and better protect user data:

If the user asks for a cluster, the script no longer asks whether to use
a matching base disk (the prompt was added before the basedisk command
that allows re-building a base disk if needed).

If an existing base disk is used, VMs already attached to that disk are
no longer removed wholesale. They are removed only if and when they are
about to be replaced by a new VM of the same name. Among other things,
this will allow us to rebuild some nodes without affecting others.

Change-Id: I6e52c521b9a5f61fa42b644a60c49bf20c2e7cc3
Implements: blueprint openstack-training-labs
This commit is contained in:
Roger Luethi 2014-08-14 14:07:46 +02:00
parent 9317570325
commit 0b4863c7b3

View File

@ -109,21 +109,24 @@ echo >&2 "$(date) osbash starting"
clean_dir "$LOG_DIR"
function cleanup_base_disk {
# Remove users of base disk
echo >&2 "Unregistering and removing all disks attached to base disk path"
disk_delete_child_vms "$BASE_DISK"
if [ -f "$BASE_DISK" ]; then
if [ "$CMD" = basedisk -a -f "$BASE_DISK" ]; then
echo >&2 "Found existing base disk: $BASE_DISK"
if ! yes_or_no "Re-use this base disk?"; then
if ! yes_or_no "Keep this base disk?"; then
if disk_registered "$BASE_DISK"; then
echo >&2 "Unregistering old base disk"
# Remove users of base disk
echo >&2 "Unregistering and removing all disks attached to" \
"base disk path."
disk_delete_child_vms "$BASE_DISK"
echo >&2 "Unregistering old base disk."
disk_unregister "$BASE_DISK"
fi
echo >&2 "Removing old base disk"
echo >&2 "Removing old base disk."
rm -f "$BASE_DISK"
else
echo >&2 "Nothing to do. Exiting."
exit
fi
fi
}
@ -142,6 +145,8 @@ if [ "$CMD" = basedisk ]; then
exit
fi
echo "Using base disk $BASE_DISK"
${WBATCH:-:} wbatch_create_hostnet
MGMT_NET_IF=$(create_network "$MGMT_NET")
DATA_NET_IF=$(create_network "$DATA_NET")