OpenStack in a snap!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

186 lines
5.7 KiB

#!/bin/bash -e
# Install conf.d configuration from snap for db etc
for project in neutron nova keystone glance; do
mkdir -p ${SNAP_COMMON}/etc/${project}/${project}.conf.d
cp -r ${SNAP}/etc/${project}/${project}.conf.d/* ${SNAP_COMMON}/etc/${project}/${project}.conf.d
done
# Create all of the databases
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 "rabbit setup"
export HOME=$SNAP_COMMON/lib/rabbitmq # TODO: unset this?
# Rabbitmq isn't always started when we run this. Wait for it to start.
# TODO: develop this a bit more -- not 100% that this does what we want.
while :;
do
grep "Starting broker... completed" /var/snap/microstack/common/log/rabbitmq/startup_log && break
echo "waiting for rabbitmq to start" && sleep 1;
done
rabbitmqctl add_user openstack rabbitmq || true
rabbitmqctl set_permissions openstack ".*" ".*" ".*"
# Keystone
echo "keystone setup"
snap-openstack keystone-manage fernet_setup --keystone-user root --keystone-group root
snap-openstack keystone-manage db_sync
systemctl restart snap.microstack.keystone-*
openstack user show admin || {
snap-openstack keystone-manage bootstrap \
--bootstrap-password $OS_PASSWORD \
--bootstrap-admin-url http://localhost:5000/v3/ \
--bootstrap-internal-url http://localhost:5000/v3/ \
--bootstrap-public-url http://localhost:5000/v3/ \
--bootstrap-region-id RegionOne
}
openstack project show service || {
openstack project create --domain default --description "Service Project" service
}
# Nova
echo "nova setup"
openstack user show nova || {
openstack user create --domain default --password nova nova
openstack role add --project service --user nova admin
}
openstack user show placement || {
openstack user create --domain default --password placement placement
openstack role add --project service --user placement admin
}
openstack service show compute || {
openstack service create --name nova \
--description "OpenStack Compute" compute
for endpoint in public internal admin; do
openstack endpoint create --region RegionOne \
compute $endpoint http://localhost:8774/v2.1 || :
done
}
openstack service show placement || {
openstack service create --name placement \
--description "Placement API" placement
for endpoint in public internal admin; do
openstack endpoint create --region RegionOne \
placement $endpoint http://localhost:8778 || :
done
}
snap-openstack nova-manage api_db sync
snap-openstack nova-manage cell_v2 list_cells | grep cell0 || {
snap-openstack nova-manage cell_v2 map_cell0
}
snap-openstack nova-manage cell_v2 list_cells | grep cell1 || {
snap-openstack nova-manage cell_v2 create_cell --name=cell1 --verbose
}
snap-openstack nova-manage db sync
systemctl restart snap.microstack.nova-*
while ! nc -z localhost 8774; do sleep 0.1; done;
sleep 5
openstack flavor show m1.tiny || {
openstack flavor create --id 1 --ram 512 --disk 1 --vcpus 1 m1.tiny
}
openstack flavor show m1.small || {
openstack flavor create --id 2 --ram 2048 --disk 20 --vcpus 1 m1.small
}
openstack flavor show m1.medium || {
openstack flavor create --id 3 --ram 4096 --disk 20 --vcpus 2 m1.medium
}
openstack flavor show m1.large || {
openstack flavor create --id 4 --ram 8192 --disk 20 --vcpus 4 m1.large
}
openstack flavor show m1.xlarge || {
openstack flavor create --id 5 --ram 16384 --disk 20 --vcpus 8 m1.xlarge
}
# Neutron
echo "neutron setup"
openstack user show neutron || {
openstack user create --domain default --password neutron neutron
openstack role add --project service --user neutron admin
}
openstack service show network || {
openstack service create --name neutron \
--description "OpenStack Network" network
for endpoint in public internal admin; do
openstack endpoint create --region RegionOne \
network $endpoint http://localhost:9696 || :
done
}
snap-openstack neutron-db-manage upgrade head
systemctl restart snap.microstack.neutron-*
while ! nc -z localhost 9696; do sleep 0.1; done;
sleep 5
openstack network show test || {
openstack network create test
}
openstack subnet show test-subnet || {
openstack subnet create --network test --subnet-range 192.168.222.0/24 test-subnet
}
# Glance
echo "glance setup"
openstack user show glance || {
openstack user create --domain default --password glance glance
openstack role add --project service --user glance admin
}
openstack service show image || {
openstack service create --name glance --description "OpenStack Image" image
for endpoint in internal admin public; do
openstack endpoint create --region RegionOne \
image $endpoint http://localhost:9292 || :
done
}
snap-openstack glance-manage db_sync
systemctl restart snap.microstack.glance*
while ! nc -z localhost 9292; do sleep 0.1; done;
sleep 5
openstack image show cirros || {
[ -f $HOME/images/cirros-0.3.5-x86_64-disk.img ] || {
export http_proxy=$SNAPSTACK_HTTP_PROXY
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
unset http_proxy
}
openstack image create --file ${HOME}/images/cirros-0.3.5-x86_64-disk.img \
--public --container-format=bare --disk-format=qcow2 cirros
}