From 58b4650cf4077425800edc4707e026892a71cbd1 Mon Sep 17 00:00:00 2001 From: James Page Date: Tue, 6 Nov 2018 10:01:54 +0000 Subject: [PATCH 1/6] Split service configuration from configure hook --- snap-overlay/bin/configure-openstack | 39 +++------------------------- snap/hooks/configure | 30 +++++++++++++++++++++ snapcraft.yaml | 4 ++- 3 files changed, 37 insertions(+), 36 deletions(-) create mode 100755 snap/hooks/configure diff --git a/snap-overlay/bin/configure-openstack b/snap-overlay/bin/configure-openstack index ae3ec02..c742912 100755 --- a/snap-overlay/bin/configure-openstack +++ b/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 diff --git a/snap/hooks/configure b/snap/hooks/configure new file mode 100755 index 0000000..b3b0e14 --- /dev/null +++ b/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 ".*" ".*" ".*" diff --git a/snapcraft.yaml b/snapcraft.yaml index cc8b503..844f266 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -28,7 +28,9 @@ apps: command: openstack plugs: - network - configure-openstack: + + # OpenStack Service Configuration + configure: command: configure-openstack plugs: - network From 3529ff2786027cc8ef4ef15ade511ee75601fe7e Mon Sep 17 00:00:00 2001 From: James Page Date: Tue, 6 Nov 2018 10:09:35 +0000 Subject: [PATCH 2/6] Tidy descriptions --- snapcraft.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/snapcraft.yaml b/snapcraft.yaml index 844f266..549af30 100644 --- a/snapcraft.yaml +++ b/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: From 2129058ec023314fb7becf3d8b90ec1ab610ad34 Mon Sep 17 00:00:00 2001 From: James Page Date: Tue, 6 Nov 2018 10:18:27 +0000 Subject: [PATCH 3/6] Drop plugs for the time being until we have proper confinement - commented out of easier re-introduction --- snapcraft.yaml | 247 ++++++++++++++++++++++++------------------------- 1 file changed, 123 insertions(+), 124 deletions(-) diff --git a/snapcraft.yaml b/snapcraft.yaml index 549af30..24c8269 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -25,193 +25,193 @@ apps: # Openstack openstack: command: openstack - plugs: - - network +# 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: @@ -222,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: @@ -260,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 From dc4cb0533e295d78f0fdc7ecd5dd5607524f9282 Mon Sep 17 00:00:00 2001 From: James Page Date: Tue, 6 Nov 2018 10:53:40 +0000 Subject: [PATCH 4/6] Wait for mysql --- snap/hooks/configure | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/snap/hooks/configure b/snap/hooks/configure index b3b0e14..dbacc37 100755 --- a/snap/hooks/configure +++ b/snap/hooks/configure @@ -9,6 +9,11 @@ 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 From 6077a6fe80d1f91ae7f6c7115dcc832f70dd036d Mon Sep 17 00:00:00 2001 From: James Page Date: Tue, 6 Nov 2018 11:55:56 +0000 Subject: [PATCH 5/6] Create br-ex for floating IP networking --- snap/hooks/configure | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/snap/hooks/configure b/snap/hooks/configure index dbacc37..a2e9af0 100755 --- a/snap/hooks/configure +++ b/snap/hooks/configure @@ -31,5 +31,15 @@ do 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 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 || : From 5f2d12c30623ee62e4accf47afc43b7768be94fb Mon Sep 17 00:00:00 2001 From: James Page Date: Tue, 6 Nov 2018 12:03:32 +0000 Subject: [PATCH 6/6] Add router and external network configuration --- snap-overlay/bin/configure-openstack | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/snap-overlay/bin/configure-openstack b/snap-overlay/bin/configure-openstack index c742912..b00b49e 100755 --- a/snap-overlay/bin/configure-openstack +++ b/snap-overlay/bin/configure-openstack @@ -119,6 +119,23 @@ 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 "Configuring Glance"