Files
microstack/snap/hooks/configure
Pete Vander Giessen 454fd38526 Fix instance errors (#34)
* Fix some common errors when starting up.

Added more polls for services that we want to make sure are up and running.

Fixed issue where launch script wouldn't run when /snap/bin wasn't in the PATH.

* Added very basic resiliance to launch.sh script.

Tears down a machine and attempts to rebuild it if the build drops into an error state.
2018-11-14 11:14:30 +01:00

63 lines
1.9 KiB
Bash
Executable File

#!/bin/bash -e
# Create all of the databases
echo "Creating OpenStack Databases"
# Wait for MySQL to startup
while ! nc -z localhost 3306; do sleep 0.1; done;
sleep 5
# Wait for rabbitmq to start
while ! nc -z localhost 5672; do sleep 0.1; done;
for db in neutron nova nova_api nova_cell0 cinder glance keystone; do
echo "CREATE DATABASE IF NOT EXISTS ${db}; GRANT ALL PRIVILEGES ON ${db}.* TO '${db}'@'localhost' IDENTIFIED BY '${db}';" \
| mysql-start-client -u root
done
# Grant nova user access to cell0
echo "GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'localhost' IDENTIFIED BY 'nova';" | mysql-start-client -u root
# RabbitMQ
echo "Configuring RabbitMQ"
# Rabbitmq isn't always started when we run this. Wait for it to start.
while :;
do
grep "Starting broker... completed" ${SNAP_COMMON}/log/rabbitmq/startup_log && break
echo "waiting for rabbitmq to start" && sleep 1;
done
HOME=$SNAP_COMMON/lib/rabbitmq rabbitmqctl add_user openstack rabbitmq || :
HOME=$SNAP_COMMON/lib/rabbitmq rabbitmqctl set_permissions openstack ".*" ".*" ".*"
# Open vSwitch/Neutron
echo "Configuring Open vSwitch networking"
# Create external integration bridge
ovs-vsctl --retry --may-exist add-br br-ex
# Configure br-ex
ip address add 10.20.20.1/24 dev br-ex || :
ip link set br-ex up || :
while ! nc -z localhost 9292; do sleep 0.1; done;
sleep 5
# Wait for identity service
while ! nc -z localhost 5000; do sleep 0.1; done;
openstack image show cirros || {
[ -f $HOME/images/cirros-0.3.5-x86_64-disk.img ] || {
mkdir -p $HOME/images
wget \
http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img \
-O ${HOME}/images/cirros-0.3.5-x86_64-disk.img
}
openstack image create --file ${HOME}/images/cirros-0.3.5-x86_64-disk.img \
--public --container-format=bare --disk-format=qcow2 cirros
}
# Wait for horizon
while ! nc -z localhost 80; do sleep 0.1; done;