6 PLATFORM=$(python -mplatform)
7 TOKEN=$(openssl rand -hex 10)
9 AUTH="--os-auth-url http://127.0.0.1:35357 --os-token $TOKEN --os-endpoint http://127.0.0.1:35357/v2.0/"
10 NEUTRON_AUTH="--os-username neutron --os-password neutron --os-tenant-name neutron --os-auth-url http://127.0.0.1:35357/v2.0"
11 FORMAT=" --request-format xml"
12 CORE_PLUGIN="neutron.plugins.ml2.plugin.Ml2Plugin"
14 if [[ $PLATFORM =~ Ubuntu ]]; then UBUNTU=true; fi
15 if [ -z $PACKAGE ]; then echo "Package for testing is not specified"; exit 1; fi
16 echo "127.0.10.1 $(hostname)" >> /etc/hosts
22 echo "mysql-server mysql-server/root_password select $MYSQL_PASS" | debconf-set-selections
23 echo "mysql-server mysql-server/root_password_again select $MYSQL_PASS" | debconf-set-selections
24 apt-get install -y --force-yes rabbitmq-server mysql-server mysql-client-core-5.5 python-mysqldb keystone
26 yum install -y openstack-keystone rabbitmq-server mysql-server python-oslo-utils
27 #Install some plugins because they are required for db-migration scripts (bug #1371184)
28 #Ubuntu neutron-server package include them
29 #yum install -y openstack-neutron-bigswitch openstack-neutron-brocade openstack-neutron-cisco openstack-neutron-hyperv openstack-neutron-vmware openstack-neutron-openvswitch \
30 # openstack-neutron-ryu openstack-neutron-linuxbridge openstack-neutron-metaplugin openstack-neutron-mellanox openstack-neutron-nec openstack-neutron-nuage
34 install_neutron_server () {
37 apt-get install -y --force-yes neutron-server
39 yum install -y openstack-neutron openstack-neutron-ml2
45 service mysql restart || service mysqld restart
48 mysqladmin -u root password $MYSQL_PASS
50 mysql -uroot -p$MYSQL_PASS -Bse "create database keystone"
51 mysql -uroot -p$MYSQL_PASS -Bse "create database neutron"
52 mysql -uroot -p$MYSQL_PASS -Bse "GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'localhost' IDENTIFIED BY 'neutron'"
53 mysql -uroot -p$MYSQL_PASS -Bse "GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY 'keystone'"
54 mysql -uroot -p$MYSQL_PASS -Bse "flush privileges"
61 cp /usr/share/keystone/keystone-dist-paste.ini /etc/keystone/keystone-paste.ini
63 cat > /etc/keystone/keystone.conf << EOF
67 connection=mysql://keystone:keystone@localhost/keystone
69 provider=keystone.token.providers.uuid.Provider
71 keystone-manage db_sync
72 chown -R keystone:keystone /var/log/keystone/
75 service keystone restart
77 service openstack-keystone start
80 #Setup Neutron credentials
81 keystone $AUTH user-create --name neutron --pass neutron
82 keystone $AUTH tenant-create --name neutron
83 keystone $AUTH role-create --name=admin
84 keystone $AUTH user-role-add --user neutron --role admin --tenant neutron
85 NEUTRON_SERVICE=`keystone $AUTH service-create --name=neutron --type=network --description="Neutron Networking Service" | grep id | awk -F '|' '{print $3}' | tr -d ' '`
86 keystone $AUTH endpoint-create --region RegionOne --service-id=$NEUTRON_SERVICE --publicurl=http://localhost:9696 --internalurl=http://localhost:9696 --adminurl=http://localhost:9696
89 setup_neutron_services() {
91 cat > /etc/neutron/neutron.conf << EOF
93 auth_strategy = keystone
96 service_plugins = neutron.services.l3_router.l3_router_plugin.L3RouterPlugin
97 core_plugin = $CORE_PLUGIN
98 rabbit_password = guest
99 rabbit_hosts = 127.0.0.1
100 rpc_backend = neutron.openstack.common.rpc.impl_kombu
101 state_path = /var/lib/neutron
102 lock_path = $state_path/lock
104 auth_host = 127.0.0.1
107 admin_tenant_name = neutron
109 admin_password = neutron
110 auth_url=http://127.0.0.1:35357/v2.0
115 root_helper = sudo neutron-rootwrap /etc/neutron/rootwrap.conf
117 connection = mysql://neutron:neutron@127.0.0.1/neutron?charset=utf8
119 service_provider=LOADBALANCER:Haproxy:neutron.services.loadbalancer.drivers.haproxy.plugin_driver.HaproxyOnHostPluginDriver:default
120 service_provider=VPN:openswan:neutron.services.vpn.service_drivers.ipsec.IPsecVPNDriver:default
123 cat > /etc/neutron/l3_agent.ini << EOF
125 interface_driver =neutron.agent.linux.interface.OVSInterfaceDriver
126 root_helper=sudo neutron-rootwrap /etc/neutron/rootwrap.conf
131 cp /usr/share/neutron/api-paste.ini /etc/neutron/
132 chown neutron:neutron /etc/neutron/api-paste.ini
135 touch /etc/neutron/plugin.ini
138 service rabbitmq-server restart
139 if [ $? -eq 0 ]; then break; fi
140 echo "RabbitMQ server failed to start"
141 cat /var/log/rabbitmq/startup_err
142 cat /var/log/rabbitmq/startup_log
146 upgrade_neutron_db () {
147 neutron-db-manage --config-file /etc/neutron/neutron.conf upgrade head || (echo "DB migration failed" && exit 1)
150 start_neutron_server () {
151 service neutron-server restart
152 # Sleep is to let Neutron server successfully reconnect to AMQP
156 check_neutron_server() {
158 neutron $NEUTRON_AUTH net-create $FORMAT mynet1
159 CHECK=$(neutron $NEUTRON_AUTH net-list | grep id)
160 if [ -z "$CHECK" ]; then echo "Network listing failed" && FAILURE=true; fi
163 check_neutron_openvswitch () {
165 # Workaround for bug #1371184
168 chown root:neutron /etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini
172 service openvswitch start
173 service neutron-openvswitch-agent start
175 service openvswitch-switch restart
176 service neutron-plugin-openvswitch-agent restart
179 STATUS=$(neutron $NEUTRON_AUTH agent-list | grep "Open vSwitch agent" | awk -F "|" '{print $5}' | tr -d " ")
180 if [ "$STATUS" != ":-)" ]; then echo "OVS agent check failed"; FAILURE=true; fi
183 check_neutron_l3_agent () {
185 service neutron-l3-agent restart
186 #This sleep here and in other functions is intended to let the agent add information to the queue
188 STATUS=$(neutron $NEUTRON_AUTH agent-list | grep "L3 agent" | awk -F "|" '{print $5}' | tr -d " ")
189 if [ "$STATUS" != ":-)" ]; then echo "L3 agent check failed"; FAILURE=true; fi
192 check_neutron_dhcp_agent () {
194 service neutron-dhcp-agent restart
196 STATUS=$(neutron $NEUTRON_AUTH agent-list | grep "DHCP agent" | awk -F "|" '{print $5}' | tr -d " ")
197 if [ "$STATUS" != ":-)" ]; then echo "DHCP agent check failed"; FAILURE=true; fi
200 check_neutron_metadata_agent () {
202 service neutron-metadata-agent restart
204 STATUS=$(neutron $NEUTRON_AUTH agent-list | grep "Metadata agent" | awk -F "|" '{print $5}' | tr -d " ")
205 if [ "$STATUS" != ":-)" ]; then echo "Metadata agent check failed"; FAILURE=true; fi
208 check_neutron_metering_agent () {
210 service neutron-metering-agent restart
212 STATUS=$(neutron $NEUTRON_AUTH agent-list | grep "Metering agent" | awk -F "|" '{print $5}' | tr -d " ")
213 if [ "$STATUS" != ":-)" ]; then echo "Metering agent check failed"; FAILURE=true; fi
216 check_neutron_client () {
217 neutron --help > /dev/null
218 if [ $? -ne 0 ]; then echo "Neutron client check failed"; FAILURE=true; fi
224 grep TRACE /var/log/neutron/*
225 grep ERROR /var/log/neutron/*
232 install_neutron_server
236 setup_neutron_services
243 install_neutron_server
247 setup_neutron_services
251 check_neutron_l3_agent
252 check_neutron_dhcp_agent
253 check_neutron_metadata_agent
256 openstack-neutron-ml2)
257 install_neutron_server
261 setup_neutron_services
267 openstack-neutron-openvswitch|neutron-plugin-openvswitch-agent)
269 install_neutron_server
272 setup_neutron_services
275 check_neutron_openvswitch
278 python-neutronclient)
283 install_neutron_server
287 setup_neutron_services
290 check_neutron_l3_agent
294 install_neutron_server
298 setup_neutron_services
301 check_neutron_dhcp_agent
304 neutron-metadata-agent)
305 install_neutron_server
309 setup_neutron_services
312 check_neutron_metadata_agent
315 openstack-neutron-metering-agent|neutron-plugin-metering-agent)
316 install_neutron_server
320 setup_neutron_services
323 check_neutron_metering_agent