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 CONTROL_HOST=172.30.9.70
15 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 cat "[ml2_odl]" >> $ML2_CONF
28 cat "password = admin" >> $ML2_CONF
29 cat "username = admin" >> $ML2_CONF
30 cat "url = http://${CONTROL_HOST}:8080/controller/nb/v2/neutron" >> $ML2_CONF
33 function reset_neutrondb {
35 mysql -e "drop database if exists neutron_ml2;"
36 mysql -e "create database neutron_ml2 character set utf8;"
37 mysql -e "grant all on neutron_ml2.* to 'neutron'@'%';"
38 neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugin.ini upgrade head
41 function restart_neutron {
42 echo "Restarting Neutron Server"
43 service neutron-server restart
44 echo "Should see Neutron runing now"
45 service neutron-server status
46 echo "Shouldnt be any nets, but should work (return empty)"
50 function stop_neutron {
51 echo "Stopping Neutron / OVS components"
52 service neutron-plugin-openvswitch-agent stop
55 service neutron-server stop
61 function verify_ML2_working {
62 echo "checking that we can talk via ML2 properly"
63 curl -u admin:admin http://${CONTROL_HOST}:8080/controller/nb/v2/neutron/networks > /tmp/check_ml2
64 if grep "network" /tmp/check_ml2
66 echo "Success - ML2 to ODL is working"
68 echo "im sorry Jim, but its dead"
75 if ls -l /var/lib/glance/images
77 echo "Controller Mode"
86 echo "Stopping OpenVSwitch"
87 service openvswitch-switch stop
91 function control_setup {
92 echo "Modifying Controller"
95 rm -rf /var/log/openvswitch/*
96 mkdir -p /opt/opnfv/odl/ovs_back
97 mv /etc/openvswitch/conf.db /opt/opnfv/odl/ovs_back/.
98 mv /etc/openvswitch/.conf*lock* /opt/opnfv/odl/ovs_back/.
99 service openvswitch-switch start
100 ovs-vsctl set-manager tcp:172.30.9.70:6640
101 ovs-vsctl add-br br-eth0
102 ovs-vsctl add-br br-ex
103 ovs-vsctl add-port br-eth0 eth0
104 ovs-vsctl add-port br-eth0 br-eth0--br-ex
105 ovs-vsctl add-port br-ex br-ex--br-eth0
106 ovs-vsctl set interface br-ex--br-eth0 type=patch
107 ovs-vsctl set interface br-eth0--br-ex type=patch
108 ovs-vsctl set interface br-ex--br-eth0 options:peer=br-eth0--br-ex
109 ovs-vsctl set interface br-eth0--br-ex options:peer=br-ex--br-eth0
110 ifconfig br-ex 172.30.9.70/24 up
111 service neutron-server restart
113 echo "setting up networks"
114 ip link add link eth1 name br-mgmt type vlan id 300
115 ip link add link eth1 name br-storage type vlan id 301
116 /etc/init.d/networking restart
119 echo "Reset Neutron DB"
121 echo "Restarting Neutron Components"
123 echo "Verifying ODL ML2 plugin is working"
128 function compute_setup {
129 echo "do compute stuff here"
130 echo "stopping neutron openvswitch plugin"
132 ip link add link eth1 name br-mgmt type vlan id 300
133 ifconfig br-mgmt `grep address /etc/network/interfaces.d/ifcfg-br-mgmt | awk -F" " '{print $2}'`/24
134 ip link add link eth1 name br-storage type vlan id 301
135 ifconfig br-storage `grep address /etc/network/interfaces.d/ifcfg-br-storage | awk -F" " '{print $2}'`/24
136 ifconfig eth1 `grep address /etc/network/interfaces.d/ifcfg-br-fw-mgmt | awk -F" " '{print $2}'`/24
137 echo "set manager, and route for ODL controller"
138 ovs-vsctl set-manager tcp:192.168.0.2:6640
139 route add 172.17.0.1 gw 192.168.0.2
145 echo "Starting to make call"
152 echo "Calling control setup"
154 elif [ $MODE == "1" ];
156 echo "Calling compute setup"
160 echo "Something is bad - call for help"