diff --git a/tools/deploy-test-vms.sh b/tools/deploy-test-vms.sh index db41ddc9..9c4b7923 100755 --- a/tools/deploy-test-vms.sh +++ b/tools/deploy-test-vms.sh @@ -6,12 +6,13 @@ set -e usage() { cat << EOF - Usage: $0 -a (create|destroy) [-c] [-n NUBER_OF_VMs] [-i PUBLIC_ETH_IFACE] + Usage: $0 -a (create|destroy) [-n NUBER_OF_VMs] [-i IMAGE] -h Prints this help -a Required action. Choise from "create" and "destroy" -n Number of VMs to spawn (optional) -k Kubernetes namespace (optional) + -i Image to boot VMs from (optional, will upload Cirros if ommited) EOF } @@ -32,11 +33,14 @@ create() { NUMBER=2 fi - curl -o /tmp/cirros.img http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img - openstack image create --disk-format qcow2 --public --file /tmp/cirros.img cirros - rm -f /tmp/cirros.img + if [ -z "${IMAGE}" ]; then + IMAGE=cirros + curl -o /tmp/cirros.img http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img + openstack image create --disk-format qcow2 --public --file /tmp/cirros.img cirros + rm -f /tmp/cirros.img + fi NETID="$(openstack network show int-net -f value -c id)" - openstack server create --flavor m1.tiny --image cirros --nic net-id="$NETID" --min $NUMBER --max $NUMBER --wait test_vm + openstack server create --flavor m1.tiny --image "${IMAGE}" --nic net-id="$NETID" --min $NUMBER --max $NUMBER --wait test_vm openstack server list for vm in $(openstack server list -f value -c Name | grep test_vm); do echo "Console for $vm:" @@ -53,7 +57,7 @@ destroy() { openstack image delete cirros } -while getopts ":a:n:k:h" opt; do +while getopts ":a:n:k:i:h" opt; do case $opt in a) ACTION="$OPTARG" @@ -64,6 +68,9 @@ while getopts ":a:n:k:h" opt; do k) K8S_NAMESPACE="$OPTARG" ;; + i) + IMAGE="$OPTARG" + ;; h) usage exit 1