Browse Source

Split service configuration from configure hook

configure-hook
James Page 3 years ago
parent
commit
58b4650cf4
  1. 39
      snap-overlay/bin/configure-openstack
  2. 30
      snap/hooks/configure
  3. 4
      snapcraft.yaml

39
snap-overlay/bin/configure-openstack

@ -1,36 +1,7 @@
#!/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"
echo "Configuring Keystone"
snap-openstack keystone-manage fernet_setup --keystone-user root --keystone-group root
snap-openstack keystone-manage db_sync
@ -51,7 +22,7 @@ openstack project show service || {
}
# Nova
echo "nova setup"
echo "Configuring Nova"
openstack user show nova || {
openstack user create --domain default --password nova nova
@ -115,7 +86,7 @@ openstack flavor show m1.xlarge || {
}
# Neutron
echo "neutron setup"
echo "Configuring Neutron"
openstack user show neutron || {
openstack user create --domain default --password neutron neutron
@ -149,7 +120,7 @@ openstack subnet show test-subnet || {
}
# Glance
echo "glance setup"
echo "Configuring Glance"
openstack user show glance || {
openstack user create --domain default --password glance glance
@ -174,12 +145,10 @@ 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

30
snap/hooks/configure

@ -0,0 +1,30 @@
#!/bin/bash -e
# Install conf.d configuration from snap for db etc
echo "Installing configuration for OpenStack Services"
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
echo "Creating OpenStack 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 "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 || true
HOME=$SNAP_COMMON/lib/rabbitmq rabbitmqctl set_permissions openstack ".*" ".*" ".*"

4
snapcraft.yaml

@ -28,7 +28,9 @@ apps:
command: openstack
plugs:
- network
configure-openstack:
# OpenStack Service Configuration
configure:
command: configure-openstack
plugs:
- network

Loading…
Cancel
Save