blob: 5cc9212ddc7b28e8af691a846fbd7f8b23bc5329 [file] [log] [blame]
Joe Topjian7c8dd022016-09-01 12:02:04 -06001#!/bin/bash
2#
3# This script is useful for creating a devstack environment to run gophercloud
4# acceptance tests on.
5#
6# To run, simply execute this script within a virtual machine.
7#
8# The following OpenStack versions are installed:
9# * OpenStack Mitaka
10# * Keystone v3
11# * Glance v1 and v2
12# * Nova v2 and v2.1
13# * Cinder v1 and v2
14# * Trove v1
15# * Swift v1
16# * Neutron v2
17# * Neutron LBaaS v2.0
18# * Neutron FWaaS v2.0
19#
20# Go 1.6 is also installed.
21
22set -e
23
24cd
25sudo apt-get update
26sudo apt-get install -y git make mercurial
27
28sudo wget -O /usr/local/bin/gimme https://raw.githubusercontent.com/travis-ci/gimme/master/gimme
29sudo chmod +x /usr/local/bin/gimme
30gimme 1.6 >> .bashrc
31
32mkdir ~/go
33eval "$(/usr/local/bin/gimme 1.6)"
34echo 'export GOPATH=$HOME/go' >> .bashrc
35export GOPATH=$HOME/go
36
37export PATH=$PATH:$HOME/terraform:$HOME/go/bin
38echo 'export PATH=$PATH:$HOME/terraform:$HOME/go/bin' >> .bashrc
39source .bashrc
40
Joe Topjian3a4e1b92016-09-06 10:08:51 -060041go get golang.org/x/crypto/ssh
42go get github.com/gophercloud/gophercloud
43
Joe Topjian7c8dd022016-09-01 12:02:04 -060044git clone https://git.openstack.org/openstack-dev/devstack -b stable/mitaka
45cd devstack
46cat >local.conf <<EOF
47[[local|localrc]]
48# OpenStack version
49OPENSTACK_VERSION="mitaka"
50
51# devstack password
52DEVSTACK_PASSWORD="password"
53
54# Configure passwords and the Swift Hash
55MYSQL_PASSWORD=\$DEVSTACK_PASSWORD
56RABBIT_PASSWORD=\$DEVSTACK_PASSWORD
57SERVICE_TOKEN=\$DEVSTACK_PASSWORD
58ADMIN_PASSWORD=\$DEVSTACK_PASSWORD
59SERVICE_PASSWORD=\$DEVSTACK_PASSWORD
60SWIFT_HASH=\$DEVSTACK_PASSWORD
61
62# Configure the stable OpenStack branches used by DevStack
63# For stable branches see
64# http://git.openstack.org/cgit/openstack-dev/devstack/refs/
65CINDER_BRANCH=stable/\$OPENSTACK_VERSION
66CEILOMETER_BRANCH=stable/\$OPENSTACK_VERSION
67GLANCE_BRANCH=stable/\$OPENSTACK_VERSION
68HEAT_BRANCH=stable/\$OPENSTACK_VERSION
69HORIZON_BRANCH=stable/\$OPENSTACK_VERSION
70KEYSTONE_BRANCH=stable/\$OPENSTACK_VERSION
71NEUTRON_BRANCH=stable/\$OPENSTACK_VERSION
72NOVA_BRANCH=stable/\$OPENSTACK_VERSION
73SWIFT_BRANCH=stable/\$OPENSTACK_VERSION
74ZAQAR_BRANCH=stable/\$OPENSTACK_VERSION
75
76# Enable Swift
77enable_service s-proxy
78enable_service s-object
79enable_service s-container
80enable_service s-account
81
82# Disable Nova Network and enable Neutron
83disable_service n-net
84enable_service q-svc
85enable_service q-agt
86enable_service q-dhcp
87enable_service q-l3
88enable_service q-meta
89enable_service q-flavors
90
91# Disable Neutron metering
92disable_service q-metering
93
94# Enable LBaaS V1
95#enable_service q-lbaas
96
97# Enable FWaaS
98enable_service q-fwaas
99
100# Enable LBaaS v2
101enable_plugin neutron-lbaas https://git.openstack.org/openstack/neutron-lbaas stable/\$OPENSTACK_VERSION
102#enable_plugin octavia https://git.openstack.org/openstack/octavia stable/\$OPENSTACK_VERSION
103enable_plugin octavia https://git.openstack.org/openstack/octavia
104enable_service q-lbaasv2
105enable_service octavia
106enable_service o-cw
107enable_service o-hm
108enable_service o-hk
109enable_service o-api
110
111# Octavia
112OCTAVIA_AUTH_VERSION=3
113
114# Enable Trove
115#enable_plugin trove git://git.openstack.org/openstack/trove.git stable/\$OPENSTACK_VERSION
116#enable_service trove,tr-api,tr-tmgr,tr-cond
117
118# Disable Temptest
119disable_service tempest
120
121# Disable Horizon
122disable_service horizon
123
124# Disable Keystone v2
125ENABLE_IDENTITY_V2=False
126
127# Enable SSL/tls
128#enable_service tls-proxy
129#USE_SSL=True
130
131# Enable Ceilometer
132#enable_service ceilometer-acompute
133#enable_service ceilometer-acentral
134#enable_service ceilometer-anotification
135#enable_service ceilometer-collector
136#enable_service ceilometer-alarm-evaluator
137#enable_service ceilometer-alarm-notifier
138#enable_service ceilometer-api
139
140# Enable Zaqar
141#enable_plugin zaqar https://github.com/openstack/zaqar
142#enable_service zaqar-server
143
144# Automatically download and register a VM image that Heat can launch
145# For more information on Heat and DevStack see
146# http://docs.openstack.org/developer/heat/getting_started/on_devstack.html
147#IMAGE_URLS+=",http://cloud.fedoraproject.org/fedora-20.x86_64.qcow2"
148#IMAGE_URLS+=",https://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.img"
149
150# Logging
151LOGDAYS=1
152LOGFILE=/opt/stack/logs/stack.sh.log
153LOGDIR=/opt/stack/logs
154
155[[post-config|\$OCTAVIA_CONF]]
156[default]
157debug = true
158verbose = true
159[keystone_authtoken]
160auth_uri = http://localhost:5000/v3
161auth_url = http://localhost:35357/v3
162user_domain_id = default
163project_name = default
164auth_type = password
165[keystone_authtoken_v3]
166admin_user_domain = default
167admin_project_domain = default
168[[post-config|\$NEUTRON_CONF]]
169[service_auth]
170auth_version = 3
171auth_uri = http://localhost:5000/v3
172auth_url = http://localhost:35357/v3
173admin_user_domain = default
174admin_project_domain = default
175[[post-config|\$NEUTRON_LBAAS_CONF]]
176[service_auth]
177auth_version = 3
178auth_uri = http://localhost:5000/v3
179auth_url = http://localhost:35357/v3
180admin_user_domain = default
181admin_project_domain = default
182EOF
183./stack.sh
184
185# Patch openrc
186cat >> openrc <<EOF
187if [ "\$OS_IDENTITY_API_VERSION" = "3" ]; then
Joe Topjian3a4e1b92016-09-06 10:08:51 -0600188 export OS_DOMAIN_NAME=\${OS_DOMAIN_NAME:-"default"}
Joe Topjian7c8dd022016-09-01 12:02:04 -0600189fi
190EOF
191
192# Prep the testing environment by creating the required testing resources and environment variables
193source openrc admin
194wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
195glance image-create --name CirrOS --disk-format qcow2 --container-format bare < cirros-0.3.4-x86_64-disk.img
Joe Topjian3a4e1b92016-09-06 10:08:51 -0600196nova flavor-create m1.acctest 99 512 5 1 --ephemeral 10
197nova flavor-create m1.resize 98 512 6 1 --ephemeral 10
Joe Topjian7c8dd022016-09-01 12:02:04 -0600198_NETWORK_ID=$(nova net-list | grep private | awk -F\| '{print $2}' | tr -d ' ')
199_EXTGW_ID=$(nova net-list | grep public | awk -F\| '{print $2}' | tr -d ' ')
200_IMAGE_ID=$(nova image-list | grep CirrOS | awk -F\| '{print $2}' | tr -d ' ' | head -1)
201echo export OS_IMAGE_NAME="cirros-0.3.4-x86_64-uec" >> openrc
202echo export OS_IMAGE_ID="$_IMAGE_ID" >> openrc
203echo export OS_NETWORK_ID=$_NETWORK_ID >> openrc
204echo export OS_EXTGW_ID=$_EXTGW_ID >> openrc
205echo export OS_POOL_NAME="public" >> openrc
206echo export OS_FLAVOR_ID=99 >> openrc
Joe Topjian3a4e1b92016-09-06 10:08:51 -0600207echo export OS_FLAVOR_ID_RESIZE=98 >> openrc
Joe Topjian7c8dd022016-09-01 12:02:04 -0600208source openrc demo