Merge "ci/deploy.sh, states: bash debug, continue on err"
[fuel.git] / ci / deploy.sh
index 5886a85..f51ba5f 100755 (executable)
@@ -68,7 +68,11 @@ $(notify "Input parameters to the build script are:" 2)
    For an empty value, the deploy script will use virsh to create the default
    expected network (e.g. -B pxe,,,public will use existing "pxe" and "public"
    bridges, respectively create "mgmt" and "internal").
-   The default is pxebr.
+   Note that a virtual network "mcpcontrol" is always created. For virtual
+   deploys, "mcpcontrol" is also used for PXE, leaving the PXE bridge unused.
+   For baremetal deploys, PXE bridge is used for baremetal node provisioning,
+   while "mcpcontrol" is used to provision the infrastructure VMs only.
+   The default is 'pxebr'.
 -h Print this message and exit
 -l Lab name as defined in the configuration directory, e.g. lf
 -p POD name as defined in the configuration directory, e.g. pod-1
@@ -87,7 +91,7 @@ $(notify "Disabled input parameters (not yet supported with MCP):" 3)
 -i (disabled) .iso image to be deployed (needs to be provided in a URI
    style, it can be a local resource: file:// or a remote resource http(s)://)
 
-$(notify "[NOTE] Root priviledges are needed for this script to run" 3)
+$(notify "[NOTE] sudo & virsh priviledges are needed for this script to run" 3)
 
 Example:
 
@@ -130,11 +134,12 @@ clean() {
 SCRIPT_PATH=$(readlink -f "$(dirname "${BASH_SOURCE[0]}")")
 DEPLOY_DIR=$(cd "${SCRIPT_PATH}/../mcp/scripts"; pwd)
 DEPLOY_TYPE='baremetal'
-OPNFV_BRIDGES=('pxe' 'mgmt' 'internal' 'public')
+OPNFV_BRIDGES=('pxebr' 'mgmt' 'internal' 'public')
 URI_REGEXP='(file|https?|ftp)://.*'
 
 export SSH_KEY=${SSH_KEY:-mcp.rsa}
 export SALT_MASTER=${SALT_MASTER_IP:-192.168.10.100}
+export MAAS_IP=${MAAS_IP:-192.168.10.3}
 export SSH_OPTS="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i ${SSH_KEY}"
 
 # Variables below are disabled for now, to be re-introduced or removed later
@@ -244,8 +249,13 @@ do
     esac
 done
 
-if [[ $EUID -ne 0 ]]; then
-    notify "[ERROR] This script must be run as root\n" 1>&2
+if [[ "$(sudo whoami)" != 'root' ]]; then
+    notify "This script requires sudo rights\n" 1>&2
+    exit 1
+fi
+
+if ! virsh list >/dev/null 2>&1; then
+    notify "This script requires hypervisor access\n" 1>&2
     exit 1
 fi
 
@@ -273,16 +283,26 @@ pushd "${DEPLOY_DIR}" > /dev/null
 # scenario, etc.
 
 # Install required packages
-[ -n "$(command -v apt-get)" ] && apt-get install -y \
+[ -n "$(command -v apt-get)" ] && sudo apt-get install -y \
   git make rsync mkisofs curl virtinst cpu-checker qemu-kvm
-[ -n "$(command -v yum)" ] && yum install -y \
+[ -n "$(command -v yum)" ] && sudo yum install -y --skip-broken \
   git make rsync genisoimage curl virt-install qemu-kvm
 
+if [ "$(uname -i)" = "aarch64" ]; then
+  [ -n "$(command -v apt-get)" ] && sudo apt-get install -y vgabios && \
+  sudo ln -sf /usr/share/vgabios/vgabios.bin /usr/share/qemu/vgabios-stdvga.bin
+  [ -n "$(command -v yum)" ] && sudo yum install -y --skip-broken vgabios
+fi
+
 # Check scenario file existence
-if [[ ! -f  ../config/scenario/${DEPLOY_TYPE}/${DEPLOY_SCENARIO}.yaml ]]; then
+if [ ! -f  ../config/scenario/${DEPLOY_TYPE}/${DEPLOY_SCENARIO}.yaml ]; then
     notify "[WARN] ${DEPLOY_SCENARIO}.yaml not found! \
             Setting simplest scenario (os-nosdn-nofeature-noha)\n" 3
     DEPLOY_SCENARIO='os-nosdn-nofeature-noha'
+    if [ ! -f  ../config/scenario/${DEPLOY_TYPE}/${DEPLOY_SCENARIO}.yaml ]; then
+        notify "[ERROR] Scenario definition file is missing!\n" 1>&2
+        exit 1
+    fi
 fi
 
 # Get required infra deployment data
@@ -305,7 +325,7 @@ generate_ssh_key
 prepare_vms virtual_nodes "${base_image}"
 create_networks OPNFV_BRIDGES
 create_vms virtual_nodes virtual_nodes_ram virtual_nodes_vcpus OPNFV_BRIDGES
-update_pxe_network OPNFV_BRIDGES
+update_mcpcontrol_network
 start_vms virtual_nodes
 check_connection
 
@@ -316,7 +336,7 @@ for state in "${cluster_states[@]}"; do
     notify "STATE: ${state}\n" 2
     # shellcheck disable=SC2086,2029
     ssh ${SSH_OPTS} "ubuntu@${SALT_MASTER}" \
-        sudo "/root/fuel/mcp/config/states/${state}"
+        sudo "/root/fuel/mcp/config/states/${state} || true"
 done
 
 popd > /dev/null