Joe Topjian | 7c8dd02 | 2016-09-01 12:02:04 -0600 | [diff] [blame] | 1 | #!/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 | |
| 22 | set -e |
| 23 | |
| 24 | cd |
| 25 | sudo apt-get update |
| 26 | sudo apt-get install -y git make mercurial |
| 27 | |
| 28 | sudo wget -O /usr/local/bin/gimme https://raw.githubusercontent.com/travis-ci/gimme/master/gimme |
| 29 | sudo chmod +x /usr/local/bin/gimme |
| 30 | gimme 1.6 >> .bashrc |
| 31 | |
| 32 | mkdir ~/go |
| 33 | eval "$(/usr/local/bin/gimme 1.6)" |
| 34 | echo 'export GOPATH=$HOME/go' >> .bashrc |
| 35 | export GOPATH=$HOME/go |
| 36 | |
| 37 | export PATH=$PATH:$HOME/terraform:$HOME/go/bin |
| 38 | echo 'export PATH=$PATH:$HOME/terraform:$HOME/go/bin' >> .bashrc |
| 39 | source .bashrc |
| 40 | |
Joe Topjian | 3a4e1b9 | 2016-09-06 10:08:51 -0600 | [diff] [blame] | 41 | go get golang.org/x/crypto/ssh |
| 42 | go get github.com/gophercloud/gophercloud |
| 43 | |
Joe Topjian | 7c8dd02 | 2016-09-01 12:02:04 -0600 | [diff] [blame] | 44 | git clone https://git.openstack.org/openstack-dev/devstack -b stable/mitaka |
| 45 | cd devstack |
| 46 | cat >local.conf <<EOF |
| 47 | [[local|localrc]] |
| 48 | # OpenStack version |
| 49 | OPENSTACK_VERSION="mitaka" |
| 50 | |
| 51 | # devstack password |
| 52 | DEVSTACK_PASSWORD="password" |
| 53 | |
| 54 | # Configure passwords and the Swift Hash |
| 55 | MYSQL_PASSWORD=\$DEVSTACK_PASSWORD |
| 56 | RABBIT_PASSWORD=\$DEVSTACK_PASSWORD |
| 57 | SERVICE_TOKEN=\$DEVSTACK_PASSWORD |
| 58 | ADMIN_PASSWORD=\$DEVSTACK_PASSWORD |
| 59 | SERVICE_PASSWORD=\$DEVSTACK_PASSWORD |
| 60 | SWIFT_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/ |
| 65 | CINDER_BRANCH=stable/\$OPENSTACK_VERSION |
| 66 | CEILOMETER_BRANCH=stable/\$OPENSTACK_VERSION |
| 67 | GLANCE_BRANCH=stable/\$OPENSTACK_VERSION |
| 68 | HEAT_BRANCH=stable/\$OPENSTACK_VERSION |
| 69 | HORIZON_BRANCH=stable/\$OPENSTACK_VERSION |
| 70 | KEYSTONE_BRANCH=stable/\$OPENSTACK_VERSION |
| 71 | NEUTRON_BRANCH=stable/\$OPENSTACK_VERSION |
| 72 | NOVA_BRANCH=stable/\$OPENSTACK_VERSION |
| 73 | SWIFT_BRANCH=stable/\$OPENSTACK_VERSION |
| 74 | ZAQAR_BRANCH=stable/\$OPENSTACK_VERSION |
| 75 | |
| 76 | # Enable Swift |
| 77 | enable_service s-proxy |
| 78 | enable_service s-object |
| 79 | enable_service s-container |
| 80 | enable_service s-account |
| 81 | |
| 82 | # Disable Nova Network and enable Neutron |
| 83 | disable_service n-net |
| 84 | enable_service q-svc |
| 85 | enable_service q-agt |
| 86 | enable_service q-dhcp |
| 87 | enable_service q-l3 |
| 88 | enable_service q-meta |
| 89 | enable_service q-flavors |
| 90 | |
| 91 | # Disable Neutron metering |
| 92 | disable_service q-metering |
| 93 | |
| 94 | # Enable LBaaS V1 |
| 95 | #enable_service q-lbaas |
| 96 | |
| 97 | # Enable FWaaS |
| 98 | enable_service q-fwaas |
| 99 | |
| 100 | # Enable LBaaS v2 |
| 101 | enable_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 |
| 103 | enable_plugin octavia https://git.openstack.org/openstack/octavia |
| 104 | enable_service q-lbaasv2 |
| 105 | enable_service octavia |
| 106 | enable_service o-cw |
| 107 | enable_service o-hm |
| 108 | enable_service o-hk |
| 109 | enable_service o-api |
| 110 | |
| 111 | # Octavia |
| 112 | OCTAVIA_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 |
| 119 | disable_service tempest |
| 120 | |
| 121 | # Disable Horizon |
| 122 | disable_service horizon |
| 123 | |
| 124 | # Disable Keystone v2 |
| 125 | ENABLE_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 |
| 151 | LOGDAYS=1 |
| 152 | LOGFILE=/opt/stack/logs/stack.sh.log |
| 153 | LOGDIR=/opt/stack/logs |
| 154 | |
| 155 | [[post-config|\$OCTAVIA_CONF]] |
| 156 | [default] |
| 157 | debug = true |
| 158 | verbose = true |
| 159 | [keystone_authtoken] |
| 160 | auth_uri = http://localhost:5000/v3 |
| 161 | auth_url = http://localhost:35357/v3 |
| 162 | user_domain_id = default |
| 163 | project_name = default |
| 164 | auth_type = password |
| 165 | [keystone_authtoken_v3] |
| 166 | admin_user_domain = default |
| 167 | admin_project_domain = default |
| 168 | [[post-config|\$NEUTRON_CONF]] |
| 169 | [service_auth] |
| 170 | auth_version = 3 |
| 171 | auth_uri = http://localhost:5000/v3 |
| 172 | auth_url = http://localhost:35357/v3 |
| 173 | admin_user_domain = default |
| 174 | admin_project_domain = default |
| 175 | [[post-config|\$NEUTRON_LBAAS_CONF]] |
| 176 | [service_auth] |
| 177 | auth_version = 3 |
| 178 | auth_uri = http://localhost:5000/v3 |
| 179 | auth_url = http://localhost:35357/v3 |
| 180 | admin_user_domain = default |
| 181 | admin_project_domain = default |
| 182 | EOF |
| 183 | ./stack.sh |
| 184 | |
| 185 | # Patch openrc |
| 186 | cat >> openrc <<EOF |
| 187 | if [ "\$OS_IDENTITY_API_VERSION" = "3" ]; then |
Joe Topjian | 3a4e1b9 | 2016-09-06 10:08:51 -0600 | [diff] [blame] | 188 | export OS_DOMAIN_NAME=\${OS_DOMAIN_NAME:-"default"} |
Joe Topjian | 7c8dd02 | 2016-09-01 12:02:04 -0600 | [diff] [blame] | 189 | fi |
| 190 | EOF |
| 191 | |
| 192 | # Prep the testing environment by creating the required testing resources and environment variables |
| 193 | source openrc admin |
| 194 | wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img |
| 195 | glance image-create --name CirrOS --disk-format qcow2 --container-format bare < cirros-0.3.4-x86_64-disk.img |
Joe Topjian | 3a4e1b9 | 2016-09-06 10:08:51 -0600 | [diff] [blame] | 196 | nova flavor-create m1.acctest 99 512 5 1 --ephemeral 10 |
| 197 | nova flavor-create m1.resize 98 512 6 1 --ephemeral 10 |
Joe Topjian | 7c8dd02 | 2016-09-01 12:02:04 -0600 | [diff] [blame] | 198 | _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) |
| 201 | echo export OS_IMAGE_NAME="cirros-0.3.4-x86_64-uec" >> openrc |
| 202 | echo export OS_IMAGE_ID="$_IMAGE_ID" >> openrc |
| 203 | echo export OS_NETWORK_ID=$_NETWORK_ID >> openrc |
| 204 | echo export OS_EXTGW_ID=$_EXTGW_ID >> openrc |
| 205 | echo export OS_POOL_NAME="public" >> openrc |
| 206 | echo export OS_FLAVOR_ID=99 >> openrc |
Joe Topjian | 3a4e1b9 | 2016-09-06 10:08:51 -0600 | [diff] [blame] | 207 | echo export OS_FLAVOR_ID_RESIZE=98 >> openrc |
Joe Topjian | 7c8dd02 | 2016-09-01 12:02:04 -0600 | [diff] [blame] | 208 | source openrc demo |