|
@ -1,10 +1,11 @@ |
|
|
#!/bin/bash |
|
|
#!/bin/bash |
|
|
# create-cumulus-vx-image.sh V0.2 |
|
|
|
|
|
|
|
|
# create-cumulus-vx-image.sh V0.3 |
|
|
# HS-Fulda - sebastian.rieger@informatik.hs-fulda.de |
|
|
# HS-Fulda - sebastian.rieger@informatik.hs-fulda.de |
|
|
# |
|
|
# |
|
|
# changelog: |
|
|
# changelog: |
|
|
# |
|
|
# |
|
|
# V0.2 - added support to delete existing image with the same name and generating the default nova flavor |
|
|
|
|
|
|
|
|
# V0.2 added support to delete existing image with the same name and generating the default nova flavor |
|
|
|
|
|
# V0.3 checking whether it is safe to unmount the working directory |
|
|
|
|
|
|
|
|
# usage |
|
|
# usage |
|
|
if [ ! $# -eq 2 ] ; then |
|
|
if [ ! $# -eq 2 ] ; then |
|
@ -46,14 +47,17 @@ function safe_unmount() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
# check for an existing image with the same name and offer to delete it prior to creating a new one |
|
|
# check for an existing image with the same name and offer to delete it prior to creating a new one |
|
|
CHECK_FOR_EXISTING_IMAGE=$(glance image-show CumulusVX 2>&1) |
|
|
|
|
|
|
|
|
CHECK_FOR_EXISTING_IMAGE=$(glance image-show $GLANCE_IMAGE_NAME 2>&1) |
|
|
if [ $? == 0 ] ; then |
|
|
if [ $? == 0 ] ; then |
|
|
|
|
|
glance image-show $GLANCE_IMAGE_NAME |
|
|
|
|
|
echo |
|
|
|
|
|
echo |
|
|
read -r -p "There is already an image with the same name in glance. Do you want to overwrite it? [y/N] " RESPONSE |
|
|
read -r -p "There is already an image with the same name in glance. Do you want to overwrite it? [y/N] " RESPONSE |
|
|
if [[ $RESPONSE =~ ^([yY][eE][sS]|[yY])$ ]] ; then |
|
|
if [[ $RESPONSE =~ ^([yY][eE][sS]|[yY])$ ]] ; then |
|
|
echo "Deleting existing image $2..." |
|
|
|
|
|
|
|
|
echo "Deleting existing image $GLANCE_IMAGE_NAME..." |
|
|
echo "===========================================================" |
|
|
echo "===========================================================" |
|
|
|
|
|
|
|
|
glance image-delete $2 |
|
|
|
|
|
|
|
|
glance image-delete $GLANCE_IMAGE_NAME |
|
|
else |
|
|
else |
|
|
echo "An image with the same name already exists. Either delete this image or choose another name." |
|
|
echo "An image with the same name already exists. Either delete this image or choose another name." |
|
|
exit 1 |
|
|
exit 1 |
|
|