Removed opendaylight build capabilities as a preparation toward Arno SR1
[genesis.git] / fuel / build / f_odl_docker / scripts / config_neutron_for_odl.sh
1 #!/bin/bash
2 CONTROL_HOST=172.17.0.3
3
4 # ENV
5 source ~/openrc
6
7
8
9 # VARS
10 ML2_CONF=/etc/neutron/plugins/ml2/ml2_conf.ini
11 MODE=0
12
13
14 # FUCNTIONS
15
16
17 # Update ml2_conf.ini
18 function update_ml2conf {
19         echo "Backing up and modifying ml2_conf.ini"
20         cp $ML2_CONF $ML2_CONF.bak
21         sed -i -e 's/mechanism_drivers =openvswitch/mechanism_drivers = opendaylight/g' $ML2_CONF
22 #!/bin/bash
23 CONTROL_HOST=172.17.0.3
24
25 # ENV
26 source ~/openrc
27
28
29
30 # VARS
31 ML2_CONF=/etc/neutron/plugins/ml2/ml2_conf.ini
32 MODE=0
33
34
35 # FUCNTIONS
36
37
38 # Update ml2_conf.ini
39 function update_ml2conf {
40         echo "Backing up and modifying ml2_conf.ini"
41         cp $ML2_CONF $ML2_CONF.bak
42         sed -i -e 's/mechanism_drivers =openvswitch/mechanism_drivers = opendaylight/g' $ML2_CONF
43         sed -i -e 's/tenant_network_types = flat,vlan,gre,vxlan/tenant_network_types = vxlan/g' $ML2_CONF
44         cat "[ml2_odl]" >> $ML2_CONF
45         cat "password = admin" >> $ML2_CONF
46         cat "username = admin" >> $ML2_CONF
47         cat "url = http://${CONTROL_HOST}:8080/controller/nb/v2/neutron" >> $ML2_CONF
48 }
49
50 function reset_neutrondb {
51         echo "Reseting DB"
52         mysql -e "drop database if exists neutron_ml2;"
53         mysql -e "create database neutron_ml2 character set utf8;"
54         mysql -e "grant all on neutron_ml2.* to 'neutron'@'%';"
55         neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugin.ini upgrade head
56 }
57
58 function restart_neutron {
59         echo "Restarting Neutron Server"
60         service neutron-server restart
61         echo "Should see Neutron runing now"
62         service neutron-server status
63         echo "Shouldnt be any nets, but should work (return empty)"
64         neutron net-list
65 }
66
67 function stop_neutron {
68         echo "Stopping Neutron / OVS components"
69         service  neutron-plugin-openvswitch-agent stop
70         if [ $MODE == "0" ]
71         then
72                 service neutron-server stop
73         fi
74 }
75
76
77
78 function verify_ML2_working {
79         echo "checking that we can talk via ML2 properly"
80         curl -u admin:admin http://${CONTROL_HOST}:8080/controller/nb/v2/neutron/networks > /tmp/check_ml2
81         if grep "network" /tmp/check_ml2
82         then
83                 echo "Success - ML2 to ODL is working"
84         else
85                 echo "im sorry Jim, but its dead"
86         fi
87
88 }
89
90
91 function set_mode {
92         if df -k | grep glance
93         then
94                 echo "Controller Mode"
95                 MODE=0
96         else
97                 echo "Compute Mode"
98                 MODE=1
99         fi
100 }
101
102 function stop_ovs {
103         echo "Stopping OpenVSwitch"
104         service openvswitch-switch stop
105
106 }
107
108 function control_setup {
109         echo "do control stuff here"
110         echo "Reset Neutron DB"
111         #reset_neutrondb
112         echo "Restarting Neutron Components"
113         #restart_neutron
114         echo "Verifying ODL ML2 plugin is working"
115         verify_ML2_working
116
117 }
118
119 function compute_setup {
120         echo "do compute stuff here"
121         stop_neutron
122         verify_ML2_working
123 }
124
125
126 # MAIN
127 echo "Starting to make call"
128 #update_ml2conf
129 echo "Check Mode"
130 set_mode
131
132 if [ $MODE == "0" ];
133 then
134         echo "Calling control setup"
135         control_setup
136 elif [ $MODE == "1" ];
137 then
138         echo "Calling compute setup"
139         compute_setup
140
141 else
142         echo "Something is bad - call for help"
143         exit
144 fi
145
146