This repository has been archived by the owner on Oct 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
commands.txt
250 lines (194 loc) · 9.06 KB
/
commands.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
This is a quick guide for having fast access to the SC commands
== ADMIN
Please, login as root, as many examples need certain privileges.
$ su
> osboxes.org
== YANG
$ cd /root/OFC_SC472/yang
$ cat topology.yang
$ pyang -f tree topology.yang
$ pyang -f tree topology.yang -o topology.tree
$ pyang -f sample-xml-skeleton --sample-xml-skeleton-annotations topology.yang
$ pyang -f uml topology.yang -o topology.uml
$ java -jar plantuml.jar topology.uml
=== PYANGBIND
$ export PYBINDPLUGIN=`/usr/bin/env python3 -c \
'import pyangbind; import os; print ("{}/plugin".format(os.path.dirname(pyangbind.__file__)))'`
$ echo $PYBINDPLUGIN
$ pyang -f pybind topology.yang --plugindir $PYBINDPLUGIN -o binding_topology.py
$ python3 topology.py
=== EXERCISE: CONNECTION
$ cd /root/OFC_SC472/yang/connection
$ python3 connection.py
== NETCONF
Run server:
$ cd /root/OFC_SC472/netconf
$ python3 serverTopology.py
In another window, run client:
$ cd /root/OFC_SC472/netconf
$ python3 clientTopology.py
=== EXERCISE: NETCONF EDIT-CONFIG
Run server:
$ cd /root/OFC_SC472/netconf/connection
$ python3 serverTopologyConnection.py
In another window, run client:
$ cd /root/OFC_SC472/netconf/connection
$ python3 clientConnection.py
== RESTCONF
=== YANG2SWAGGER
$ cd /root/OFC_SC472/restconf
(if needed)
$ wget https://github.com/bartoszm/yang2swagger/releases/download/1.1.11/swagger-generator-cli-1.1.11-executable.jar
Generate swagger files:
$ java -jar swagger-generator-cli-1.1.11-executable.jar -yang-dir ../yang/ -output topology.yaml topology
$ java -jar swagger-generator-cli-1.1.11-executable.jar -yang-dir ../yang/ -output connection.yaml connection
=== SERVER
$ cd /root/OFC_SC472/restconf
(if needed)
$ wget https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/3.0.11/swagger-codegen-cli-3.0.11.jar -O swagger-codegen-cli.jar
Create the server:
$ mkdir /root/OFC_SC472/restconf/server
$ java -jar swagger-codegen-cli.jar generate -i connection.yaml -l python-flask -o server
Run the server:
$ cd /root/OFC_SC472/restconf/server
$ pip3 install -r requirements.txt
(Open /root/OFC_SC472/restconf/server/swagger_server/swagger/swagger.yaml and modify all: "name: connection_id" for "name: connection-id")
RUN AUTOGENERATED SERVER
$ python3 -m swagger_server
(you have the solution in /root/OFC_SC472/restconf/connectionserver )
RUN CURL AS CLIENT (In another window)
$ cd /root/OFC_SC472/restconf/
$ curl -X POST -H "Content-Type: application/yang-data+json" http://127.0.0.1:8080/data/connection/ -d@conn1.json
$ curl -X GET -H "Content-Type: application/yang-data+json" http://127.0.0.1:8080/data/connection=0/
$ curl -X DELETE -H "Content-Type: application/yang-data+json" http://127.0.0.1:8080/data/connection=0/
=== Exercise: RESTCONF TOPOLOGY ===
$ mkdir /root/OFC_SC472/restconf/topologyserver
$ java -jar swagger-codegen-cli.jar generate -i topology.yaml -l python-flask -o topologyserver
$ cd /root/OFC_SC472/restconf/topologyserver
(Open /root/OFC_SC472/restconf/topologyserver/swagger_server/swagger/swagger.yaml and modify all: "name: link_id" for "name: link-id", same for node and port)
$ python3 -m swagger_server
RUN CURL AS CLIENT (In another window)
$curl -X GET -H "Content-Type: application/yang-data+json" http://127.0.0.1:8080/data/topology/
== TAPI
RUN TAPI SERVER:
$ cd /root/OFC_SC472/tapi/server
$ python3 tapi_server.py
RUN TAPI CLIENT (In a new window):
$ cd /root/OFC_SC472/tapi/client
$ curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/config/context/
$ curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/config/context/service-interface-point/
$ curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/config/context/service-interface-point/sip-pe1-uni1/
$ curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/config/context/topology/
$ curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/config/context/topology/topo-nwk/
$ curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/config/context/topology/topo-nwk/node/
$ curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/config/context/topology/topo-nwk/node/node-pe-1/
$ curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/config/context/topology/topo-nwk/node/node-pe-1/owned-node-edge-point/
$ curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/config/context/topology/topo-nwk/node/node-pe-1/owned-node-edge-point/NEP_PE_01_UNI1/
$ curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/config/context/topology/topo-nwk/link/PE1_NNI3_PI3_NNI1/
CONNECTIONS:
$ curl -X POST -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/config/context/connectivity-service/cs1/ -d @cs1.json
$ curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/config/context/connectivity-service/
$ curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/config/context/connectivity-service/cs1/
$ curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/config/context/connection/cs1/
$ curl -X DELETE -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/config/context/connectivity-service/cs1/
EXERCISE: TAPI_APP
$ cd /root/OFC_SC472/tapi/tapi_app
$ python3 tapi_app.py
== GRPC
$ cd /root/OFC_SC472/grpc
COMPILE connection.proto:
$ python -m grpc_tools.protoc -I=. --python_out=connection/ connection.proto
RUN CREATE AND LIST CONNECTION
$ cd /root/OFC_SC472/grpc/connection
$ python3 create.py connection.txt
$ python3 list.py connection.txt
COMPILE connectionService.proto
$ python -m grpc_tools.protoc -I=. --python_out=connectionService/ --grpc_python_out=connectionService/ connectionService.proto
RUN SERVER
$ cd /root/OFC_SC472/grpc/connectionService
$ python3 connectionService_server.py
RUN CLIENT (in another window)
$ cd /root/OFC_SC472/grpc/connectionService
$ python3 connectionService_client.py
### EXERCISE
COMPILE connectionServiceWithNotif.proto
$ cd /root/OFC_SC472/grpc/
$ python -m grpc_tools.protoc -I=. --python_out=connectionServiceWithNotif/ --grpc_python_out=connectionServiceWithNotif/ connectionServiceWithNotif.proto
RUN SERVER
$ cd /root/OFC_SC472/grpc/connectionServiceWithNotif
$ python3 connectionServiceWithNotif_server.py
RUN CLIENT (in another window)
$ cd /root/OFC_SC472/grpc/connectionServiceWithNotif
$ python3 connectionServiceWithNotif_client.py
== GNMI
$ cd /usr/share/gocode/src/
$ export GOPATH=/usr/share/gocode/
$ go run github.com/openconfig/ygot/generator/generator.go -generate_fakeroot -output_file github.com/google/gnxi/gnmi/modeldata/gostruct/generated.go -package_name gostruct github.com/rvilalta/OFC_SC472/yang/topology.yang
$ cd /usr/share/gocode/src/github.com/google/gnxi/gnmi_target
$ go run gnmi_target.go -bind_address :10161 -config /root/OFC_SC472/gnmi/topology.json --notls -alsologtostderr
RUN CLIENT (in another window)
$ export GOPATH=/usr/share/gocode/
$ cd /usr/share/gocode/src/github.com/google/gnxi/gnmi_get
$ go run gnmi_get.go -notls -xpath "/topology/" -target_addr localhost:10161 -alsologtostderr
$ go run gnmi_get.go -notls -xpath "/topology/node[node-id=A]" -target_addr localhost:10161 -alsologtostderr
USE PYTHON CLIENT
$ cd /usr/share/gocode/src/github.com/google/gnxi/gnmi_cli_py
$ python py_gnmicli.py -n -m get -t localhost -p 10161 -x /topology -u foo -pass bar
== KAFKA
$ cd /root/OFC_SC472/kafka
(INSTALL)
$ pip3 install kafka-python
$ wget https://ftp.cixug.es/apache/kafka/2.8.0/kafka_2.13-2.8.0.tgz
$ tar -xzf kafka_2.13-2.8.0.tgz
(RUN)
$ cd kafka_2.13-2.8.0
$ bin/zookeeper-server-start.sh config/zookeeper.properties
(In new window)
$ cd /root/OFC_SC472/kafka/kafka_2.13-2.8.0
$ bin/kafka-server-start.sh config/server.properties
CREATE TOPIC
(In new window)
$ cd /root/OFC_SC472/kafka/kafka_2.13-2.8.0
$ bin/kafka-topics.sh --create --topic my-topic --bootstrap-server localhost:9092
(In new window)
$ cd /root/OFC_SC472/kafka
$ python3 sub.py
(In new window)
$ cd /root/OFC_SC472/kafka
$ python3 pub.py
== APPENDIX: CONFD
$ cd /root/OFC_SC472/netconf
$ unzip confd-basic-6.4.linux.x86_64.zip
$ cd confd-basic-6.4.linux.x86_64/
$ ./confd-basic-6.4.linux.x86_64.installer.bin /root/confd/
Data model compilation
$ cd /root/confd/bin/
$ ./confdc -c /root/OFC_SC472/yang/topology.yang
Start ConfD
$ ./confd --foreground -v --addloadpath .
In another terminal, use ConfD-client to populate model
$ cd /root/confd/bin/
$ ./confd_cli
> conf
> topology node node1
> exit
> commit
> exit
> exit
Use ConfD-client to show db
$ ./confd_cli
> conf
> show full-configuration
> exit
> exit
== RUN ONOS
$ cd /root/onos-2.1.0/apache-karaf-4.2.3/bin/
$ ./karaf clean
> app activate org.onosproject.openflow
> app activate org.onosproject.gui
In another terminal, run mininet:
$ mn --topo linear,3 --mac --controller=remote,ip=127.0.0.1,port=6653 --switch ovs,protocols=OpenFlow13
In another terminal, we use ONOS REST API:
$ curl -X GET -u onos:rocks --header 'Accept: application/json' http://localhost:8181/onos/v1/links | python -m json.tool
$ cd /root/OFC_SC472/onos_api/
$ python3 onos_topology.py