Fix/cleanup: Added missing license headers and removed unused files.
[osm/vim-emu.git] / src / emuvim / api / openstack / openstack_dummies / NeutronSFC.md
1 <!--
2 # Copyright (c) 2017 SONATA-NFV and Paderborn University
3 # ALL RIGHTS RESERVED.
4
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #    http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #
17 # Neither the name of the SONATA-NFV, Paderborn University
18 # nor the names of its contributors may be used to endorse or promote
19 # products derived from this software without specific prior written
20 # permission.
21 #
22 # This work has been performed in the framework of the SONATA project,
23 # funded by the European Commission under Grant number 671517 through
24 # the Horizon 2020 and 5G-PPP programmes. The authors would like to
25 # acknowledge the contributions of their colleagues of the SONATA
26 # partner consortium (www.sonata-nfv.eu).
27 -->
28
29 A complete description of the Service Function Chaining API can be found under
30 https://docs.openstack.org/developer/networking-sfc/api.html
31
32 ### Working Example
33 This section describes a complete, working example of the SFC API with Sonata.
34 The following diagram shows the structure of the service chain that will be created.
35
36 ```
37 +-------+      +------+     +------+     +-------+
38 | Host1 |      | VNF1 |     | VNF2 |     | Host2 |
39 +-------+      +------+     +------+     +-------+
40      |p1       p2|  |p3     p4|  |p5      p6|
41      |           |  |         |  |          |           PC1 = {{p1, p2}, {p3, p4}, {p5, p6}}
42      +------>----+  +---->----+  +---->-----+
43      |                                      |
44      ^                                      v           PC2 = {{p6, p1}}
45      +-------------------<------------------+
46 ```
47 Two port chains, PC1 and PC2, are created. PC1 chains packets from Host1 over VNF1 and VNF2 to Host2.
48 Both network functions, VNF1 and VNF2, simply forward all packets from ingress to egress. PC2 creates a
49 direct chain from Host2 to Host1, such that replies can be routed send back.
50 (Note: Port chains are unidirectional)
51
52 #### Prerequisites
53 The following python packages required in order for the Openstack CLI commands to work.
54 ```
55 sudo pip install python-openstackclient networking-sfc
56 ```
57 Also the docker images `ubuntu:trusty` and `sonatanfv/sonata-snort-ids-vnf` have to be locally available
58 (otherwise Sonata cannot start the containers).
59
60 #### Execution
61 First, start the DCEmulator:
62 ```
63 sudo python src/emuvim/examples/openstack_single_dc.py
64 ```    
65 It creates a single data center and connects it to an instance of the Openstack API listening on `http://0.0.0.0:6001`.
66
67 Then execute the following script. It starts the containers and sets up the port chains as described above.
68 Finally a ping from Host1 to Host2 is executed to check the connection established by the port chains.
69
70 ```
71 export OS_USERNAME="admin"
72 export OS_PASSWORD="nope"
73 export OS_PROJECT_NAME="nope"
74 export OS_AUTH_URL="http://0.0.0.0:6001"
75
76 # 1. Create ports
77 openstack port create --network default p1
78 openstack port create --network default p2
79 openstack port create --network default p3
80 openstack port create --network default p4
81 openstack port create --network default p5
82 openstack port create --network default p6
83
84 # 2. Start servers
85 openstack server create --image ubuntu:trusty --flavor m1.tiny --port p1 Host1
86 openstack server create --image sonatanfv/sonata-snort-ids-vnf --flavor m1.tiny \
87   --port p2 --port p3 --property IFIN="p2-0" --property IFOUT="p3-0" VNF1
88 openstack server create --image sonatanfv/sonata-snort-ids-vnf --flavor m1.tiny \
89   --port p4 --port p5 --property IFIN="p4-0" --property IFOUT="p5-0" VNF2
90 openstack server create --image ubuntu:trusty --flavor m1.tiny --port p6 Host2
91
92 # 3. Create port pairs
93 openstack sfc port pair create --ingress p1 --egress p2 PP1
94 openstack sfc port pair create --ingress p3 --egress p4 PP2
95 openstack sfc port pair create --ingress p5 --egress p6 PP3
96 openstack sfc port pair create --ingress p6 --egress p1 PP4 # for direct ping reply Host2->Host1
97
98 # 4. Create port groups
99 openstack sfc port pair group create --port-pair PP1 --port-pair PP2 --port-pair PP3 PPG1
100 openstack sfc port pair group create --port-pair PP4 PPG2
101
102 # 5. Create port chain
103 openstack sfc port chain create --port-pair-group PPG1 PC1
104 openstack sfc port chain create --port-pair-group PPG2 PC2
105
106 # 6. Test the port chain
107 export HOST1_DOCKER=$(openstack server list | grep "Host1" | awk '{print "mn."$4}')
108 export HOST2_IP=$(openstack port show p6 | grep fixed_ips \
109   | awk 'match($4, "\x27,") {print substr($4, 13, RSTART - 13)}')
110 sudo docker exec -it ${HOST1_DOCKER} ping -c 5 ${HOST2_IP}
111 ```
112
113 To verify that the port chains actually works, commenting out the creation of either port chain (step 5)
114 will result in the ping packets not getting through.
115
116 ### Unimplemented Features
117 While all functions of the API are implemented and can be called, some of the internal functionality
118 remains unimplemented at the moment:
119 * Updating/deleting port chains (the metadata is updated, but the implemented chain is not)
120 * FlowClassifiers (can be called, metadata is handles but not actually implemented with the chain)