Migrate ALTO user docs to rst
[docs.git] / manuals / developer-guide / src / main / asciidoc / ovsdb / ovsdb-overview.adoc
1 === OVSDB Integration\r
2 The Open vSwitch database (OVSDB) Southbound Plugin component for OpenDaylight implements\r
3 the OVSDB  https://tools.ietf.org/html/rfc7047[RFC 7047] management protocol\r
4 that allows the southbound configuration of switches that support OVSDB. The\r
5 component comprises a library and a plugin. The OVSDB protocol\r
6 uses JSON-RPC calls to manipulate a physical or virtual switch that supports OVSDB.\r
7 Many vendors support OVSDB on various hardware platforms.\r
8 The OpenDaylight controller uses the library project to interact with an OVS\r
9 instance.\r
10 \r
11 NOTE:\r
12 Read the OVSDB User Guide before you begin development.\r
13 \r
14 ==== OpenDaylight OVSDB integration\r
15 The OpenStack integration architecture uses the following technologies:\r
16 \r
17 * https://tools.ietf.org/html/rfc7047[RFC 7047] - The Open vSwitch Database Management Protocol\r
18 * http://www.opennetworking.org/images/stories/downloads/sdn-resources/onf-specifications/openflow/openflow-switch-v1.3.4.pdf[OpenFlow v1.3]\r
19 * https://wiki.openstack.org/wiki/Neutron/ML2[OpenStack Neutron ML2 Plugin]\r
20 \r
21 ===== OpenDaylight Mechanism Driver for Openstack Neutron ML2\r
22 This code is a part of OpenStack and is available at: https://github.com/openstack/neutron/blob/master/neutron/plugins/ml2/drivers/mechanism_odl.py\r
23 \r
24 The ODL neutron driver implementation can be found at: https://github.com/openstack/networking-odl\r
25 \r
26 To make changes to this code, please read about https://wiki.openstack.org/wiki/NeutronDevelopment[Neutron Development].\r
27 \r
28 Before submitting the code, run the following tests:\r
29 \r
30 ----\r
31 tox -e py27\r
32 tox -e pep8\r
33 ----\r
34 \r
35 ===== Importing the code in to Eclipse or IntelliJ\r
36 To import code, look at either of the following pages:\r
37 \r
38 * https://wiki.opendaylight.org/view/Eclipse_Setup[Getting started with Eclipse]\r
39 * https://wiki.opendaylight.org/view/OpenDaylight_Controller:Developing_With_Intellij[Developing with Intellij]\r
40 \r
41 .Avoid conflicting project names\r
42 image::OVSDB_Eclipse.png[]\r
43 \r
44 * To ensure that a project in Eclipse does not have a conflicting name in the workspace, select Advanced > Name Template > [groupId].[artifactId] when importing the project.\r
45 \r
46 ===== Browsing the code\r
47 The code is mirrored to https://github.com/opendaylight/ovsdb[GitHub] to make reading code online easier. \r
48 \r
49 ===== Source code organization\r
50 \r
51 The OVSDB project generates the following Karaf modules:\r
52 \r
53 * ovsdb.karaf  -- all openstack netvirt related artifacts\r
54 * ovsdb.library-karaf -- the OVSDB library reference implementation\r
55 * ovsdb.openstack.net-virt-sfc-karaf  -- openflow service function chaining\r
56 * ovsdb.hwvtepsouthbound-karaf -- the hw_vtep schema southbound plugin\r
57 * ovsdb.southbound-karaf - the Open_vSwitch schema plugin\r
58 \r
59 Following are a brief descriptions on directories you will find a the root ovsdb/ directory:\r
60 \r
61 * _commons_ contains the parent POM file for Maven project which is used to get consistency of settings across the project.\r
62 \r
63 * _features_ contains all the Karaf related feature files.\r
64 \r
65 * _hwvtepsouthbound_ contains the hw_vtep southbound plugin.\r
66 \r
67 * _karaf_ contains the ovsdb library and southbound and OpenStack bundles for the OpenStack integration.\r
68 \r
69 * _library_ contains a schema-independent library that is a reference implementation for RFC 7047.\r
70 \r
71 * _openstack_ contains the northbound handlers for Neutron used by OVSDB, as well as their providers. The NetVirt SFC implementation is also located here.\r
72 \r
73 * _ovsdb-ui_ contains the DLUX implementation for displaying network virtualization.\r
74 \r
75 * _resources_ contains useful scripts, how-tos, demos and other resources.\r
76 \r
77 * _schemas_ contains the OVSDB schemas that are implemented in OpenDaylight.\r
78 \r
79 * _southbound_ contains the plugin for converting from the OVSDB protocol to MD-SAL and vice-versa.\r
80 \r
81 * _utils_ contains a collection of utilities for using the OpenFlow plugin, southbound, Neutron and other helper methods.\r
82 \r
83 ==== Building and running OVSDB\r
84 *Prerequisites* +\r
85 \r
86 * JDK 1.7+\r
87 * Maven 3+\r
88 \r
89 [[ovsdbBuildSteps]]\r
90 ===== Building a Karaf feature and deploying it in an Opendaylight Karaf distribution +\r
91 . From the root ovsdb/ directory, run *mvn clean install*.\r
92 . Unzip the karaf-<VERSION_NUMBER>-SNAPSHOT.zip file created from step 1 in the directory ovsdb/karaf/target/:\r
93 ----\r
94 unzip karaf-<VERSION_NUMBER>-SNAPSHOT.zip\r
95 ----\r
96 ===== Downloading OVSDB's Karaf distribution +\r
97 Instead of building, you can download the latest OVSDB distribution from the Nexus server. The link for that is:\r
98 ----\r
99 https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/org/opendaylight/ovsdb/karaf/1.3.0-SNAPSHOT/\r
100 ----\r
101 \r
102 ===== Running Karaf feature from OVSDB's Karaf distribution +\r
103 \r
104 [[ovsdbStartingOdl]]\r
105 . Start ODL, from the unzipped directory\r
106 ----\r
107 bin/karaf\r
108 ----\r
109 . Once karaf has started, and you see the Opendaylight ascii art in the console, the last step is to start the OVSDB plugin framework with the following command in the karaf console: \r
110 ----\r
111 feature:install odl-ovsdb-openstack\r
112 ----\r
113 \r
114 ====== Sample output from the Karaf console\r
115 ----\r
116 opendaylight-user@root>feature:list | grep -i ovsdb \r
117 opendaylight-user@root>feature:list -i | grep ovsdb\r
118 odl-ovsdb-southbound-api          | 1.2.1-SNAPSHOT   | x         | odl-ovsdb-southbound-1.2.1-SNAPSHOT     | OpenDaylight :: southbound :: api\r
119 odl-ovsdb-southbound-impl         | 1.2.1-SNAPSHOT   | x         | odl-ovsdb-southbound-1.2.1-SNAPSHOT     | OpenDaylight :: southbound :: impl\r
120 odl-ovsdb-southbound-impl-rest    | 1.2.1-SNAPSHOT   | x         | odl-ovsdb-southbound-1.2.1-SNAPSHOT     | OpenDaylight :: southbound :: impl :: REST\r
121 odl-ovsdb-southbound-impl-ui      | 1.2.1-SNAPSHOT   | x         | odl-ovsdb-southbound-1.2.1-SNAPSHOT     | OpenDaylight :: southbound :: impl :: UI\r
122 odl-ovsdb-library                 | 1.2.1-SNAPSHOT   | x         | odl-ovsdb-library-1.2.1-SNAPSHOT        | OpenDaylight :: library\r
123 odl-ovsdb-openstack               | 1.2.1-SNAPSHOT   | x         | ovsdb-1.2.1-SNAPSHOT                    | OpenDaylight :: OVSDB :: OpenStack Network Virtual\r
124 ----\r
125 \r
126 ===== Testing patches\r
127 It is recommended that you test your patches locally before submission.\r
128 \r
129 ===== Neutron integration\r
130 To test patches to the Neutron integration, you need a http://devstack.org/guides/multinode-lab.html[Multi-Node Devstack Setup]. The ``resources`` folder contains sample ``local.conf`` files.\r
131 \r
132 ===== Open vSwitch\r
133 To test patches to the library, you will need a working http://openvswitch.org/[Open vSwitch]. Packages are available for most Linux distributions. If you would like to run multiple versions of Open vSwitch for testing you can use https://github.com/dave-tucker/docker-ovs[docker-ovs] to run Open vSwitch in https://www.docker.com/[Docker] containers. \r
134 \r
135 ===== Mininet\r
136 http://mininet.org/[Mininet] is another useful resource for testing patches. Mininet creates multiple Open vSwitches connected in a configurable topology. \r
137 \r
138 ===== Vagrant\r
139 The Vagrant file in the root of the OVSDB source code provides an easy way to create VMs for tests.\r
140 \r
141 * To install Vagrant on your machine, follow the steps at: https://docs.vagrantup.com/v2/installation/[Installing Vagrant].\r
142 \r
143 *Testing with Devstack*\r
144 \r
145 . Start the controller.\r
146 ----\r
147 vagrant up devstack-control\r
148 vagrant ssh devstack-control\r
149 cd devstack\r
150 ./stack.sh\r
151 ----\r
152 [start=2]\r
153 . Run the following:\r
154 ----\r
155 vagrant up devstack-compute-1\r
156 vagrant ssh devstack-compute-1\r
157 cd devstack\r
158 ./stack.sh\r
159 ----\r
160 [start=3]\r
161 . To start testing, create a new VM.\r
162 ----\r
163 nova boot --flavor m1.tiny --image $(nova image-list | grep 'cirros-0.3.1-x86_64-uec\s' | awk '{print $2}') --nic net-id=$(neutron net-list | grep private | awk '{print $2}') test\r
164 ----\r
165 To create three, use the following:\r
166 ----\r
167 nova boot --flavor m1.tiny --image $(nova image-list | grep 'cirros-0.3.1-x86_64-uec\s' | awk '{print $2}') --nic net-id=$(neutron net-list | grep private | awk '{print $2}') --num-instances 3 test\r
168 ----\r
169 [start=4]\r
170 .To get a mininet installation for testing:\r
171 ----\r
172 vagrant up mininet\r
173 vagrant ssh mininet\r
174 ----\r
175 [start=5]\r
176 . Use the following to clean up when finished:\r
177 ----\r
178 vagrant destroy\r
179 ----\r
180 \r
181 ==== OVSDB integration design\r
182 ===== Resources\r
183 See the following: +\r
184 \r
185 * http://networkheresy.com/2012/09/15/remembering-the-management-plane/[Network Heresy]\r
186 \r
187 See the OVSDB YouTube Channel for getting started videos and other tutorials: +\r
188 \r
189 * http://www.youtube.com/channel/UCMYntfZ255XGgYFrxCNcAzA[ODL OVSDB Youtube Channel]\r
190 * https://wiki.opendaylight.org/view/OVSDB_Integration:Mininet_OVSDB_Tutorial[Mininet OVSDB Tutorial]\r
191 * https://wiki.opendaylight.org/view/OVSDB_Integration:Main#Getting_Started_with_OpenDaylight_OVSDB_Plugin_Network_Virtualization[OVSDB Getting Started]\r
192 \r
193 ==== OpenDaylight OVSDB southbound plugin architecture and design\r
194 OpenVSwitch (OVS) is generally accepted as the unofficial standard for Virtual Switching in the Open hypervisor based solutions. Every other Virtual Switch implementation, properietery or otherwise, uses OVS in some form.\r
195 For information on OVS, see http://openvswitch.org/[Open vSwitch].\r
196 \r
197 In Software Defined Networking (SDN), controllers and applications interact using two channels: OpenFlow and OVSDB. OpenFlow addresses the forwarding-side of the OVS functionality. OVSDB, on the other hand, addresses the management-plane. \r
198 A simple and concise overview of Open Virtual Switch Database(OVSDB) is available at: http://networkstatic.net/getting-started-ovsdb/\r
199 \r
200 ===== Overview of OpenDaylight Controller architecture\r
201 The OpenDaylight controller platform is designed as a highly modular and plugin based middleware that serves various network applications in a variety of use-cases. The modularity is achieved through the Java OSGi framework. The controller consists of many Java OSGi bundles that work together to provide the required\r
202  controller functionalities. \r
203  \r
204 The bundles can be placed in the following broad categories: +\r
205 \r
206 * Network Service Functional Modules (Examples: Topology Manager, Inventory Manager, Forwarding Rules Manager,and others) \r
207 * NorthBound API Modules (Examples: Topology APIs, Bridge Domain APIs, Neutron APIs, Connection Manager APIs, and others) \r
208 * Service Abstraction Layer(SAL)- (Inventory Services, DataPath Services, Topology Services, Network Config, and others) \r
209 * SouthBound Plugins (OpenFlow Plugin, OVSDB Plugin, OpenDove Plugin, and others) \r
210 * Application Modules (Simple Forwarding, Load Balancer)\r
211 \r
212 Each layer of the Controller architecture performs specified tasks, and hence aids in modularity. \r
213 While the Northbound API layer addresses all the REST-Based application needs, the SAL layer takes care of abstracting the SouthBound plugin protocol specifics from the Network Service functions. \r
214  \r
215 Each of the SouthBound Plugins serves a different purpose, with some overlapping.\r
216 For example, the OpenFlow plugin might serve the Data-Plane needs of an OVS element, while the OVSDB plugin can serve the management plane needs of the same OVS element.\r
217 As the Openflow Plugin talks OpenFlow protocol with the OVS element, the OVSDB plugin will use OVSDB schema over JSON-RPC transport.\r
218 \r
219 ==== OVSDB southbound plugin\r
220 The http://tools.ietf.org/html/draft-pfaff-ovsdb-proto-02[Open vSwitch Database Management Protocol-draft-02] and http://openvswitch.org/ovs-vswitchd.conf.db.5.pdf[Open vSwitch Manual] provide theoretical information about OVSDB.\r
221 The OVSDB protocol draft is generic enough to lay the groundwork on Wire Protocol and Database Operations, and the OVS Manual currently covers 13 tables leaving space for future OVS expansion, and vendor expansions on proprietary implementations.\r
222 The OVSDB Protocol is a database records transport protocol using JSON RPC1.0. For information on the protocol structure, see http://networkstatic.net/getting-started-ovsdb/[Getting Started with OVSDB].\r
223 The OpenDaylight OVSDB southbound plugin consists of one or more OSGi bundles addressing the following services or functionalities: +\r
224 \r
225 * Connection Service - Based on Netty \r
226 * Network Configuration Service \r
227 * Bidirectional JSON-RPC Library \r
228 * OVSDB Schema definitions and Object mappers \r
229 * Overlay Tunnel management \r
230 * OVSDB to OpenFlow plugin mapping service \r
231 * Inventory Service \r
232 \r
233 ==== Connection service\r
234 One of the primary services that most southbound plugins provide in Opendaylight a Connection Service. The service provides protocol specific connectivity to network elements, and supports the connectivity management services as specified by the OpenDaylight Connection Manager.\r
235 The connectivity services include: +\r
236 \r
237 * Connection to a specified element given IP-address, L4-port, and other connectivity options (such as authentication,...) \r
238 * Disconnection from an element \r
239 * Handling Cluster Mode change notifications to support the OpenDaylight Clustering/High-Availability feature \r
240 \r
241 ==== Network Configuration Service\r
242 The goal of the OpenDaylight Network Configuration services is to provide complete management plane solutions needed to successfully install, configure, and deploy the various SDN based network services. These are generic services which can be implemented in part or full by any south-bound protocol plugin.\r
243 The south-bound plugins can be either of the following: +\r
244 \r
245 * The new network virtualization protocol plugins such as OVSDB JSON-RPC\r
246 * The traditional management protocols such as SNMP or any others in the middle. \r
247 \r
248 The above definition, and more information on Network Configuration Services, is available at : https://wiki.opendaylight.org/view/OpenDaylight_Controller:NetworkConfigurationServices \r
249 \r
250 ===== Bidirectional JSON-RPC library\r
251 The OVSDB plugin implements a Bidirectional JSON-RPC library.  It is easy to design the library as a module that manages the Netty connection towards the Element. \r
252 \r
253 The main responsibilities of this Library are: +\r
254 \r
255 * Demarshal and marshal JSON Strings to JSON objects \r
256 * Demarshal and marshal JSON Strings from and to the Network Element.\r
257 \r
258 ===== OVSDB Schema definitions and Object mappers\r
259 The OVSDB Schema definitions and Object Mapping layer sits above the JSON-RPC library. It maps the generic JSON objects to OVSDB schema POJOs (Plain Old Java Object) and vice-versa. This layer mostly provides the Java Object definition for the corresponding OVSDB schema (13 of them) and also will provide much more friendly API abstractions on top of these object data. This helps in hiding the JSON semantics from the functional modules such as Configuration Service and Tunnel management.\r
260 \r
261 On the demarshaling side the mapping logic differentiates the Request and Response messages as follows : +\r
262 \r
263 * Request messages are mapped by its "method" \r
264 * Response messages are mapped by their IDs which were originally populated by the Request message.\r
265 The JSON semantics of these OVSDB schema is quite complex.\r
266 The following figures summarize two of the end-to-end scenarios: +\r
267 \r
268 .End-to-end handling of a Create Bridge request\r
269 image::ConfigurationService-example1.png[width=500]\r
270 \r
271 .End-to-end handling of a monitor response\r
272 image::MonitorResponse.png[width=500]\r
273 \r
274 ===== Overlay tunnel management\r
275 \r
276 Network Virtualization using OVS is achieved through Overlay Tunnels. The actual Type of the Tunnel may be GRE, VXLAN, or STT. The differences in the encapsulation and configuration decide the tunnel types. Establishing a tunnel using configuration service requires just the sending of OVSDB messages towards the ovsdb-server. However, the scaling issues that would arise on the state management at the data-plane (using OpenFlow) can get challenging. Also, this module can assist in various optimizations in the presence of Gateways. It can also help in providing Service guarantees for the VMs using these overlays with the help of underlay orchestration. \r
277 \r
278 ===== OVSDB to OpenFlow plugin mapping service\r
279 The connect() of the ConnectionService  would result in a Node that represents an ovsdb-server. The CreateBridgeDomain() Configuration on the above Node would result in creating an OVS bridge. This OVS Bridge is an OpenFlow Agent for the OpenDaylight OpenFlow plugin with its own Node represented as (example) OF|xxxx.yyyy.zzzz. \r
280 Without any help from the OVSDB plugin, the Node Mapping Service of the Controller platform would not be able to map the following: +\r
281 ----\r
282 {OVSDB_NODE + BRIDGE_IDENTFIER} <---> {OF_NODE}.\r
283 ----\r
284 Without such mapping, it would be extremely difficult for the applications to manage and maintain such nodes. This Mapping Service provided by the OVSDB plugin would essentially help in providing more value added services to the orchestration layers that sit atop the Northbound APIs (such as OpenStack). \r
285 \r
286 ==== OpenDaylight OVSDB Developer Getting Started Video Series\r
287 The video series were started to help developers bootstrap into OVSDB development.\r
288 \r
289 * http://www.youtube.com/watch?v=ieB645oCIPs[OpenDaylight OVSDB Developer Getting Started]\r
290 * http://www.youtube.com/watch?v=xgevyaQ12cg[OpenDaylight OVSDB Developer Getting Started - Northbound API Usage]\r
291 * http://www.youtube.com/watch?v=xgevyaQ12cg[OpenDaylight OVSDB Developer Getting Started - Java APIs]\r
292 * http://www.youtube.com/watch?v=NayuY6J-AMA[OpenDaylight OVSDB Developer Getting Started - OpenStack Integration OpenFlow v1.0]\r
293 \r
294 ===== Other developer tutorials\r
295 \r
296 * https://docs.google.com/presentation/d/1KIuNDuUJGGEV37Zk9yzx9OSnWExt4iD2Z7afycFLf_I/edit?usp=sharing[OVSDB NetVirt Tutorial]\r
297 * https://www.youtube.com/watch?v=2axNKHvt5MY&list=PL8F5jrwEpGAiJG252ShQudYeodGSsks2l&index=43[Youtube of OVSDB NetVirt tutorial]\r
298 * https://wiki.opendaylight.org/view/OVSDB:OVSDB_OpenStack_Guide[OVSDB OpenFlow v1.3 Neutron ML2 Integration]\r
299 * http://networkstatic.net/getting-started-ovsdb/[Open vSwitch Database Table Explanations and Simple Jackson Tutorial]\r
300 \r
301 ==== OVSDB integration: New features\r
302 ===== Schema independent library\r
303 The OVS connection is a node which can have multiple databases. Each database is represented by a schema. A single connection can have multiple schemas.\r
304 OSVDB supports multiple schemas. Currently, these are two schemas available in the\r
305 OVSDB, but there is no restriction on the number of schemas. Owing to the Northbound v3 API, no code changes in ODL are needed for supporting additional schemas.\r
306 \r
307 Schemas: +\r
308 \r
309 *  openvswitch : Schema wrapper that represents http://openvswitch.org/ovs-vswitchd.conf.db.5.pdf\r
310 *  hardwarevtep: Schema wrapper that represents http://openvswitch.org/docs/vtep.5.pdf\r
311 \r
312 ===== Port security\r
313 Based on the fact that security rules can be obtained from a port object, OVSDB can apply Open Flow rules. These rules will match on what types of traffic the Openstack tenant VM is allowed to use.\r
314  \r
315 Support for security groups is very experimental. There are limitations in determining the state of flows in the Open vSwitch. See http://%20https//www.youtube.com/watch?v=DSop2uLJZS8[Open vSwitch and the Intelligent Edge] from Justin Petit for a deep dive into the challenges we faced creating a flow based port security implementation. The current set of rules that will be installed only supports filtering of the TCP protocol. This is because via a Nicira TCP_Flag read we can match on a flows TCP_SYN flag, and permit or deny the flow based on the Neutron port security rules. If rules are requested for ICMP and UDP, they are ignored until greater visibility from the Linux kernel is available as outlined in the OpenStack presentation mentioned earlier. \r
316 \r
317 Using the port security groups of Neutron, one can add rules that restrict the network access of the tenants. The OVSDB Neutron integration checks the port security rules configured, and apply them by means of openflow rules. \r
318 \r
319 Through the ML2 interface, Neutron security rules are available in the port object, following this scope: Neutron Port -> Security Group -> Security Rules. \r
320 \r
321 The current rules are applied on the basis of the following attributes: ingress/egress, tcp protocol, port range, and prefix.\r
322  \r
323 ====== OpenStack workflow\r
324 . Create a stack.\r
325 . Add the network and subnet. \r
326 . Add the Security Group and Rules.\r
327 \r
328 NOTE: This is no different than what users normally do in regular openstack deployments. \r
329 ----\r
330 neutron security-group-create group1 --description "Group 1"\r
331 neutron security-group-list\r
332 neutron security-group-rule-create --direction ingress --protocol tcp group1\r
333 ----\r
334 [start=4]\r
335 . Start the tenant, specifying the security-group.\r
336 ----\r
337 nova boot --flavor m1.tiny \\r
338 --image $(nova image-list | grep 'cirros-0.3.1-x86_64-uec\s' | awk '{print $2}') \\r
339 --nic net-id=$(neutron net-list | grep 'vxlan2' | awk '{print $2}') vxlan2 \\r
340 --security-groups group1\r
341 ----\r
342 ====== Examples: Rules supported\r
343 ----\r
344 neutron security-group-create group2 --description "Group 2"\r
345 neutron security-group-rule-create --direction ingress --protocol tcp --port-range-min 54 group2\r
346 neutron security-group-rule-create --direction ingress --protocol tcp --port-range-min 80 group2\r
347 neutron security-group-rule-create --direction ingress --protocol tcp --port-range-min 1633 group2\r
348 neutron security-group-rule-create --direction ingress --protocol tcp --port-range-min 22 group2\r
349 ----\r
350 ----\r
351 neutron security-group-create group3 --description "Group 3"\r
352 neutron security-group-rule-create --direction ingress --protocol tcp --remote-ip-prefix 10.200.0.0/16 group3\r
353 ----\r
354 ----\r
355 neutron security-group-create group4 --description "Group 4"\r
356 neutron security-group-rule-create --direction ingress --remote-ip-prefix 172.24.0.0/16 group4\r
357 ----\r
358 ----\r
359 neutron security-group-create group5 --description "Group 5"\r
360 neutron security-group-rule-create --direction ingress --protocol tcp group5\r
361 neutron security-group-rule-create --direction ingress --protocol tcp --port-range-min 54 group5\r
362 neutron security-group-rule-create --direction ingress --protocol tcp --port-range-min 80 group5\r
363 neutron security-group-rule-create --direction ingress --protocol tcp --port-range-min 1633 group5\r
364 neutron security-group-rule-create --direction ingress --protocol tcp --port-range-min 22 group5\r
365 ----\r
366 ----\r
367 neutron security-group-create group6 --description "Group 6"\r
368 neutron security-group-rule-create --direction ingress --protocol tcp --remote-ip-prefix 0.0.0.0/0 group6\r
369 ----\r
370 ----\r
371 neutron security-group-create group7 --description "Group 7"\r
372 neutron security-group-rule-create --direction egress --protocol tcp --port-range-min 443 --remote-ip-prefix 172.16.240.128/25 group7\r
373 ----\r
374 *Reference gist*:https://gist.github.com/anonymous/1543a410d57f491352c8[Gist]\r
375 \r
376 ====== Security group rules supported in ODL \r
377 The following rules formata are supported in the current implementation. The direction (ingress/egress) is always expected. Rules are implemented such that tcp-syn packets that do not satisfy the rules are dropped.\r
378 [cols="3", width="60%"]\r
379 |===\r
380 | Proto | Port | IP Prefix\r
381 \r
382 |TCP |x |x\r
383 |Any | Any |x\r
384 |TCP |x |Any\r
385 |TCP |Any |Any\r
386 |===\r
387 \r
388 ====== Limitations\r
389 * Soon, conntrack will be supported by OVS. Until then, TCP flags are used as way of checking for connection state. Specifically, that is done by matching on the TCP-SYN flag.\r
390 * The param '--port-range-max' in 'security-group-rule-create' is not used until the implementation uses contrack. \r
391 * No UDP/ICMP specific match support is provided.\r
392 * No IPv6 support is provided.\r
393 \r
394 ===== L3 forwarding\r
395 OVSDB extends support for the usage of an ODL-Neutron-driver so that OVSDB can configure OF 1.3 rules to route IPv4 packets. The driver eliminates the need for the router of the L3 Agent. In order to accomplish that, OVS 2.1 or a newer version is required.\r
396 OVSDB also supports inbound/outbound NAT, floating IPs.\r
397 \r
398 ====== Starting OVSDB and OpenStack\r
399 . Build or download OVSDB distribution, as mentioned in <<ovsdbBuildSteps,building a Karaf feature section>>.\r
400 . http://docs.vagrantup.com/v2/installation/index.html[Install Vagrant].\r
401 \r
402 [start=3]\r
403 . Enable the L3 Forwarding feature:\r
404 ----\r
405 echo 'ovsdb.l3.fwd.enabled=yes' >> ./opendaylight/configuration/config.ini\r
406 echo 'ovsdb.l3gateway.mac=${GATEWAY_MAC}' >> ./configuration/config.ini\r
407 ----\r
408 [start=4]\r
409 . Run the following commands to get the odl neutron drivers:\r
410 [start=5]\r
411 ----\r
412 git clone https://github.com/dave-tucker/odl-neutron-drivers.git\r
413 cd odl-neutron-drivers\r
414 vagrant up devstack-control devstack-compute-1\r
415 ----\r
416 [start=6]\r
417 . Use ssh to go to the control node, and clone odl-neutron-drivers again:\r
418 ----\r
419 vagrant ssh devstack-control\r
420 git clone https://github.com/dave-tucker/odl-neutron-drivers.git\r
421 cd odl-neutron-drivers\r
422 sudo python setup.py install\r
423 *leave this shell open*\r
424 ----\r
425 [start=7]\r
426 . Start odl, as mentioned in <<ovsdbStartingOdl,running Karaf feature section>>.\r
427 [start=8]\r
428 . To see processing of neutron event related to L3, do this from prompt:\r
429 ----\r
430 log:set debug org.opendaylight.ovsdb.openstack.netvirt.impl.NeutronL3Adapter\r
431 ----\r
432 [start=9]\r
433 . From shell, do one of the following: open on ssh into control node or vagrant ssh devstack-control.\r
434 ----\r
435 cd ~/devstack && ./stack.sh\r
436 ----\r
437 [start=10]\r
438 . From a new shell in the host system, run the following:\r
439 ----\r
440 cd odl-neutron-drivers\r
441 vagrant ssh devstack-compute-1\r
442 cd ~/devstack && ./stack.sh\r
443 ----\r
444 \r
445 ====== OpenStack workflow\r
446 .Sample workflow\r
447 image::L3FwdSample.png[height=250]\r
448 \r
449 Use the following steps to set up a workflow like the one shown in figure above.\r
450 \r
451 . Set up authentication. From shell on stack control or vagrant ssh devstack-control:\r
452 ----\r
453 source openrc admin admin\r
454 ----\r
455 \r
456 ----\r
457 rm -f id_rsa_demo* ; ssh-keygen -t rsa -b 2048 -N  -f id_rsa_demo\r
458  nova keypair-add --pub-key  id_rsa_demo.pub  demo_key\r
459  # nova keypair-list\r
460 ----\r
461 [start=2]\r
462 . Create two networks and two subnets.\r
463 ----\r
464 neutron net-create net1 --tenant-id $(keystone tenant-list | grep '\s'admin | awk '{print $2}') \\r
465  --provider:network_type gre --provider:segmentation_id 555\r
466 ----\r
467 ----\r
468 neutron subnet-create --tenant-id $(keystone tenant-list | grep '\s'admin | awk '{print $2}') \\r
469 net1 10.0.0.0/16 --name subnet1 --dns-nameserver 8.8.8.8\r
470 ----\r
471 ----\r
472 neutron net-create net2 --tenant-id $(keystone tenant-list | grep '\s'admin | awk '{print $2}') \\r
473  --provider:network_type gre --provider:segmentation_id 556\r
474 ----\r
475 ----\r
476 neutron subnet-create --tenant-id $(keystone tenant-list | grep '\s'admin | awk '{print $2}') \\r
477  net2 20.0.0.0/16 --name subnet2 --dns-nameserver 8.8.8.8\r
478 ----\r
479 [start=3]\r
480 . Create a router, and add an interface to each of the two subnets.\r
481 ----\r
482 neutron router-create demorouter --tenant-id $(keystone tenant-list | grep '\s'admin | awk '{print $2}')\r
483  neutron router-interface-add demorouter subnet1\r
484  neutron router-interface-add demorouter subnet2\r
485  # neutron router-port-list demorouter\r
486 ----\r
487 [start=4]\r
488 . Create two tenant instances.\r
489 ----\r
490 nova boot --poll --flavor m1.nano --image $(nova image-list | grep 'cirros-0.3.2-x86_64-uec\s' | awk '{print $2}') \\r
491  --nic net-id=$(neutron net-list | grep -w net1 | awk '{print $2}'),v4-fixed-ip=10.0.0.10 \\r
492  --availability-zone nova:devstack-control \\r
493  --key-name demo_key host10\r
494 ----\r
495 ----\r
496 nova boot --poll --flavor m1.nano --image $(nova image-list | grep 'cirros-0.3.2-x86_64-uec\s' | awk '{print $2}') \\r
497  --nic net-id=$(neutron net-list | grep -w net2 | awk '{print $2}'),v4-fixed-ip=20.0.0.20 \\r
498  --availability-zone nova:devstack-compute-1 \\r
499  --key-name demo_key host20\r
500 ----\r
501 \r
502 ====== Limitations\r
503 * To use this feature, you need OVS 2.1 or newer version.\r
504 * Owing to OF limitations, icmp responses due to routing failures, like ttl expired or host unreacheable, are not generated.\r
505 * The MAC address of the default route is not automatically mapped. In order to route to L3 destinations outside the networks of the tenant, the manual configuration of the default route is necessary. To provide the MAC address of the default route, use ovsdb.l3gateway.mac in file configuration/config.ini ; \r
506 * This feature is Tech preview, which depends on later versions of OpenStack to be used without the provided neutron-driver. \r
507 * No IPv6 support is provided.\r
508  \r
509 *More information on L3 forwarding*: +\r
510 \r
511 * odl-neutron-driver: https://github.com/dave-tucker/odl-neutron-drivers\r
512 * OF rules example: http://dtucker.co.uk/hack/building-a-router-with-openvswitch.html\r
513 \r
514 ===== LBaaS\r
515 Load-Balancing-as-a-Service (LBaaS) creates an Open vSwitch powered L3-L4 stateless load-balancer in a virtualized network environment so that individual TCP connections destined to a designated virtual IP (VIP) are sent to the appropriate servers (that is to say, serving app VMs). The load-balancer works in a session-preserving, proactive manner without involving the controller during flow setup.\r
516 \r
517 A Neutron northbound interface is provided to create a VIP which will map to a pool of servers (that is to say, members) within a subnet. The pools consist of members identified by an IP address. The goal is to closely match the API to the OpenStack LBaaS v2 API: http://docs.openstack.org/api/openstack-network/2.0/content/lbaas_ext.html.\r
518 \r
519 ====== Creating an OpenStack workflow\r
520 . Create a subnet. \r
521 . Create a floating VIP 'A' that maps to a private VIP 'B'. \r
522 . Create a Loadbalancer pool 'X'. \r
523 ----\r
524 neutron lb-pool-create --name http-pool --lb-method ROUND_ROBIN --protocol HTTP --subnet-id XYZ\r
525 ----\r
526 [start=4]\r
527 . Create a Loadbalancer pool member 'Y' and associate with pool 'X'. \r
528 ----\r
529 neutron lb-member-create --address 10.0.0.10 --protocol-port 80 http-pool\r
530 neutron lb-member-create --address 10.0.0.11 --protocol-port 80 http-pool\r
531 neutron lb-member-create --address 10.0.0.12 --protocol-port 80 http-pool\r
532 neutron lb-member-create --address 10.0.0.13 --protocol-port 80 http-pool\r
533 ----\r
534 [start=5]\r
535 . Create a Loadbalancer instance 'Z', and associate pool 'X' and VIP 'B' with it.\r
536 ----\r
537 neutron lb-vip-create --name http-vip --protocol-port 80 --protocol HTTP --subnet-id XYZ http-pool\r
538 ----\r
539 \r
540 ====== Implementation\r
541 \r
542 The current implementation of the proactive stateless load-balancer was made using "multipath" action in the Open vSwitch. The "multipath" action takes a max_link parameter value (which is same as the number of pool members) as input, and performs a hash of the fields to get a value between (0, max_link). The value of the hash is used as an index to select a pool member to handle that session. \r
543 \r
544 ===== Open vSwitch rules\r
545 Assuming that table=20 contains all the rules to forward the traffic destined for a specific destination MAC address, the following are the rules needed to be programmed in the LBaaS service table=10. The programmed rules makes the translation from the VIP to a different pool member for every session.\r
546 \r
547 * Proactive forward rules:\r
548 ----\r
549 sudo ovs-ofctl -O OpenFlow13 add-flow s1 "table=10,reg0=0,ip,nw_dst=10.0.0.5,actions=load:0x1->NXM_NX_REG0[[]],multipath(symmetric_l4, 1024, modulo_n, 4, 0, NXM_NX_REG1[0..12]),resubmit(,10)"\r
550 sudo ovs-ofctl -O OpenFlow13 add-flow s1 table=10,reg0=1,nw_dst=10.0.0.5,ip,reg1=0,actions=mod_dl_dst:00:00:00:00:00:10,mod_nw_dst:10.0.0.10,goto_table:20\r
551 sudo ovs-ofctl -O OpenFlow13 add-flow s1 table=10,reg0=1,nw_dst=10.0.0.5,ip,reg1=1,actions=mod_dl_dst:00:00:00:00:00:11,mod_nw_dst:10.0.0.11,goto_table:20\r
552 sudo ovs-ofctl -O OpenFlow13 add-flow s1 table=10,reg0=1,nw_dst=10.0.0.5,ip,reg1=2,actions=mod_dl_dst:00:00:00:00:00:12,mod_nw_dst:10.0.0.12,goto_table:20\r
553 sudo ovs-ofctl -O OpenFlow13 add-flow s1 table=10,reg0=1,nw_dst=10.0.0.5,ip,reg1=3,actions=mod_dl_dst:00:00:00:00:00:13,mod_nw_dst:10.0.0.13,goto_table:20\r
554 ----\r
555 * Proactive reverse rules: \r
556 ----\r
557 sudo ovs-ofctl -O OpenFlow13 add-flow s1 table=10,ip,tcp,tp_src=80,actions=mod_dl_src:00:00:00:00:00:05,mod_nw_src:10.0.0.5,goto_table:20\r
558 ---- \r
559 \r
560 ====== OVSDB project code\r
561 The current implementation handles all neutron calls in the net-virt/LBaaSHandler.java code, and makes calls to the net-virt-providers/LoadBalancerService to program appropriate flowmods. The rules are updated whenever there is a change in the Neutron LBaaS settings. There is no cache of state kept in the net-virt or providers. \r
562 \r
563 ====== Limitations\r
564 Owing to the inflexibility of the multipath action, the existing LBaaS implementation comes with some limitations: \r
565 \r
566 * TCP, HTTP or HTTPS are supported protocols for the pool. (Caution: You can lose access to the members if you assign {Proto:TCP, Port:22} to LB) \r
567 \r
568 * Member weights are ignored. \r
569 * The update of an LB instance is done as a delete + add, and not an actual delta. \r
570 * The update of an LB member is not supported (because weights are ignored). \r
571 * Deletion of an LB member leads to the reprogramming of the LB on all nodes (because of the way multipath does link hash).\r
572 * There is only a single LB instance per subnet because the pool-id is not reported in the create load-balancer call. \r
573 \r
574 \r
575 \r
576 \r
577 \r
578 \r
579 \r
580 \r
581 \r
582                        \r
583 \r
584 \r