-
-
Save syffs/4d4ac063526b46f8f486bde22fabb679 to your computer and use it in GitHub Desktop.
Openstack kolla 3.0.1 (/usr/share/kolla/init-runonce) init env udpated with more images, better specs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# This script is meant to be run once after running start for the first | |
# time. This script downloads a cirros image and registers it. Then it | |
# configures networking and nova quotas to allow 40 m1.small instances | |
# to be created. | |
# Sanitize language settings to avoid commands bailing out | |
# with "unsupported locale setting" errors. | |
unset LANG | |
unset LANGUAGE | |
LC_ALL=C | |
export LC_ALL | |
for i in curl nova neutron openstack; do | |
if [[ ! $(type $i 2>/dev/null) ]]; then | |
if [ "$i" == 'curl' ]; then | |
echo "$i not installed. Please install $i before proceeding" | |
else | |
echo "python-${i}client not installed. Please install python-${i}client before proceeding" | |
fi | |
exit | |
fi | |
done | |
# Move to top level directory | |
REAL_PATH=$(python -c "import os,sys;print os.path.realpath('$0')") | |
cd "$(dirname "$REAL_PATH")/.." | |
NETWORK_MANAGER="neutron" | |
# Test for credentials set | |
if [[ "${OS_USERNAME}" == "" ]]; then | |
echo "No Keystone credentials specified. Try running source openrc" | |
exit | |
fi | |
# Test to ensure configure script is run only once | |
if glance image-list | grep -q cirros; then | |
echo "This tool should only be run once per deployment." | |
exit | |
fi | |
echo Downloading glance image. | |
IMAGE_URL=http://download.cirros-cloud.net/0.3.4 | |
IMAGE=cirros-0.3.4-x86_64-disk.img | |
if ! [ -f "$IMAGE" ]; then | |
curl -L -o ./$IMAGE $IMAGE_URL/$IMAGE | |
fi | |
echo Creating CirrOS glance image. | |
glance image-create --name cirros-0.3.4 --progress --disk-format qcow2 --container-format bare --visibility public --file ./$IMAGE | |
IMAGE_URL=https://stable.release.core-os.net/amd64-usr/1185.5.0 | |
IMAGE_TMP=coreos_production_openstack_image.img.bz2 | |
IMAGE=coreos_production_openstack_image.img | |
if ! [ -f "$IMAGE" ]; then | |
curl -L -o ./$IMAGE_TMP $IMAGE_URL/$IMAGE_TMP | |
bunzip2 ./$IMAGE_TMP | |
rm -f ./$IMAGE_TMP | |
fi | |
echo Creating CoreOS glance image. | |
glance image-create --name coreos-1185.5.0 --progress --disk-format qcow2 --container-format bare --visibility public --file ./$IMAGE | |
IMAGE_URL=http://cloud-images.ubuntu.com/xenial/current | |
IMAGE=xenial-server-cloudimg-amd64-disk1.img | |
if ! [ -f "$IMAGE" ]; then | |
curl -L -o ./$IMAGE $IMAGE_URL/$IMAGE | |
fi | |
echo Creating Ubuntu-16.04LTS glance image. | |
glance image-create --name ubuntu-16.04lts --progress --disk-format qcow2 --container-format bare --visibility public --file ./$IMAGE | |
#http://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.img | |
IMAGE_URL=http://cloud-images.ubuntu.com/trusty/current | |
IMAGE=trusty-server-cloudimg-amd64-disk1.img | |
if ! [ -f "$IMAGE" ]; then | |
curl -L -o ./$IMAGE $IMAGE_URL/$IMAGE | |
fi | |
echo Creating Ubuntu-14.04LTS glance image. | |
glance image-create --name ubuntu-14.04lts --progress --disk-format qcow2 --container-format bare --visibility public --file ./$IMAGE | |
IMAGE_URL=http://cloud.centos.org/centos/7/images | |
IMAGE=CentOS-7-x86_64-GenericCloud.qcow2 | |
if ! [ -f "$IMAGE" ]; then | |
curl -L -o ./$IMAGE $IMAGE_URL/$IMAGE | |
fi | |
echo Creating CentOS-7 glance image. | |
glance image-create --name centos-7 --progress --disk-format qcow2 --container-format bare --visibility public --file ./$IMAGE | |
#http://cloud.centos.org/centos/6/images/CentOS-6-x86_64-GenericCloud.qcow2 | |
IMAGE_URL=http://cloud.centos.org/centos/6/images | |
IMAGE=CentOS-6-x86_64-GenericCloud.qcow2 | |
if ! [ -f "$IMAGE" ]; then | |
curl -L -o ./$IMAGE $IMAGE_URL/$IMAGE | |
fi | |
echo Creating CentOS-6 glance image. | |
glance image-create --name centos-6 --progress --disk-format qcow2 --container-format bare --visibility public --file ./$IMAGE | |
#https://download.fedoraproject.org/pub/alt/atomic/stable/Fedora-Atomic-25-20161221.0/CloudImages/x86_64/images/Fedora-Atomic-25-20161221.0.x86_64.qcow2 | |
IMAGE_URL=https://download.fedoraproject.org/pub/alt/atomic/stable/Fedora-Atomic-25-20161221.0/CloudImages/x86_64/images | |
IMAGE=Fedora-Atomic-25-20161221.0.x86_64.qcow2 | |
if ! [ -f "$IMAGE" ]; then | |
curl -L -o ./$IMAGE $IMAGE_URL/$IMAGE | |
fi | |
echo Creating Fedora-25 glance image. | |
glance image-create --name fedora-25 --progress --disk-format qcow2 --container-format bare --visibility public --file ./$IMAGE | |
#http://cdimage.debian.org/cdimage/openstack/current/debian-8.6.3-20161129-openstack-amd64.qcow2 | |
IMAGE_URL=http://cdimage.debian.org/cdimage/openstack/current | |
IMAGE=debian-8.6.3-20161129-openstack-amd64.qcow2 | |
if ! [ -f "$IMAGE" ]; then | |
curl -L -o ./$IMAGE $IMAGE_URL/$IMAGE | |
fi | |
echo Creating Debian-8.6.3 glance image. | |
glance image-create --name debian-8.6.3 --progress --disk-format qcow2 --container-format bare --visibility public --file ./$IMAGE | |
if [[ "${NETWORK_MANAGER}" == "nova" ]] ; then | |
echo Configuring nova networking. | |
nova secgroup-add-rule default tcp 22 22 0.0.0.0/0 | |
nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0 | |
nova network-create vmnet --fixed-range-v4=10.0.0.0/24 --bridge=br100 --multi-host=T | |
else | |
echo Configuring neutron. | |
neutron net-create public --router:external --provider:physical_network physnet1 --provider:network_type flat | |
neutron subnet-create --name livebox --allocation-pool start=192.168.1.101,end=192.168.1.200 public1 192.168.1.0/24 --gateway 192.168.1.1 --dns-nameserver 192.168.1.1 --dns-nameserver 8.8.8.8 | |
neutron net-create demo-net --provider:network_type vxlan | |
neutron subnet-create demo-net 10.0.0.0/24 --name demo-subnet --gateway 10.0.0.1 --dns-nameservers list=true 8.8.8.8 | |
neutron router-create demo-router | |
neutron router-interface-add demo-router demo-subnet | |
neutron router-gateway-set demo-router public1 | |
# Sec Group Config | |
neutron security-group-rule-create default --direction ingress --ethertype IPv4 --protocol icmp --remote-ip-prefix 0.0.0.0/0 | |
neutron security-group-rule-create default --direction ingress --ethertype IPv4 --protocol tcp --port-range-min 22 --port-range-max 22 --remote-ip-prefix 0.0.0.0/0 | |
# Open heat-cfn so it can run on a different host | |
neutron security-group-rule-create default --direction ingress --ethertype IPv4 --protocol tcp --port-range-min 8000 --port-range-max 8000 --remote-ip-prefix 0.0.0.0/0 | |
neutron security-group-rule-create default --direction ingress --ethertype IPv4 --protocol tcp --port-range-min 8080 --port-range-max 8080 --remote-ip-prefix 0.0.0.0/0 | |
fi | |
if [ -r ~/.ssh/id_rsa.pub ]; then | |
echo Configuring nova public key and quotas. | |
nova keypair-add --pub-key ~/.ssh/id_rsa.pub mykey | |
fi | |
# Increase the quota to allow 40 m1.small instances to be created | |
# Get admin user and tenant IDs | |
ADMIN_USER_ID=$(openstack user list | awk '/ admin / {print $2}') | |
ADMIN_PROJECT_ID=$(openstack project list | awk '/ admin / {print $2}') | |
# 40 instances | |
nova quota-update --instances 40 $ADMIN_PROJECT_ID | |
nova quota-update --user $ADMIN_USER_ID --instances 40 $ADMIN_PROJECT_ID | |
# 40 cores | |
nova quota-update --cores 40 $ADMIN_PROJECT_ID | |
nova quota-update --user $ADMIN_USER_ID --cores 40 $ADMIN_PROJECT_ID | |
# 96GB ram | |
nova quota-update --ram 96000 $ADMIN_PROJECT_ID | |
nova quota-update --user $ADMIN_USER_ID --ram 96000 $ADMIN_PROJECT_ID | |
# add default flavors, if they don't already exist | |
if ! openstack flavor list | grep -q m1.tiny; then | |
openstack flavor create --id 1 --ram 1024 --disk 5 --vcpus 1 m1.xtiny | |
openstack flavor create --id 2 --ram 1024 --disk 12 --vcpus 1 m1.tiny | |
openstack flavor create --id 3 --ram 2048 --disk 12 --vcpus 1 m1.small | |
openstack flavor create --id 4 --ram 4096 --disk 12 --vcpus 1 m1.medium | |
openstack flavor create --id 5 --ram 4096 --disk 20 --vcpus 2 m1.large | |
openstack flavor create --id 6 --ram 8192 --disk 30 --vcpus 2 m1.xlarge | |
fi | |
DEMO_NET_ID=$(openstack network list | awk '/ demo-net / {print $2}') | |
cat << EOF | |
Done. | |
To deploy a demo instance, run: | |
openstack server create \\ | |
--image cirros \\ | |
--flavor m1.tiny \\ | |
--key-name mykey \\ | |
--nic net-id=${DEMO_NET_ID} \\ | |
demo1 | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment