From 3db9d36e8507552812c3b2f331e9c6fd2b98e55a Mon Sep 17 00:00:00 2001 From: Abraham Arce Date: Wed, 31 Oct 2018 03:36:40 -0600 Subject: [PATCH] Setup Configurations Clean Up Combine setup_allinone.sh and setup_standard_controller.sh to have one single setup script to configure via input parameter allinone and standardcontroller configurations: - setup_configuration.sh - destroy_configuration.sh Change-Id: Id29d3eeeff43f0c0f43ab710a1179eaacdfb330d Signed-off-by: Abraham Arce --- deployment/libvirt/README.rst | 23 ++++++----- deployment/libvirt/destroy_allinone.sh | 11 ------ deployment/libvirt/destroy_configuration.sh | 38 +++++++++++++++++++ .../libvirt/destroy_standard_controller.sh | 18 --------- deployment/libvirt/functions.sh | 11 +++++- deployment/libvirt/setup_allinone.sh | 37 ------------------ ...d_controller.sh => setup_configuration.sh} | 21 ++++++---- 7 files changed, 75 insertions(+), 84 deletions(-) delete mode 100755 deployment/libvirt/destroy_allinone.sh create mode 100755 deployment/libvirt/destroy_configuration.sh delete mode 100755 deployment/libvirt/destroy_standard_controller.sh delete mode 100755 deployment/libvirt/setup_allinone.sh rename deployment/libvirt/{setup_standard_controller.sh => setup_configuration.sh} (60%) diff --git a/deployment/libvirt/README.rst b/deployment/libvirt/README.rst index 0835dbe6..a2004777 100644 --- a/deployment/libvirt/README.rst +++ b/deployment/libvirt/README.rst @@ -5,8 +5,8 @@ This is a quick reference for deploying StarlingX on libvirt/qemu systems. It assumes you have a working libvirt/qemu installation for a non-root user and that your user has NOPASSWD sudo permissions. -Refer also to pages "Installation Guide Virtual Environment", "Testing Guide" -on the StarlingX wiki: https://wiki.openstack.org/wiki/StarlingX +Refer also to pages "Installation Guide" on the StarlingX Documentation: +https://docs.starlingx.io/installation_guide/index.html Overview -------- @@ -45,16 +45,19 @@ It should also only be used after all of the VMs created below have been destroy Controllers ----------- -There are two scripts for creating the controllers: ``setup_allinone.sh`` and -``setup_standard_controller.sh``. They are operated in the same manner but build -different StarlingX cloud configurations. Choose wisely. +There is one script for creating the controllers: ``setup_configuration.sh``. It +builds different StarlingX cloud configurations: -You need an ISO file for the installation, these scripts take a name with the +- allinone +- standardcontroller + +You need an StarlingX ISO file for the installation. The script takes the +configuration name with the ``-c`` option and the ISO file name with the ``-i`` option:: - ./setup_allinone.sh -i stx-2018-08-28-93.iso + ./setup_configuration.sh -c allinone -i stx-2018-08-28-93.iso -And the setup will begin. The scripts create one or more VMs and start the boot +And the setup will begin. The script create one or more VMs and start the boot of the first controller, named oddly enough ``controller-0``. If you have Xwindows available you will get virt-manager running. If not, Ctrl-C out of that attempt if it doesn't return to a shell prompt. @@ -64,4 +67,6 @@ Then connect to the serial console:: Continue the usual StarlingX installation from this point forward. -Tear down the VMs using ``destroy_allinone.sh`` and ``destroy_standard_controller.sh``. +Tear down the VMs giving the configuration name with the ``-c`` option:: + +>-------./destroy_configuration.sh -c allinone diff --git a/deployment/libvirt/destroy_allinone.sh b/deployment/libvirt/destroy_allinone.sh deleted file mode 100755 index b3f8aa66..00000000 --- a/deployment/libvirt/destroy_allinone.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}" )" )" - -source ${SCRIPT_DIR}/functions.sh - -CONFIGURATION="allinone" -CONTROLLER=${CONTROLLER:-controller} -DOMAIN_DIRECTORY=vms - -destroy_controller ${CONFIGURATION} ${CONTROLLER} diff --git a/deployment/libvirt/destroy_configuration.sh b/deployment/libvirt/destroy_configuration.sh new file mode 100755 index 00000000..8d4d3298 --- /dev/null +++ b/deployment/libvirt/destroy_configuration.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}" )" )" + +source ${SCRIPT_DIR}/functions.sh + +while getopts "c:" o; do + case "${o}" in + c) + CONFIGURATION=${OPTARG} + ;; + *) + usage_destroy + exit 1 + ;; + esac +done +shift $((OPTIND-1)) + +if [[ -z ${CONFIGURATION} ]]; then + usage_destroy + exit -1 +fi + +CONFIGURATION=${CONFIGURATION:-allinone} +CONTROLLER=${CONTROLLER:-controller} +DOMAIN_DIRECTORY=vms + +destroy_controller ${CONFIGURATION} ${CONTROLLER} + +if ([ "$CONFIGURATION" == "standardcontroller" ]); then + COMPUTE=${COMPUTE:-compute} + COMPUTE_NODES_NUMBER=${COMPUTE_NODES_NUMBER:-1} + for ((i=0; i<=$COMPUTE_NODES_NUMBER; i++)); do + COMPUTE_NODE=${COMPUTE}-${i} + destroy_compute $COMPUTE_NODE + done +fi diff --git a/deployment/libvirt/destroy_standard_controller.sh b/deployment/libvirt/destroy_standard_controller.sh deleted file mode 100755 index 10e24db9..00000000 --- a/deployment/libvirt/destroy_standard_controller.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash - -SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}" )" )" - -source ${SCRIPT_DIR}/functions.sh - -CONFIGURATION="standardcontroller" -CONTROLLER=${CONTROLLER:-controller} -COMPUTE=${COMPUTE:-compute} -COMPUTE_NODES_NUMBER=${COMPUTE_NODES_NUMBER:-1} -DOMAIN_DIRECTORY=vms - -destroy_controller ${CONFIGURATION} ${CONTROLLER} - -for ((i=0; i<=$COMPUTE_NODES_NUMBER; i++)); do - COMPUTE_NODE=${COMPUTE}-${i} - destroy_compute $COMPUTE_NODE -done diff --git a/deployment/libvirt/functions.sh b/deployment/libvirt/functions.sh index 6ddd7a3a..d9d1664c 100644 --- a/deployment/libvirt/functions.sh +++ b/deployment/libvirt/functions.sh @@ -1,13 +1,22 @@ #!/usr/bin/env bash usage() { - echo "$0 [-h] [-i ]" + echo "$0 [-h] [-c ] [-i ]" echo "" echo "Options:" + echo " -c: Configuration: allinone, standardcontroller" echo " -i: StarlingX ISO image" echo "" } +usage_destroy() { + echo "$0 [-h] [-c ]" + echo "" + echo "Options:" + echo " -c: Configuration: allinone, standardcontroller" + echo "" +} + iso_image_check() { local ISOIMAGE=$1 FILETYPE=$(file --mime-type -b ${ISOIMAGE}) diff --git a/deployment/libvirt/setup_allinone.sh b/deployment/libvirt/setup_allinone.sh deleted file mode 100755 index 11963ddc..00000000 --- a/deployment/libvirt/setup_allinone.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash - -SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}" )" )" -source ${SCRIPT_DIR}/functions.sh - -while getopts "i:" o; do - case "${o}" in - i) - ISOIMAGE=$(readlink -f "$OPTARG") - ;; - *) - usage - exit 1 - ;; - esac -done -shift $((OPTIND-1)) - -if [ -z "${ISOIMAGE}" ]; then - usage - exit -1 -fi - -iso_image_check ${ISOIMAGE} - -CONFIGURATION="allinone" -BRIDGE_INTERFACE=${BRIDGE_INTERFACE:-stxbr} -CONTROLLER=${CONTROLLER:-controller} -DOMAIN_DIRECTORY=vms - -bash ${SCRIPT_DIR}/destroy_allinone.sh - -[ ! -d ${DOMAIN_DIRECTORY} ] && mkdir ${DOMAIN_DIRECTORY} - -create_controller $CONFIGURATION $CONTROLLER $BRIDGE_INTERFACE $ISOIMAGE - -sudo virt-manager diff --git a/deployment/libvirt/setup_standard_controller.sh b/deployment/libvirt/setup_configuration.sh similarity index 60% rename from deployment/libvirt/setup_standard_controller.sh rename to deployment/libvirt/setup_configuration.sh index a164f931..3b17ace7 100755 --- a/deployment/libvirt/setup_standard_controller.sh +++ b/deployment/libvirt/setup_configuration.sh @@ -3,8 +3,11 @@ SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}" )" )" source ${SCRIPT_DIR}/functions.sh -while getopts "i:" o; do +while getopts "c:i:" o; do case "${o}" in + c) + CONFIGURATION="$OPTARG" + ;; i) ISOIMAGE=$(readlink -f "$OPTARG") ;; @@ -16,29 +19,31 @@ while getopts "i:" o; do done shift $((OPTIND-1)) -if [ -z "${ISOIMAGE}" ]; then +if [[ -z ${CONFIGURATION} ]] || [[ -z "${ISOIMAGE}" ]]; then usage exit -1 fi iso_image_check ${ISOIMAGE} -CONFIGURATION="standardcontroller" +CONFIGURATION=${CONFIGURATION:-allinone} BRIDGE_INTERFACE=${BRIDGE_INTERFACE:-stxbr} CONTROLLER=${CONTROLLER:-controller} COMPUTE=${COMPUTE:-compute} COMPUTE_NODES_NUMBER=${COMPUTE_NODES_NUMBER:-1} DOMAIN_DIRECTORY=vms -bash ${SCRIPT_DIR}/destroy_standard_controller.sh +bash ${SCRIPT_DIR}/destroy_configuration.sh -c $CONFIGURATION [ ! -d ${DOMAIN_DIRECTORY} ] && mkdir ${DOMAIN_DIRECTORY} create_controller $CONFIGURATION $CONTROLLER $BRIDGE_INTERFACE $ISOIMAGE -for ((i=0; i<=$COMPUTE_NODES_NUMBER; i++)); do - COMPUTE_NODE=${COMPUTE}-${i} - create_compute ${COMPUTE_NODE} -done +if ([ "$CONFIGURATION" == "standardcontroller" ]); then + for ((i=0; i<=$COMPUTE_NODES_NUMBER; i++)); do + COMPUTE_NODE=${COMPUTE}-${i} + create_compute ${COMPUTE_NODE} + done +fi sudo virt-manager