#!/bin/bash
SERVERNAME=coreos
echo "Creating VM ${SERVERNAME}"

nova boot ${SERVERNAME} \
--image CoreOS-1068 \
--availability-zone nuczone \
--user-data ${SERVERNAME}.yaml \
--key-name "Sebastian Rojo" \
--flavor m1.medium.md \
--min-count 1 \
--max-count 3 \
--security-groups default,docker,CoreOS \
--nic net-id=7a9ae8e9-8425-4084-94cc-fb70c069e957

for RUN in {1..50}; do
    if [ "$(nova show ${SERVERNAME} | awk '/status/ {print $4}')" == "ACTIVE" ]
    then
      nova show ${SERVERNAME}
      exit 0
    else
      echo "VM ${SERVERNAME} is not active yet"
      sleep 2
    fi
done
