Merge "Fix sphinx warnings (and some formatting)"
[docs.git] / docs / opendaylight-with-openstack / openstack-with-ovsdb.rst
1 OpenStack with OVSDB
2 ====================
3
4 **Prerequisites**: OpenDaylight requires Java 1.7.0.
5
6 * On the control host, `Download
7   the latest OpenDaylight release <ODL_Downloads_>`_ (at the time of writing,
8   this is Boron)
9 * Uncompress it as root, and start OpenDaylight (you can start OpenDaylight
10   by running karaf directly, but exiting from the shell will shut it down):
11
12 .. code-block:: bash
13
14     tar xvfz distribution-karaf-0.5.0-Boron.tar.gz
15     cd distribution-karaf-0.5.0-Boron
16     ./bin/start # Start OpenDaylight as a server process
17
18 * Connect to the Karaf shell, and install the odl-ovsdb-openstack bundle,
19   dlux and their dependencies:
20
21 .. code-block:: bash
22
23     ./bin/client # Connect to OpenDaylight with the client
24     opendaylight-user@root> feature:install odl-base-all odl-aaa-authn odl-restconf odl-nsf-all odl-adsal-northbound odl-mdsal-apidocs odl-ovsdb-openstack odl-ovsdb-northbound odl-dlux-core
25
26 * If everything is installed correctly, you should now be able to log in to
27   the dlux interface on http://$CONTROL_HOST:8181/dlux/index.html - the
28   default username and password is "admin/admin" (see screenshot below)
29
30 .. figure:: images/dlux-default.png
31
32 Ensuring OpenStack network state is clean
33 -----------------------------------------
34
35 When using OpenDaylight as the Neutron back-end, ODL expects to be the only
36 source of truth for Open vSwitch configuration. Because of this, it is
37 necessary to remove existing OpenStack and Open vSwitch configurations to
38 give OpenDaylight a clean slate.
39
40 * Delete instances
41
42 .. code-block:: bash
43
44     nova list
45     nova delete <instance names>
46
47 * Remove link from subnets to routers
48
49 .. code-block:: bash
50
51     neutron subnet-list
52     neutron router-list
53     neutron router-port-list <router name>
54     neutron router-interface-delete <router name> <subnet ID or name>
55
56 * Delete subnets, nets, routers
57
58 .. code-block:: bash
59
60     neutron subnet-delete <subnet name>
61     neutron net-list
62     neutron net-delete <net name>
63     neutron router-delete <router name>
64
65 * Check that all ports have been cleared - at this point, this should be an
66   empty list
67
68 .. code-block:: bash
69
70     neutron port-list
71
72
73 Ensure Neutron is stopped
74 -------------------------
75
76 While Neutron is managing the OVS instances on compute and control nodes,
77 OpenDaylight and Neutron can be in conflict. To prevent issues, we turn off
78 Neutron server on the network controller, and Neutron's Open vSwitch agents
79 on all hosts.
80
81 * Turn off neutron-server on control node
82
83 .. code-block:: bash
84
85     systemctl stop neutron-server
86
87 * On each node in the cluster, shut down and disable Neutron's agent services to ensure that they do not restart after a reboot:
88
89 .. code-block:: bash
90
91     systemctl stop neutron-openvswitch-agent
92     systemctl disable neutron-openvswitch-agent
93
94
95 Configuring Open vSwitch to be managed by OpenDaylight
96 ------------------------------------------------------
97
98 On each host (both compute and control nodes) we will clear the pre-existing
99 Open vSwitch config and set OpenDaylight to manage the switch:
100
101 * Stop the Open vSwitch service, and clear existing OVSDB (ODL expects to
102   manage vSwitches completely)
103
104 .. code-block:: bash
105
106     systemctl stop openvswitch
107     rm -rf /var/log/openvswitch/*
108     rm -rf /etc/openvswitch/conf.db
109     systemctl start openvswitch
110
111 * At this stage, your Open vSwitch configuration should be empty:
112
113 .. code-block:: bash
114
115     [root@dneary-odl-compute2 ~]# ovs-vsctl show
116     9f3b38cb-eefc-4bc7-828b-084b1f66fbfd
117         ovs_version: "2.1.3"
118
119 * Set OpenDaylight as the manager on all nodes
120
121 .. code-block:: bash
122
123     ovs-vsctl set-manager tcp:${CONTROL_HOST}:6640
124
125
126 * You should now see a new section in your Open vSwitch configuration
127   showing that you are connected to the OpenDaylight server, and OpenDaylight
128   will automatically create a br-int bridge:
129
130 .. code-block:: bash
131
132     [root@dneary-odl-compute2 ~]# ovs-vsctl show
133     9f3b38cb-eefc-4bc7-828b-084b1f66fbfd
134         Manager "tcp:172.16.21.56:6640"
135             is_connected: true
136         Bridge br-int
137             Controller "tcp:172.16.21.56:6633"
138             fail_mode: secure
139             Port br-int
140                 Interface br-int
141         ovs_version: "2.1.3"
142
143
144 * (BUG WORKAROUND) If SELinux is enabled, you may not have a security
145   context in place which allows Open vSwitch remote administration. If you
146   do not see the result above (specifically, if you do not see
147   "is_connected: true" in the Manager section), set SELinux to Permissive
148   mode on all nodes and ensure it stays that way after boot:
149
150 .. code-block:: bash
151
152     setenforce 0
153     sed -i -e 's/SELINUX=enforcing/SELINUX=permissive/g' /etc/selinux/config
154
155 * Make sure all nodes, including the control node, are connected to
156   OpenDaylight
157 * If you reload DLUX, you should now see that all of your Open vSwitch nodes
158   are now connected to OpenDaylight
159
160 .. figure:: images/dlux-with-switches.png
161
162 * If something has gone wrong, check ``data/log/karaf.log`` under
163   the OpenDaylight distribution directory. If you do not see any interesting
164   log entries, set logging for OVSDB to TRACE level inside Karaf and try again:
165
166 .. code-block:: bash
167
168     log:set TRACE ovsdb
169
170
171 Configuring Neutron to use OpenDaylight
172 ---------------------------------------
173
174 Once you have configured the vSwitches to connect to OpenDaylight, you can
175 now ensure that OpenStack Neutron is using OpenDaylight.
176
177 First, ensure that port 8080 (which will be used by OpenDaylight to listen
178 for REST calls) is available. By default, swift-proxy-service listens on the
179 same port, and you may need to move it (to another port or another host), or
180 disable that service. I moved it to port 8081 by editing
181 ``/etc/swift/proxy-server.conf`` and
182 ``/etc/cinder/cinder.conf``, modifying iptables appropriately, and
183 restarting swift-proxy-service and OpenDaylight.
184
185 * Configure Neutron to use OpenDaylight's ML2 driver:
186
187 .. code-block:: bash
188
189     crudini --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 mechanism_drivers opendaylight
190     crudini --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 tenant_network_types vxlan
191
192     cat <<EOT>> /etc/neutron/plugins/ml2/ml2_conf.ini
193     [ml2_odl]
194     password = admin
195     username = admin
196     url = http://${CONTROL_HOST}:8080/controller/nb/v2/neutron
197     EOT
198
199 * Reset Neutron's ML2 database
200
201 .. code-block:: bash
202
203     mysql -e "drop database if exists neutron_ml2;"
204     mysql -e "create database neutron_ml2 character set utf8;"
205     mysql -e "grant all on neutron_ml2.* to 'neutron'@'%';"
206     neutron-db-manage --config-file /usr/share/neutron/neutron-dist.conf --config-file /etc/neutron/neutron.conf \
207     --config-file /etc/neutron/plugin.ini upgrade head
208
209 * Restart neutron-server:
210
211 .. code-block:: bash
212
213     systemctl start neutron-server
214
215
216 Verifying it works
217 ------------------
218
219 * Verify that OpenDaylight's ML2 interface is working:
220
221 .. code-block:: bash
222
223     curl -u admin:admin http://${CONTROL_HOST}:8080/controller/nb/v2/neutron/networks
224
225     {
226        "networks" : [ ]
227     }
228
229 If this does not work or gives an error, check Neutron's log file in
230 ``/var/log/neutron/server.log``. Error messages here should give
231 some clue as to what the problem is in the connection with OpenDaylight
232
233 * Create a net, subnet, router, connect ports, and start an instance using
234   the Neutron CLI:
235
236 .. code-block:: bash
237
238     neutron router-create router1
239     neutron net-create private
240     neutron subnet-create private --name=private_subnet 10.10.5.0/24
241     neutron router-interface-add router1 private_subnet
242     nova boot --flavor <flavor> --image <image id> --nic net-id=<network id> test1
243     nova boot --flavor <flavor> --image <image id> --nic net-id=<network id> test2
244
245 At this point, you have confirmed that OpenDaylight is creating network
246 end-points for instances on your network and managing traffic to them.
247
248 Congratulations! You're done!
249
250
251 .. _ODL_Downloads: https://www.opendaylight.org/software/downloads