0399955cf1
Moved security rules and keypair creation into init first. Launch script now takes image name as positional argument, and name of instance as a named argument. This makes it work more like launch in other Canonical tools. Written in Python, for ease of maintenance. --retry and --wait args allow it to behave like tests expect it to, while humans will get a much more intuitive (and much less noisy) experience. Also increased time we wait for a ping on the host, to allow for slower, pure qemu, emulation times, and bring it in line with what Tempest does in similar situations. Change-Id: I11dcc098012468e9c88dcc7af78cde6920f31ecd
57 lines
1.7 KiB
Bash
Executable File
57 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
# Check for microstack.init. TODO: just run microstack.init ...
|
|
if ! [ "$(snapctl get initialized)" == "true" ]; then
|
|
echo "Microstack is not initialized. Please run microstack.init!"
|
|
exit 1;
|
|
fi
|
|
|
|
source $SNAP_COMMON/etc/microstack.rc
|
|
|
|
if [ -z "$1" ]; then
|
|
echo "Please specify a name for the server."
|
|
exit 1
|
|
else
|
|
SERVER=$1
|
|
fi
|
|
|
|
echo "Launching instance ..."
|
|
openstack server create --flavor m1.tiny --image cirros --nic net-id=test --key-name microstack $SERVER
|
|
|
|
TRIES=0
|
|
while [[ $(openstack server list | grep $SERVER | grep ERROR) ]]; do
|
|
TRIES=$(($TRIES + 1))
|
|
if test $TRIES -gt 3; then
|
|
break
|
|
fi
|
|
echo "I ran into an issue launching an instance. Retrying ... (try $TRIES of 3)"
|
|
openstack server delete $SERVER
|
|
openstack server create --flavor m1.tiny --image cirros --nic net-id=test --key-name microstack $SERVER
|
|
while [[ $(openstack server list | grep $SERVER | grep BUILD) ]]; do
|
|
sleep 1;
|
|
done
|
|
done
|
|
|
|
echo "Allocating floating ip ..."
|
|
ALLOCATED_FIP=`openstack floating ip create -f value -c floating_ip_address external`
|
|
openstack server add floating ip $SERVER $ALLOCATED_FIP
|
|
|
|
echo "Waiting for server to become ACTIVE."
|
|
while :; do
|
|
if [[ $(openstack server list | grep $SERVER | grep ACTIVE) ]]; then
|
|
openstack server list
|
|
echo "Access your server with 'ssh -i $HOME/.ssh/id_microstack cirros@$ALLOCATED_FIP'"
|
|
break
|
|
fi
|
|
if [[ $(openstack server list | grep $SERVER | grep ERROR) ]]; then
|
|
openstack server list
|
|
echo "Uh-oh. There was an error. Run `journalctl -xe` for details."
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
extgateway=`snapctl get questions.ext-gateway`
|
|
echo "You can also visit the openstack dashboard at 'http://$extgateway/'"
|