Browse Source

Populated configure hook.

Moved configure-the-things.sh code into configure hook.

Updated references to executables that can be found inside of the snap context.

Fixed up rabbitmq issues (possibly).
configure-hook
Pete Vander Giessen 3 years ago
parent
commit
0ac9b0079e
  1. 174
      snap/hooks/configure

174
snap/hooks/configure

@ -21,24 +21,47 @@ if [[ $driver != $driver_saved ]]; then
snapctl restart $SNAP_NAME
fi
# MySQL Setup
MYSQL_PASSWORD=fnord # TODO use snapctl
# 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
echo "ALTER USER 'root'@'localhost' IDENTIFIED BY 'fnord';" | mysql-start-client -u root
# 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
# Keystone Setup
echo "CREATE DATABASE IF NOT EXISTS keystone; GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY 'keystone';" | mysql-start-client -u root -p"$MYSQL_PASSWORD"
# 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
sudo systemctl restart snap.microstack.*
systemctl restart snap.microstack.keystone-*
openstack user show admin || {
snap-openstack keystone-manage bootstrap \
--bootstrap-password $OS_PASSWORD \
--bootstrap-admin-url http://localhost:35357/v3/ \
--bootstrap-internal-url http://localhost:35357/v3/ \
--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
}
@ -47,3 +70,138 @@ 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
}
# TODO correct naming of manage script
snap-openstack neutron-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
}
Loading…
Cancel
Save