Browse Source

Merge pull request #21 from javacruft/configure-refactor

Configure refactor
configure-hook
James Page 3 years ago
committed by GitHub
parent
commit
f79ede2ad0
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 56
      snap-overlay/bin/configure-openstack
  2. 45
      snap/hooks/configure
  3. 258
      snapcraft.yaml

56
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
@ -148,8 +119,25 @@ openstack subnet show test-subnet || {
openstack subnet create --network test --subnet-range 192.168.222.0/24 test-subnet
}
openstack network show external || {
openstack network create --external \
--provider-physical-network=physnet1 \
--provider-network-type=flat external
}
openstack subnet show external-subnet || {
openstack subnet create --network external --subnet-range 10.20.20.0/24 \
--no-dhcp external-subnet
}
openstack router show test-router || {
openstack router create test-router
openstack router add subnet test-router test-subnet
openstack router set --external-gateway external test-router
}
# Glance
echo "glance setup"
echo "Configuring Glance"
openstack user show glance || {
openstack user create --domain default --password glance glance
@ -174,12 +162,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

45
snap/hooks/configure

@ -0,0 +1,45 @@
#!/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"
# Wait for MySQL to startup
while ! nc -z localhost 3306; do sleep 0.1; done;
sleep 5
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 || :

258
snapcraft.yaml

@ -1,10 +1,9 @@
name: microstack
version: rocky
summary: Openstack on your laptop.
summary: OpenStack on your laptop.
description: |
Microstack gives you an easy way to develop and test Openstack
workloads on your laptop. TODO drop in basic usage instructions
here.
Microstack gives you an easy way to develop and test OpenStack
workloads on your laptop.
grade: devel
confinement: classic
environment:
@ -26,191 +25,193 @@ apps:
# Openstack
openstack:
command: openstack
plugs:
- network
configure-openstack:
# plugs:
# - network
# OpenStack Service Configuration
configure:
command: configure-openstack
plugs:
- network
# plugs:
# - network
# Keystone
keystone-uwsgi:
command: snap-openstack keystone-uwsgi
daemon: simple
plugs:
- network-bind
# plugs:
# - network-bind
keystone-manage:
command: snap-openstack keystone-manage
plugs:
- network
# plugs:
# - network
# Nova
nova-uwsgi:
command: snap-openstack nova-uwsgi
daemon: simple
plugs:
- network-bind
# plugs:
# - network-bind
nova-api:
command: snap-openstack nova-api-os-compute
daemon: simple
plugs:
- network-bind
# plugs:
# - network-bind
nova-conductor:
command: snap-openstack nova-conductor
daemon: simple
plugs:
- network
# plugs:
# - network
nova-scheduler:
command: snap-openstack nova-scheduler
daemon: simple
plugs:
- network
# plugs:
# - network
nova-compute:
command: snap-openstack nova-compute
daemon: simple
plugs:
- network-bind
- network-control
- firewall-control
- hardware-observe
- libvirt
- openvswitch
# plugs:
# - network-bind
# - network-control
# - firewall-control
# - hardware-observe
# - libvirt
# - openvswitch
nova-api-metadata:
command: snap-openstack nova-api-metadata
daemon: simple
plugs:
- network-bind
- firewall-control
# plugs:
# - network-bind
# - firewall-control
nova-manage:
command: snap-openstack nova-manage
plugs:
- network
# plugs:
# - network
# Neutron
neutron-api:
command: snap-openstack neutron-server
daemon: simple
plugs:
- network-bind
# plugs:
# - network-bind
neutron-openvswitch-agent:
command: snap-openstack neutron-openvswitch-agent
daemon: simple
plugs:
- network-bind
- network-control
- network-observe
- firewall-control
- process-control
- system-observe
- openvswitch
# plugs:
# - network-bind
# - network-control
# - network-observe
# - firewall-control
# - process-control
# - system-observe
# - openvswitch
neutron-l3-agent:
command: snap-openstack neutron-l3-agent
daemon: simple
plugs:
- network-bind
- network-control
- network-observe
- firewall-control
- process-control
- system-observe
- openvswitch
# plugs:
# - network-bind
# - network-control
# - network-observe
# - firewall-control
# - process-control
# - system-observe
# - openvswitch
neutron-dhcp-agent:
command: snap-openstack neutron-dhcp-agent
daemon: simple
plugs:
- network
- network-bind
- network-control
- network-observe
- process-control
- system-observe
- openvswitch
# plugs:
# - network
# - network-bind
# - network-control
# - network-observe
# - process-control
# - system-observe
# - openvswitch
neutron-metadata-agent:
command: snap-openstack neutron-metadata-agent
daemon: simple
plugs:
- network
- network-bind
- network-control
# plugs:
# - network
# - network-bind
# - network-control
neutron-ovs-cleanup:
command: snap-openstack neutron-ovs-cleanup
plugs:
- network
- network-control
- openvswitch
# plugs:
# - network
# - network-control
# - openvswitch
neutron-netns-cleanup:
command: snap-openstack neutron-netns-cleanup
plugs:
- network
- network-control
# plugs:
# - network
# - network-control
neutron-db-manage:
command: snap-openstack neutron-db-manage
plugs:
- network
# plugs:
# - network
# Glance
glance-api:
command: snap-openstack glance-api
daemon: simple
plugs:
- network-bind
# plugs:
# - network-bind
registry:
command: snap-openstack glance-registry
daemon: simple
plugs:
- network
- network-bind
# plugs:
# - network
# - network-bind
glance-manage:
command: snap-openstack glance-manage
plugs:
- network
# plugs:
# - network
# Openstack Shared Services
nginx:
command: snap-openstack nginx
daemon: forking
plugs:
- network-bind
# plugs:
# - network-bind
# Openvswitch
ovs-vswitchd:
command: ovs-wrapper $SNAP/share/openvswitch/scripts/ovs-ctl --no-ovsdb-server --no-monitor --system-id=random start
stop-command: ovs-wrapper $SNAP/share/openvswitch/scripts/ovs-ctl --no-ovsdb-server stop
daemon: forking
plugs:
- network
- network-bind
- network-control
- openvswitch-support
- process-control
- system-trace
# plugs:
# - network
# - network-bind
# - network-control
# - openvswitch-support
# - process-control
# - system-trace
ovsdb-server:
command: ovs-wrapper $SNAP/share/openvswitch/scripts/ovs-ctl --no-ovs-vswitchd --no-monitor --system-id=random start
stop-command: ovs-wrapper $SNAP/share/openvswitch/scripts/ovs-ctl --no-ovs-vswitchd stop
daemon: forking
plugs:
- network
- network-bind
- network-control
- openvswitch-support
- process-control
- system-trace
# plugs:
# - network
# - network-bind
# - network-control
# - openvswitch-support
# - process-control
# - system-trace
ovs-vsctl:
command: ovs-wrapper $SNAP/bin/ovs-vsctl
plugs:
- network
# plugs:
# - network
ovs-appctl:
command: ovs-wrapper $SNAP/bin/ovs-appctl
plugs:
- network
# plugs:
# - network
ovs-ofctl:
command: ovs-wrapper $SNAP/bin/ovs-ofctl
plugs:
- network
# plugs:
# - network
ovs-dpctl:
command: ovs-wrapper $SNAP/bin/ovs-dpctl
plugs:
- network
# plugs:
# - network
# Libvirt/Qemu
libvirtd:
@ -221,33 +222,32 @@ apps:
virsh:
command: virsh
# MySQL
# MySQL
mysqld:
command: mysql-start-server
daemon: simple
plugs:
- process-control
- network
- network-bind
# plugs:
# - process-control
# - network
# - network-bind
mysql:
command: mysql-start-client
plugs:
- process-control
- network
# plugs:
# - process-control
# - network
# RabbitMQ
rabbitmq-server:
command: rabbitmq-server
daemon: simple
plugs:
- network-bind
# plugs:
# - network-bind
environment:
HOME: $SNAP_COMMON/lib/rabbitmq
rabbitmqctl:
command: rabbitmqctl
plugs:
- network
# plugs:
# - network
environment:
HOME: $SNAP_COMMON/lib/rabbitmq
rabbitmq-plugins:
@ -259,41 +259,41 @@ apps:
memcached:
command: memcached -u root -v
daemon: simple
plugs:
- network-bind
# plugs:
# - network-bind
# Cinder
cinder-uwsgi:
command: snap-openstack cinder-uwsgi
# daemon: simple
plugs:
- network-bind
# plugs:
# - network-bind
cinder-backup:
command: snap-openstack cinder-backup
# daemon: simple
plugs:
- network
# plugs:
# - network
cinder-manage:
command: snap-openstack cinder-manage
plugs:
- network
# plugs:
# - network
cinder-scheduler:
command: snap-openstack cinder-scheduler
# daemon: simple
plugs:
- network
# plugs:
# - network
cinder-volume:
command: snap-openstack cinder-volume
# daemon: simple
plugs:
- network
# plugs:
# - network
# Horizon
horizon-uwsgi:
command: snap-openstack horizon-uwsgi
daemon: simple
plugs:
- network-bind
# plugs:
# - network-bind
parts:
# OpenStack Python Projects, keyed off Keystone

Loading…
Cancel
Save