9 PLATFORM=$(python -mplatform)
10 TOKEN=$(openssl rand -hex 10)
12 AUTH="--os-auth-url http://127.0.0.1:35357 --os-token $TOKEN --os-endpoint http://127.0.0.1:35357/v2.0/"
13 NEUTRON_AUTH="--os-username neutron --os-password neutron --os-tenant-name neutron --os-auth-url http://127.0.0.1:35357/v2.0"
14 CORE_PLUGIN="neutron.plugins.ml2.plugin.Ml2Plugin"
16 if [[ $PLATFORM =~ Ubuntu ]]; then UBUNTU=true; fi
17 if [ -z $PACKAGE ]; then echo "Package for testing is not specified"; exit 1; fi
18 echo "127.0.10.1 $(hostname)" >> /etc/hosts
24 echo "mysql-server mysql-server/root_password select $MYSQL_PASS" | debconf-set-selections
25 echo "mysql-server mysql-server/root_password_again select $MYSQL_PASS" | debconf-set-selections
26 apt-get install -y --force-yes rabbitmq-server mysql-server mysql-client-core-5.5 python-mysqldb keystone
28 #yum install -y openstack-keystone rabbitmq-server mysql-server MySQL-client python-oslo-utils
29 yum install -y openstack-keystone rabbitmq-server python-oslo-utils
30 #CentOS 7 temporary workaround
31 yum install -y http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
32 yum install -y mysql-community-server mysql-community-client
33 #Install some plugins because they are required for db-migration scripts (bug #1371184)
34 #Ubuntu neutron-server package include them
35 #yum install -y openstack-neutron-bigswitch openstack-neutron-brocade openstack-neutron-cisco openstack-neutron-hyperv openstack-neutron-vmware openstack-neutron-openvswitch \
36 # openstack-neutron-ryu openstack-neutron-linuxbridge openstack-neutron-metaplugin openstack-neutron-mellanox openstack-neutron-nec openstack-neutron-nuage
40 install_neutron_server () {
43 apt-get install -y --force-yes neutron-server
45 yum install -y openstack-neutron openstack-neutron-ml2
50 #Setup firewall on CentOS 7
52 firewall-cmd --permanent --add-port=5672/tcp
54 setsebool -P nis_enabled 1
57 restart_service rabbitmq-server
59 echo "RabbitMQ server failed to start"
60 cat /var/log/rabbitmq/startup_err
61 cat /var/log/rabbitmq/startup_log
70 mysqladmin -u root password $MYSQL_PASS
72 mysql -uroot -p$MYSQL_PASS -Bse "drop database if exists keystone"
73 mysql -uroot -p$MYSQL_PASS -Bse "drop database if exists neutron"
74 mysql -uroot -p$MYSQL_PASS -Bse "create database keystone"
75 mysql -uroot -p$MYSQL_PASS -Bse "create database neutron"
76 mysql -uroot -p$MYSQL_PASS -Bse "GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'localhost' IDENTIFIED BY 'neutron'"
77 mysql -uroot -p$MYSQL_PASS -Bse "GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY 'keystone'"
78 mysql -uroot -p$MYSQL_PASS -Bse "flush privileges"
85 cp /usr/share/keystone/keystone-dist-paste.ini /etc/keystone/keystone-paste.ini
87 cat > /etc/keystone/keystone.conf << EOF
91 connection=mysql://keystone:keystone@localhost/keystone
93 provider=keystone.token.providers.uuid.Provider
95 keystone-manage db_sync
96 chown -R keystone:keystone /var/log/keystone/
99 service keystone restart
101 systemctl restart openstack-keystone
104 #Setup Neutron credentials
105 keystone $AUTH user-create --name neutron --pass neutron
106 keystone $AUTH tenant-create --name neutron
107 keystone $AUTH role-create --name=admin
108 keystone $AUTH user-role-add --user neutron --role admin --tenant neutron
109 NEUTRON_SERVICE=`keystone $AUTH service-create --name=neutron --type=network --description="Neutron Networking Service" | grep id | awk -F '|' '{print $3}' | tr -d ' '`
110 keystone $AUTH endpoint-create --region RegionOne --service-id=$NEUTRON_SERVICE --publicurl=http://localhost:9696 --internalurl=http://localhost:9696 --adminurl=http://localhost:9696
113 setup_neutron_services() {
115 cat > /etc/neutron/neutron.conf << EOF
117 auth_strategy = keystone
120 service_plugins = neutron.services.l3_router.l3_router_plugin.L3RouterPlugin
121 core_plugin = $CORE_PLUGIN
122 rabbit_password = guest
123 rabbit_hosts = 127.0.0.1
124 rpc_backend = neutron.openstack.common.rpc.impl_kombu
125 state_path = /var/lib/neutron
126 lock_path = $state_path/lock
128 auth_host = 127.0.0.1
131 admin_tenant_name = neutron
133 admin_password = neutron
134 auth_url=http://127.0.0.1:35357/v2.0
139 root_helper = sudo neutron-rootwrap /etc/neutron/rootwrap.conf
141 connection = mysql://neutron:neutron@127.0.0.1/neutron?charset=utf8
145 cat > /etc/neutron/l3_agent.ini << EOF
147 interface_driver =neutron.agent.linux.interface.OVSInterfaceDriver
148 root_helper=sudo neutron-rootwrap /etc/neutron/rootwrap.conf
153 cp /usr/share/neutron/api-paste.ini /etc/neutron/
154 chown neutron:neutron /etc/neutron/api-paste.ini
157 touch /etc/neutron/plugin.ini
161 upgrade_neutron_db () {
162 neutron-db-manage --config-file /etc/neutron/neutron.conf upgrade head || (echo "DB migration failed" && exit 1)
165 start_neutron_server () {
166 restart_service neutron-server
167 # Sleep is to let Neutron server successfully reconnect to AMQP
173 SERVICE_STARTED=false
182 FAILED_TESTS+="$TEST_FUNCTION "
190 service $SERVICE restart
192 systemctl restart $SERVICE
196 check_neutron_server() {
198 neutron $NEUTRON_AUTH net-create mynet1
199 CHECK=$(neutron $NEUTRON_AUTH net-list | grep id)
200 if [ -z "$CHECK" ]; then echo "Network listing failed" && FAILURE=true; fi
203 check_neutron_openvswitch () {
204 # Workaround for bug #1371184
207 chown root:neutron /etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini
210 if ! $SERVICE_STARTED ; then
212 restart_service openvswitch-switch
214 restart_service openvswitch
216 restart_service neutron-openvswitch-agent
221 STATUS=$(neutron $NEUTRON_AUTH agent-list | grep "Open vSwitch agent" | awk -F "|" '{print $5}' | tr -d " ")
222 if [ "$STATUS" != ":-)" ]; then echo "OVS agent check failed"; FAILURE=true; fi
225 check_neutron_l3_agent () {
226 if ! $SERVICE_STARTED ; then
227 restart_service neutron-l3-agent
230 #This sleep here and in other functions is intended to let the agent add information to the queue
232 STATUS=$(neutron $NEUTRON_AUTH agent-list | grep "L3 agent" | awk -F "|" '{print $5}' | tr -d " ")
233 if [ "$STATUS" != ":-)" ]; then echo "L3 agent check failed"; FAILURE=true; fi
236 check_neutron_dhcp_agent () {
237 if ! $SERVICE_STARTED ; then
238 restart_service neutron-dhcp-agent
242 STATUS=$(neutron $NEUTRON_AUTH agent-list | grep "DHCP agent" | awk -F "|" '{print $5}' | tr -d " ")
243 if [ "$STATUS" != ":-)" ]; then echo "DHCP agent check failed"; FAILURE=true; fi
246 check_neutron_metadata_agent () {
247 if ! $SERVICE_STARTED ; then
248 restart_service neutron-metadata-agent
252 STATUS=$(neutron $NEUTRON_AUTH agent-list | grep "Metadata agent" | awk -F "|" '{print $5}' | tr -d " ")
253 if [ "$STATUS" != ":-)" ]; then echo "Metadata agent check failed"; FAILURE=true; fi
256 check_neutron_metering_agent () {
257 if ! $SERVICE_STARTED ; then
258 restart_service neutron-metering-agent
262 STATUS=$(neutron $NEUTRON_AUTH agent-list | grep "Metering agent" | awk -F "|" '{print $5}' | tr -d " ")
263 if [ "$STATUS" != ":-)" ]; then echo "Metering agent check failed"; FAILURE=true; fi
266 check_neutron_client () {
267 neutron --help > /dev/null
268 if [ $? -ne 0 ]; then echo "Neutron client check failed"; FAILURE=true; fi
272 if [ "$FAILED_TESTS" != "" ]
274 grep TRACE /var/log/neutron/*
275 grep ERROR /var/log/neutron/*
276 echo "Failed tests are: $FAILED_TESTS"
283 install_neutron_server
287 setup_neutron_services
290 try check_neutron_server
294 install_neutron_server
298 setup_neutron_services
301 try check_neutron_server
302 try check_neutron_l3_agent
303 try check_neutron_dhcp_agent
304 try check_neutron_metadata_agent
307 openstack-neutron-ml2)
308 install_neutron_server
312 setup_neutron_services
315 try check_neutron_server
318 openstack-neutron-openvswitch|neutron-plugin-openvswitch-agent)
320 install_neutron_server
323 setup_neutron_services
326 try check_neutron_openvswitch
329 python-neutronclient)
334 install_neutron_server
338 setup_neutron_services
341 try check_neutron_l3_agent
345 install_neutron_server
349 setup_neutron_services
352 try check_neutron_dhcp_agent
355 neutron-metadata-agent)
356 install_neutron_server
360 setup_neutron_services
363 try check_neutron_metadata_agent
366 openstack-neutron-metering-agent|neutron-plugin-metering-agent)
367 install_neutron_server
371 setup_neutron_services
374 try check_neutron_metering_agent