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 DEBIAN_FRONTEND=noninteractive 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 DEBIAN_FRONTEND=noninteractive 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
213 restart_service neutron-plugin-openvswitch-agent
215 restart_service openvswitch
216 restart_service neutron-openvswitch-agent
222 STATUS=$(neutron $NEUTRON_AUTH agent-list | grep "Open vSwitch agent" | awk -F "|" '{print $5}' | tr -d " ")
223 if [ "$STATUS" != ":-)" ]; then echo "OVS agent check failed"; FAILURE=true; fi
226 check_neutron_l3_agent () {
227 if ! $SERVICE_STARTED ; then
228 restart_service neutron-l3-agent
231 #This sleep here and in other functions is intended to let the agent add information to the queue
233 STATUS=$(neutron $NEUTRON_AUTH agent-list | grep "L3 agent" | awk -F "|" '{print $5}' | tr -d " ")
234 if [ "$STATUS" != ":-)" ]; then echo "L3 agent check failed"; FAILURE=true; fi
237 check_neutron_dhcp_agent () {
238 if ! $SERVICE_STARTED ; then
239 restart_service neutron-dhcp-agent
243 STATUS=$(neutron $NEUTRON_AUTH agent-list | grep "DHCP agent" | awk -F "|" '{print $5}' | tr -d " ")
244 if [ "$STATUS" != ":-)" ]; then echo "DHCP agent check failed"; FAILURE=true; fi
247 check_neutron_metadata_agent () {
248 if ! $SERVICE_STARTED ; then
249 restart_service neutron-metadata-agent
253 STATUS=$(neutron $NEUTRON_AUTH agent-list | grep "Metadata agent" | awk -F "|" '{print $5}' | tr -d " ")
254 if [ "$STATUS" != ":-)" ]; then echo "Metadata agent check failed"; FAILURE=true; fi
257 check_neutron_metering_agent () {
258 if ! $SERVICE_STARTED ; then
259 restart_service neutron-metering-agent
263 STATUS=$(neutron $NEUTRON_AUTH agent-list | grep "Metering agent" | awk -F "|" '{print $5}' | tr -d " ")
264 if [ "$STATUS" != ":-)" ]; then echo "Metering agent check failed"; FAILURE=true; fi
267 check_neutron_client () {
268 neutron --help > /dev/null
269 if [ $? -ne 0 ]; then echo "Neutron client check failed"; FAILURE=true; fi
273 if [ "$FAILED_TESTS" != "" ]
275 grep TRACE /var/log/neutron/*
276 grep ERROR /var/log/neutron/*
277 echo "Failed tests are: $FAILED_TESTS"
284 install_neutron_server
288 setup_neutron_services
291 try check_neutron_server
295 install_neutron_server
299 setup_neutron_services
302 try check_neutron_server
303 try check_neutron_l3_agent
304 try check_neutron_dhcp_agent
305 try check_neutron_metadata_agent
308 openstack-neutron-ml2)
309 install_neutron_server
313 setup_neutron_services
316 try check_neutron_server
319 openstack-neutron-openvswitch|neutron-plugin-openvswitch-agent)
321 install_neutron_server
324 setup_neutron_services
327 try check_neutron_openvswitch
330 python-neutronclient)
335 install_neutron_server
339 setup_neutron_services
342 try check_neutron_l3_agent
346 install_neutron_server
350 setup_neutron_services
353 try check_neutron_dhcp_agent
356 neutron-metadata-agent)
357 install_neutron_server
361 setup_neutron_services
364 try check_neutron_metadata_agent
367 openstack-neutron-metering-agent|neutron-plugin-metering-agent)
368 install_neutron_server
372 setup_neutron_services
375 try check_neutron_metering_agent