3 # Author: Daniel Smith (Ericsson)
5 # Script to update neutron configuration for OVSDB/ODL integratino
7 # Usage - Set / pass CONTROL_HOST to your needs
9 ### SET THIS VALUE TO MATCH YOUR SYSTEM
10 CONTROL_HOST=192.168.0.2
16 ML2_CONF=/etc/neutron/plugins/ml2/ml2_conf.ini
22 function update_ml2conf {
23 echo "Backing up and modifying ml2_conf.ini"
24 cp $ML2_CONF $ML2_CONF.bak
25 sed -i -e 's/mechanism_drivers =openvswitch/mechanism_drivers = opendaylight/g' $ML2_CONF
26 sed -i -e 's/tenant_network_types = flat,vlan,gre,vxlan/tenant_network_types = vxlan/g' $ML2_CONF
27 sed -i -e 's/bridge_mappings=physnet2:br-prv/bridge_mappings=physnet1:br-ex/g' $ML2_CONF
28 echo "[ml2_odl]" >> $ML2_CONF
29 echo "password = admin" >> $ML2_CONF
30 echo "username = admin" >> $ML2_CONF
31 echo "url = http://${CONTROL_HOST}:8080/controller/nb/v2/neutron" >> $ML2_CONF
34 function reset_neutrondb {
36 mysql -e "drop database if exists neutron_ml2;"
37 mysql -e "create database neutron_ml2 character set utf8;"
38 mysql -e "grant all on neutron_ml2.* to 'neutron'@'%';"
39 neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugin.ini upgrade head
42 function restart_neutron {
43 echo "Restarting Neutron Server"
44 service neutron-server restart
45 echo "Should see Neutron runing now"
46 service neutron-server status
47 echo "Shouldnt be any nets, but should work (return empty)"
51 function stop_neutron {
52 echo "Stopping Neutron / OVS components"
53 service neutron-plugin-openvswitch-agent stop
56 service neutron-server stop
60 function disable_agent {
61 echo "Disabling Neutron Plugin Agents from running"
62 service neutron-plugin-openvswitch-agent stop
63 echo 'manual' > /etc/init/neutron-plugin-openvswitch-agent.override
68 function verify_ML2_working {
69 echo "checking that we can talk via ML2 properly"
70 curl -u admin:admin http://${CONTROL_HOST}:8080/controller/nb/v2/neutron/networks > /tmp/check_ml2
71 if grep "network" /tmp/check_ml2
73 echo "Success - ML2 to ODL is working"
75 echo "im sorry Jim, but its dead"
82 if [ -d "/var/lib/glance/images" ]
84 echo "Controller Mode"
93 echo "Stopping OpenVSwitch"
94 service openvswitch-switch stop
100 service openvswitch-vswitch start
105 function control_setup {
106 echo "Modifying Controller"
110 rm -rf /var/log/openvswitch/*
111 mkdir -p /opt/opnfv/odl/ovs_back
112 mv /etc/openvswitch/conf.db /opt/opnfv/odl/ovs_back/.
113 mv /etc/openvswitch/.conf*lock* /opt/opnfv/odl/ovs_back/.
114 rm -rf /etc/openvswitch/conf.db
115 rm -rf /etc/openvswitch/.conf*
116 service openvswitch-switch start
117 ovs-vsctl add-br br-ex
118 ovs-vsctl add-port br-ex eth0
119 ovs-vsctl set interface br-ex type=external
120 ifconfig br-ex 172.30.9.70/24 up
121 service neutron-server restart
123 echo "setting up networks"
124 ip link add link eth1 name br-mgmt type vlan id 300
125 ifconfig br-mgmt `grep address /etc/network/interfaces.d/ifcfg-br-mgmt | awk -F" " '{print $2}'`/24 up arp
126 ip link add link eth1 name br-storage type vlan id 301
127 ip link add link eth1 name br-prv type vlan id 1000
128 ifconfig br-storage `grep address /etc/network/interfaces.d/ifcfg-br-storage | awk -F" " '{print $2}'`/24 up arp
129 ifconfig eth1 `grep address /etc/network/interfaces.d/ifcfg-br-fw-admin | awk -F" " '{print $2}'`/24 up arp
131 echo "Setting ODL Manager IP"
132 ovs-vsctl set-manager tcp:192.168.0.2:6640
134 echo "Verifying ODL ML2 plugin is working"
137 # BAD HACK - Should be parameterized - this is to catch up
138 route add default gw 172.30.9.1
143 echo "cleaning OVS DB"
145 rm -rf /var/log/openvswitch/*
146 mkdir -p /opt/opnfv/odl/ovs_back
147 cp -pr /etc/openvswitch/* /opt/opnfv/odl/ovs_back/.
148 rm -rf /etc/openvswitch/conf.db
149 echo "restarting OVS - you should see Nothing there"
153 function compute_setup {
154 echo "Modifying Compute"
155 echo "Disabling neutron openvswitch plugin"
158 ip link add link eth1 name br-mgmt type vlan id 300
159 ifconfig br-mgmt `grep address /etc/network/interfaces.d/ifcfg-br-mgmt | awk -F" " '{print $2}'`/24 up arp
160 ip link add link eth1 name br-storage type vlan id 301
161 ip link add link eth1 name br-prv type vlan id 1000
162 ifconfig br-storage `grep address /etc/network/interfaces.d/ifcfg-br-storage | awk -F" " '{print $2}'`/24 up arp
163 ifconfig eth1 `grep address /etc/network/interfaces.d/ifcfg-br-fw-admin | awk -F" " '{print $2}'`/24 up arp
165 echo "set manager, and route for ODL controller"
166 ovs-vsctl set-manager tcp:192.168.0.2:6640
167 route add 172.17.0.1 gw 192.168.0.2
173 echo "Starting to make call"
180 echo "Calling control setup"
182 elif [ $MODE == "1" ];
184 echo "Calling compute setup"
188 echo "Something is bad - call for help"