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.
 
 
 
 

172 lines
5.0 KiB

#!/bin/bash -e
# Keystone
echo "Configuring Keystone"
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://10.20.20.1:5000/v3/ \
--bootstrap-internal-url http://10.20.20.1:5000/v3/ \
--bootstrap-public-url http://10.20.20.1:5000/v3/ \
--bootstrap-region-id microstack
}
openstack project show service || {
openstack project create --domain default --description "Service Project" service
}
# Nova
echo "Configuring Nova"
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 microstack \
compute $endpoint http://10.20.20.1: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 microstack \
placement $endpoint http://10.20.20.1: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 10.20.20.1 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 "Configuring Neutron"
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 microstack \
network $endpoint http://10.20.20.1:9696 || :
done
}
snap-openstack neutron-db-manage upgrade head
systemctl restart snap.microstack.neutron-*
while ! nc -z 10.20.20.1 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
}
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"
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 microstack \
image $endpoint http://10.20.20.1:9292 || :
done
}
snap-openstack glance-manage db_sync
systemctl restart snap.microstack.glance*
while ! nc -z 10.20.20.1 9292; do sleep 0.1; done;
sleep 5
openstack image show cirros || {
[ -f $HOME/images/cirros-0.3.5-x86_64-disk.img ] || {
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
}
openstack image create --file ${HOME}/images/cirros-0.3.5-x86_64-disk.img \
--public --container-format=bare --disk-format=qcow2 cirros
}