Allow to specify which image to create VM from
Since we already have a job for automatic image upload, we don't need to do it here. Also remove unused arguments from usage(). Change-Id: I3616b9dba6221228c0bd7b62d5f5a93f65730d34
This commit is contained in:
parent
cb9d9d85ae
commit
992ebc7920
@ -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
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user