VTN Beryllium - Adoc changes.
[docs.git] / manuals / user-guide / src / main / asciidoc / vtn / VTN_Manager_How_To_Provision_Virtual_L2_Network.adoc
1 ==== How to provision virtual L2 Network
2
3 ===== Overview
4
5 This page explains how to provision virtual L2 network using VTN Manager. This page targets Beryllium release, so the procedure described here does not work in other releases.
6
7 .EXAMPLE DEMONSTRATING SINGLE CONTROLLER
8 image::vtn/vtn-single-controller-topology-example.png[EXAMPLE DEMONSTRATING SINGLE CONTROLLER]
9
10 ===== Requirements
11
12 ====== Mininet
13
14 * To provision OpenFlow switches, this page uses Mininet. Mininet details and set-up can be referred at the following page:
15 https://wiki.opendaylight.org/view/OpenDaylight_Controller:Installation#Using_Mininet
16
17 * Start Mininet and create three switches(s1, s2, and s3) and four hosts(h1, h2, h3, and h4) in it.
18
19 ----
20  mininet@mininet-vm:~$ sudo mn --controller=remote,ip=192.168.0.100 --topo tree,2
21 ----
22
23 NOTE:
24 Replace "192.168.0.100" with the IP address of OpenDaylight controller based on your environment.
25
26 * you can check the topology that you have created by executing "net" command in the Mininet console.
27
28 ----
29  mininet> net
30  h1 h1-eth0:s2-eth1
31  h2 h2-eth0:s2-eth2
32  h3 h3-eth0:s3-eth1
33  h4 h4-eth0:s3-eth2
34  s1 lo:  s1-eth1:s2-eth3 s1-eth2:s3-eth3
35  s2 lo:  s2-eth1:h1-eth0 s2-eth2:h2-eth0 s2-eth3:s1-eth1
36  s3 lo:  s3-eth1:h3-eth0 s3-eth2:h4-eth0 s3-eth3:s1-eth2
37 ----
38
39 * In this guide, you will provision the virtual L2 network to establish communication between h1 and h3.
40
41 * You need to manually add flow entries to OpenFlow switches in the Mininet. The flow entries are needed to forward packets to controller when there is a table-miss. This configuration is required only in case of Openflow 1.3 or using OVS version(>2.1.1).
42
43 ----
44  sudo ovs-ofctl add-flow s1 priority=0,actions=output:CONTROLLER
45  sudo ovs-ofctl add-flow s2 priority=0,actions=output:CONTROLLER
46  sudo ovs-ofctl add-flow s3 priority=0,actions=output:CONTROLLER
47 ----
48
49 ===== Configuration
50
51 To provision the virtual L2 network for the two hosts (h1 and h3), execute REST API provided by VTN Manager as follows. It uses curl command to call the REST API.
52
53 * Create a virtual tenant named vtn1 by executing
54   https://jenkins.opendaylight.org/releng/view/vtn/job/vtn-merge-beryllium/lastSuccessfulBuild/artifact/manager/model/target/site/models/vtn.html#update-vtn[the update-vtn RPC].
55
56 ----
57 curl --user "admin":"admin" -H "Content-type: application/json" -X POST http://localhost:8181/restconf/operations/vtn:update-vtn -d '{"input":{"tenant-name":"vtn1"}}'
58 ----
59
60 * Create a virtual bridge named vbr1 in the tenant vtn1 by executing
61   https://jenkins.opendaylight.org/releng/view/vtn/job/vtn-merge-beryllium/lastSuccessfulBuild/artifact/manager/model/target/site/models/vtn-vbridge.html#update-vbridge[the update-vbridge RPC].
62
63 ----
64 curl --user "admin":"admin" -H "Content-type: application/json" -X POST http://localhost:8181/restconf/operations/vtn-vbridge:update-vbridge -d '{"input":{"tenant-name":"vtn1", "bridge-name":"vbr1"}}'
65 ----
66
67 * Create two interfaces into the virtual bridge by executing
68   https://jenkins.opendaylight.org/releng/view/vtn/job/vtn-merge-beryllium/lastSuccessfulBuild/artifact/manager/model/target/site/models/vtn-vinterface.html#update-vinterface[the update-vinterface RPC].
69
70 ----
71 curl --user "admin":"admin" -H "Content-type: application/json" -X POST http://localhost:8181/restconf/operations/vtn-vinterface:update-vinterface -d '{"input":{"tenant-name":"vtn1", "bridge-name":"vbr1", "interface-name":"if1"}}'
72 ----
73
74
75 ----
76 curl --user "admin":"admin" -H "Content-type: application/json" -X POST http://localhost:8181/restconf/operations/vtn-vinterface:update-vinterface -d '{"input":{"tenant-name":"vtn1", "bridge-name":"vbr1", "interface-name":"if2"}}'
77 ----
78
79 * Configure two mappings on the created interfaces by executing
80   https://jenkins.opendaylight.org/releng/view/vtn/job/vtn-merge-beryllium/lastSuccessfulBuild/artifact/manager/model/target/site/models/vtn-port-map.html#set-port-map[the set-port-map RPC].
81
82 ** The interface if1 of the virtual bridge will be mapped to the port "s2-eth1" of the switch "openflow:2" of the Mininet.
83 *** The h1 is connected to the port "s2-eth1".
84
85 ** The interface if2 of the virtual bridge will be mapped to the port "s3-eth1" of the switch "openflow:3" of the Mininet.
86 *** The h3 is connected to the port "s3-eth1".
87
88 ----
89 curl --user "admin":"admin" -H "Content-type: application/json" -X POST http://localhost:8181/restconf/operations/vtn-port-map:set-port-map -d '{"input":{"tenant-name":"vtn1", "bridge-name":"vbr1", "interface-name":"if1", "node":"openflow:2", "port-name":"s2-eth1"}}'
90 ----
91
92
93 ----
94 curl --user "admin":"admin" -H "Content-type: application/json" -X POST http://localhost:8181/restconf/operations/vtn-port-map:set-port-map -d '{"input":{"tenant-name":"vtn1", "bridge-name":"vbr1", "interface-name":"if2", "node":"openflow:3", "port-name":"s3-eth1"}}'
95 ----
96
97 ===== Verification
98
99 * Please execute ping from h1 to h3 to verify if the virtual L2 network for h1 and h3 is provisioned successfully.
100
101 ----
102  mininet> h1 ping h3
103  PING 10.0.0.3 (10.0.0.3) 56(84) bytes of data.
104  64 bytes from 10.0.0.3: icmp_seq=1 ttl=64 time=243 ms
105  64 bytes from 10.0.0.3: icmp_seq=2 ttl=64 time=0.341 ms
106  64 bytes from 10.0.0.3: icmp_seq=3 ttl=64 time=0.078 ms
107  64 bytes from 10.0.0.3: icmp_seq=4 ttl=64 time=0.079 ms
108 ----
109
110 * You can also verify the configuration by executing the following REST API. It shows all configuration in VTN Manager.
111
112 ----
113 curl --user "admin":"admin" -H "Content-type: application/json" -X GET http://localhost:8181/restconf/operational/vtn:vtns/
114 ----
115
116 * The result of the command should be like this.
117
118 ----
119 {
120   "vtns": {
121     "vtn": [
122     {
123       "name": "vtn1",
124         "vtenant-config": {
125           "idle-timeout": 300,
126           "hard-timeout": 0
127         },
128         "vbridge": [
129         {
130           "name": "vbr1",
131           "bridge-status": {
132             "state": "UP",
133             "path-faults": 0
134           },
135           "vbridge-config": {
136             "age-interval": 600
137           },
138           "vinterface": [
139           {
140             "name": "if2",
141             "vinterface-status": {
142               "entity-state": "UP",
143               "state": "UP",
144               "mapped-port": "openflow:3:3"
145             },
146             "vinterface-config": {
147               "enabled": true
148             },
149             "port-map-config": {
150               "vlan-id": 0,
151               "port-name": "s3-eth1",
152               "node": "openflow:3"
153             }
154           },
155           {
156             "name": "if1",
157             "vinterface-status": {
158               "entity-state": "UP",
159               "state": "UP",
160               "mapped-port": "openflow:2:1"
161             },
162             "vinterface-config": {
163               "enabled": true
164             },
165             "port-map-config": {
166               "vlan-id": 0,
167               "port-name": "s2-eth1",
168               "node": "openflow:2"
169             }
170           }
171           ]
172         }
173       ]
174     }
175     ]
176   }
177 }
178 ----
179
180 ===== Cleaning Up
181
182 * You can delete the virtual tenant vtn1 by executing
183 https://jenkins.opendaylight.org/releng/view/vtn/job/vtn-merge-beryllium/lastSuccessfulBuild/artifact/manager/model/target/site/models/vtn.html#remove-vtn[the remove-vtn RPC].
184
185 ----
186 curl --user "admin":"admin" -H "Content-type: application/json" -X POST http://localhost:8181/restconf/operations/vtn:remove-vtn -d '{"input":{"tenant-name":"vtn1"}}'
187 ----
188
189
190