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 ]]
23 if [ -z $PACKAGE ]; then echo "Package for testing is not specified"; exit 1; fi
24 echo "127.0.10.1 $(hostname)" >> /etc/hosts
30 echo "mysql-server mysql-server/root_password select $MYSQL_PASS" | debconf-set-selections
31 echo "mysql-server mysql-server/root_password_again select $MYSQL_PASS" | debconf-set-selections
32 DEBIAN_FRONTEND=noninteractive apt-get install -y --force-yes rabbitmq-server mysql-server mysql-client-core-5.5 python-mysqldb keystone
34 #yum install -y openstack-keystone rabbitmq-server mysql-server MySQL-client python-oslo-utils
35 yum install -y openstack-keystone rabbitmq-server python-oslo-utils
36 #CentOS 7 temporary workaround
37 yum install -y http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
38 yum install -y mysql-community-server mysql-community-client
39 #Install some plugins because they are required for db-migration scripts (bug #1371184)
40 #Ubuntu neutron-server package include them
41 #yum install -y openstack-neutron-bigswitch openstack-neutron-brocade openstack-neutron-cisco openstack-neutron-hyperv openstack-neutron-vmware openstack-neutron-openvswitch \
42 # openstack-neutron-ryu openstack-neutron-linuxbridge openstack-neutron-metaplugin openstack-neutron-mellanox openstack-neutron-nec openstack-neutron-nuage
46 install_neutron_server () {
49 DEBIAN_FRONTEND=noninteractive apt-get install -y --force-yes neutron-server
51 yum install -y openstack-neutron openstack-neutron-ml2
56 #Setup firewall on CentOS 7
58 firewall-cmd --permanent --add-port=5672/tcp
60 setsebool -P nis_enabled 1
63 restart_service rabbitmq-server
65 echo "RabbitMQ server failed to start"
66 cat /var/log/rabbitmq/startup_err
67 cat /var/log/rabbitmq/startup_log
76 mysqladmin -u root password $MYSQL_PASS
78 mysql -uroot -p$MYSQL_PASS -Bse "drop database if exists keystone"
79 mysql -uroot -p$MYSQL_PASS -Bse "drop database if exists neutron"
80 mysql -uroot -p$MYSQL_PASS -Bse "create database keystone"
81 mysql -uroot -p$MYSQL_PASS -Bse "create database neutron"
82 mysql -uroot -p$MYSQL_PASS -Bse "GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'localhost' IDENTIFIED BY 'neutron'"
83 mysql -uroot -p$MYSQL_PASS -Bse "GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY 'keystone'"
84 mysql -uroot -p$MYSQL_PASS -Bse "flush privileges"
91 cp /usr/share/keystone/keystone-dist-paste.ini /etc/keystone/keystone-paste.ini
93 cat > /etc/keystone/keystone.conf << EOF
97 connection=mysql://keystone:keystone@localhost/keystone
99 provider=keystone.token.providers.uuid.Provider
101 keystone-manage db_sync
102 chown -R keystone:keystone /var/log/keystone/
105 service keystone restart
107 systemctl restart openstack-keystone
110 #Setup Neutron credentials
111 keystone $AUTH user-create --name neutron --pass neutron
112 keystone $AUTH tenant-create --name neutron
113 keystone $AUTH role-create --name=admin
114 keystone $AUTH user-role-add --user neutron --role admin --tenant neutron
115 NEUTRON_SERVICE=`keystone $AUTH service-create --name=neutron --type=network --description="Neutron Networking Service" | grep id | awk -F '|' '{print $3}' | tr -d ' '`
116 keystone $AUTH endpoint-create --region RegionOne --service-id=$NEUTRON_SERVICE --publicurl=http://localhost:9696 --internalurl=http://localhost:9696 --adminurl=http://localhost:9696
119 setup_neutron_services() {
121 cat > /etc/neutron/neutron.conf << EOF
123 auth_strategy = keystone
126 service_plugins = neutron.services.l3_router.l3_router_plugin.L3RouterPlugin
127 core_plugin = $CORE_PLUGIN
128 rabbit_password = guest
129 rabbit_hosts = 127.0.0.1
130 rpc_backend = neutron.openstack.common.rpc.impl_kombu
131 state_path = /var/lib/neutron
132 lock_path = $state_path/lock
134 auth_host = 127.0.0.1
137 admin_tenant_name = neutron
139 admin_password = neutron
140 auth_url=http://127.0.0.1:35357/v2.0
145 root_helper = sudo neutron-rootwrap /etc/neutron/rootwrap.conf
147 connection = mysql://neutron:neutron@127.0.0.1/neutron?charset=utf8
151 cat > /etc/neutron/l3_agent.ini << EOF
153 interface_driver =neutron.agent.linux.interface.OVSInterfaceDriver
154 root_helper=sudo neutron-rootwrap /etc/neutron/rootwrap.conf
159 cp /usr/share/neutron/api-paste.ini /etc/neutron/
160 chown neutron:neutron /etc/neutron/api-paste.ini
163 touch /etc/neutron/plugin.ini
167 upgrade_neutron_db () {
168 neutron-db-manage --config-file /etc/neutron/neutron.conf upgrade head || (echo "DB migration failed" && exit 1)
171 start_neutron_server () {
172 restart_service neutron-server
173 # Sleep is to let Neutron server successfully reconnect to AMQP
179 SERVICE_STARTED=false
188 FAILED_TESTS+="$TEST_FUNCTION "
196 service $SERVICE restart
198 systemctl restart $SERVICE
202 check_neutron_server() {
204 neutron $NEUTRON_AUTH net-create mynet1
205 CHECK=$(neutron $NEUTRON_AUTH net-list | grep id)
206 if [ -z "$CHECK" ]; then echo "Network listing failed" && FAILURE=true; fi
209 check_neutron_openvswitch () {
210 # Workaround for bug #1371184
213 chown root:neutron /etc/neutron/plugins/ml2/openvswitch_agent.ini
216 if ! $SERVICE_STARTED ; then
218 restart_service openvswitch-switch
219 restart_service neutron-openvswitch-agent
221 restart_service openvswitch
222 restart_service neutron-openvswitch-agent
228 STATUS=$(neutron $NEUTRON_AUTH agent-list | grep "Open vSwitch agent" | awk -F "|" '{print $6}' | tr -d " ")
229 if [ "$STATUS" != ":-)" ]; then echo "OVS agent check failed"; FAILURE=true; fi
232 check_neutron_l3_agent () {
233 if ! $SERVICE_STARTED ; then
234 restart_service neutron-l3-agent
237 #This sleep here and in other functions is intended to let the agent add information to the queue
239 STATUS=$(neutron $NEUTRON_AUTH agent-list | grep "L3 agent" | awk -F "|" '{print $6}' | tr -d " ")
240 if [ "$STATUS" != ":-)" ]; then echo "L3 agent check failed"; FAILURE=true; fi
243 check_neutron_dhcp_agent () {
244 if ! $SERVICE_STARTED ; then
245 restart_service neutron-dhcp-agent
249 STATUS=$(neutron $NEUTRON_AUTH agent-list | grep "DHCP agent" | awk -F "|" '{print $6}' | tr -d " ")
250 if [ "$STATUS" != ":-)" ]; then echo "DHCP agent check failed"; FAILURE=true; fi
253 check_neutron_metadata_agent () {
254 if ! $SERVICE_STARTED ; then
255 restart_service neutron-metadata-agent
259 STATUS=$(neutron $NEUTRON_AUTH agent-list | grep "Metadata agent" | awk -F "|" '{print $6}' | tr -d " ")
260 if [ "$STATUS" != ":-)" ]; then echo "Metadata agent check failed"; FAILURE=true; fi
263 check_neutron_metering_agent () {
264 if ! $SERVICE_STARTED ; then
265 restart_service neutron-metering-agent
269 STATUS=$(neutron $NEUTRON_AUTH agent-list | grep "Metering agent" | awk -F "|" '{print $6}' | tr -d " ")
270 if [ "$STATUS" != ":-)" ]; then echo "Metering agent check failed"; FAILURE=true; fi
273 check_neutron_client () {
274 neutron --help > /dev/null
275 if [ $? -ne 0 ]; then echo "Neutron client check failed"; FAILURE=true; fi
279 if [ "$FAILED_TESTS" != "" ]
281 grep TRACE /var/log/neutron/*
282 grep ERROR /var/log/neutron/*
283 echo "Failed tests are: $FAILED_TESTS"
290 install_neutron_server
294 setup_neutron_services
297 try check_neutron_server
301 install_neutron_server
305 setup_neutron_services
308 try check_neutron_server
309 try check_neutron_l3_agent
310 try check_neutron_dhcp_agent
311 try check_neutron_metadata_agent
314 openstack-neutron-ml2)
315 install_neutron_server
319 setup_neutron_services
322 try check_neutron_server
325 openstack-neutron-openvswitch|neutron-openvswitch-agent)
327 install_neutron_server
330 setup_neutron_services
333 try check_neutron_openvswitch
336 python-neutronclient)
341 install_neutron_server
345 setup_neutron_services
348 try check_neutron_l3_agent
352 install_neutron_server
356 setup_neutron_services
359 try check_neutron_dhcp_agent
362 neutron-metadata-agent)
363 install_neutron_server
367 setup_neutron_services
370 try check_neutron_metadata_agent
373 openstack-neutron-metering-agent|neutron-metering-agent)
374 install_neutron_server
378 setup_neutron_services
381 try check_neutron_metering_agent