This patch removed the bespoke "vm_manager.sh" script in favor of a Multi-Machine Vagrantfile. With this the users needs to only change the variables in Vagrantfile then use the standard `vagrant` commands to launch the VMs/Runners. Change-Id: Ida5d2701319fd844c6a5b6fa7baf0c48b67db975
44 lines
1.6 KiB
Bash
Executable File
44 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
NUM_RUNNERS=20
|
|
NUM_BUILDERS=3
|
|
RUNNER_PREFIX="$(hostname)-runner-"
|
|
BUILDER_PREFIX="$(hostname)-builder-"
|
|
|
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
|
export VAGRANT_HOME=${SCRIPT_DIR}
|
|
|
|
param="up"
|
|
if [[ $# -ge 1 ]]; then
|
|
param=$1
|
|
if [[ "${param}" != "destroy" ]] && [[ "${param}" != "shutdown" ]]; then
|
|
echo "Only valid parameters are 'destroy' and 'shutdown' to destroy all VMs or shutdown all VMs"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
|
|
for (( i=1; i<=NUM_RUNNERS; i++ )); do
|
|
sed -i "s/ config.vm.define.*/ config.vm.define \"${RUNNER_PREFIX}${i}\"/g" Vagrantfile-runner
|
|
sed -i "s/ config.vm.hostname.*/ config.vm.hostname = \"${RUNNER_PREFIX}${i}\"/g" Vagrantfile-runner
|
|
if [[ "${param}" == "destroy" ]]; then
|
|
VAGRANT_VAGRANTFILE=Vagrantfile-runner vagrant destroy -f
|
|
elif [[ "${param}" == "shutdown" ]]; then
|
|
VAGRANT_VAGRANTFILE=Vagrantfile-runner vagrant halt -f
|
|
else
|
|
VAGRANT_VAGRANTFILE=Vagrantfile-runner vagrant up --provider=libvirt
|
|
fi
|
|
done
|
|
|
|
for (( i=1; i<=NUM_BUILDERS; i++ )); do
|
|
sed -i "s/ config.vm.define.*/ config.vm.define \"${BUILDER_PREFIX}${i}\"/g" Vagrantfile-builder
|
|
sed -i "s/ config.vm.hostname.*/ config.vm.hostname = \"${BUILDER_PREFIX}${i}\"/g" Vagrantfile-builder
|
|
if [[ "${param}" == "destroy" ]]; then
|
|
VAGRANT_VAGRANTFILE=Vagrantfile-builder vagrant destroy -f
|
|
elif [[ "${param}" == "shutdown" ]]; then
|
|
VAGRANT_VAGRANTFILE=Vagrantfile-builder vagrant halt -f
|
|
else
|
|
VAGRANT_VAGRANTFILE=Vagrantfile-builder vagrant up --provider=libvirt
|
|
fi
|
|
done
|