blob: eb270bad78ed2f0665ea04b38d84a86ac4282e15 [file] [log] [blame]
Ubuntu82b8a832013-02-06 22:00:11 +00001#! /usr/bin/env python
2import pprint
3import os
4import sys
5import subprocess
6import json
7import argparse
8import io
9import time
Masayoshi Kobayashi2ae891a2013-04-05 02:16:19 +000010import random
Ubuntu82b8a832013-02-06 22:00:11 +000011
Masayoshi Kobayashi51011522013-03-27 00:18:12 +000012import re
13
Ubuntu82b8a832013-02-06 22:00:11 +000014from flask import Flask, json, Response, render_template, make_response, request
15
Masayoshi Kobayashi2ae891a2013-04-05 02:16:19 +000016## Global Var for ON.Lab local REST ##
Ubuntuf6ce96c2013-02-07 01:45:07 +000017RestIP="localhost"
Ubuntu82b8a832013-02-06 22:00:11 +000018RestPort=8080
Masayoshi Kobayashia9ed33a2013-03-27 23:14:18 +000019
20## Uncomment the desired block based on your testbed environment
Masayoshi Kobayashia9ed33a2013-03-27 23:14:18 +000021# Settings for running on production
Masayoshi Kobayashi03e64b42013-04-05 05:56:27 +000022#controllers=["onosgui1", "onosgui2", "onosgui3", "onosgui4", "onosgui5", "onosgui6", "onosgui7", "onosgui8"]
23#core_switches=["00:00:00:00:ba:5e:ba:11", "00:00:00:00:00:00:ba:12", "00:00:20:4e:7f:51:8a:35", "00:00:00:00:ba:5e:ba:13", "00:00:00:08:a2:08:f9:01", "00:00:00:16:97:08:9a:46"]
24#ONOS_GUI3_HOST="http://gui3.onlab.us:8080"
25#ONOS_GUI3_CONTROL_HOST="http://gui3.onlab.us:8081"
Masayoshi Kobayashia9ed33a2013-03-27 23:14:18 +000026
27# Settings for running on dev testbed. Replace dev
28#controllers=["onosdevb1", "onosdevb2", "onosdevb3", "onosdevb4"]
Masayoshi Kobayashi03e64b42013-04-05 05:56:27 +000029controllers=["onosdevt1", "onosdevt2", "onosdevt3", "onosdevt4", "onosdevt5", "onosdevt6", "onosdevt7", "onosdevt8"]
30core_switches=["00:00:00:00:00:00:01:01", "00:00:00:00:00:00:01:02", "00:00:00:00:00:00:01:03", "00:00:00:00:00:00:01:04", "00:00:00:00:00:00:01:05", "00:00:00:00:00:00:01:06"]
Masayoshi Kobayashia9ed33a2013-03-27 23:14:18 +000031
Masayoshi Kobayashi03e64b42013-04-05 05:56:27 +000032ONOS_GUI3_HOST="http://devt-gui.onlab.us:8080"
33ONOS_GUI3_CONTROL_HOST="http://devt-gui.onlab.us:8080"
Masayoshi Kobayashi1e072382013-03-27 05:17:09 +000034
Masayoshi Kobayashi2ae891a2013-04-05 02:16:19 +000035LB=True #; True or False
36ONOS_DEFAULT_HOST="localhost" ;# Has to set if LB=False
Ubuntu82b8a832013-02-06 22:00:11 +000037
38DEBUG=1
Ubuntu82b8a832013-02-06 22:00:11 +000039
Masayoshi Kobayashi2ae891a2013-04-05 02:16:19 +000040pp = pprint.PrettyPrinter(indent=4)
Ubuntu82b8a832013-02-06 22:00:11 +000041app = Flask(__name__)
42
43## Worker Functions ##
44def log_error(txt):
45 print '%s' % (txt)
46
47def debug(txt):
48 if DEBUG:
49 print '%s' % (txt)
50
Ubuntu82b8a832013-02-06 22:00:11 +000051### File Fetch ###
52@app.route('/ui/img/<filename>', methods=['GET'])
53@app.route('/img/<filename>', methods=['GET'])
54@app.route('/css/<filename>', methods=['GET'])
55@app.route('/js/models/<filename>', methods=['GET'])
56@app.route('/js/views/<filename>', methods=['GET'])
57@app.route('/js/<filename>', methods=['GET'])
58@app.route('/lib/<filename>', methods=['GET'])
Masayoshi Kobayashi3d049312013-04-02 22:15:16 +000059@app.route('/log/<filename>', methods=['GET'])
Ubuntu82b8a832013-02-06 22:00:11 +000060@app.route('/', methods=['GET'])
61@app.route('/<filename>', methods=['GET'])
62@app.route('/tpl/<filename>', methods=['GET'])
Masayoshi Kobayashi13e2ebe2013-03-26 18:38:41 +000063@app.route('/ons-demo/<filename>', methods=['GET'])
64@app.route('/ons-demo/js/<filename>', methods=['GET'])
65@app.route('/ons-demo/css/<filename>', methods=['GET'])
66@app.route('/ons-demo/assets/<filename>', methods=['GET'])
67@app.route('/ons-demo/data/<filename>', methods=['GET'])
Ubuntu82b8a832013-02-06 22:00:11 +000068def return_file(filename="index.html"):
69 if request.path == "/":
70 fullpath = "./index.html"
71 else:
72 fullpath = str(request.path)[1:]
73
Masayoshi Kobayashi03e64b42013-04-05 05:56:27 +000074 try:
75 open(fullpath)
76 except:
77 response = make_response("Cannot find a file: %s" % (fullpath), 500)
78 response.headers["Content-type"] = "text/html"
79 return response
80
Ubuntu82b8a832013-02-06 22:00:11 +000081 response = make_response(open(fullpath).read())
82 suffix = fullpath.split(".")[-1]
83
84 if suffix == "html" or suffix == "htm":
85 response.headers["Content-type"] = "text/html"
86 elif suffix == "js":
87 response.headers["Content-type"] = "application/javascript"
88 elif suffix == "css":
89 response.headers["Content-type"] = "text/css"
90 elif suffix == "png":
91 response.headers["Content-type"] = "image/png"
Paul Greyson2913af82013-03-27 14:53:17 -070092 elif suffix == "svg":
93 response.headers["Content-type"] = "image/svg+xml"
Ubuntu82b8a832013-02-06 22:00:11 +000094
95 return response
96
Masayoshi Kobayashi2ae891a2013-04-05 02:16:19 +000097## Proxy ##
Paul Greyson4e6dc3a2013-03-27 11:37:14 -070098@app.route("/proxy/gui/link/<cmd>/<src_dpid>/<src_port>/<dst_dpid>/<dst_port>")
99def proxy_link_change(cmd, src_dpid, src_port, dst_dpid, dst_port):
100 try:
Paul Greyson8d1c6362013-03-27 13:05:24 -0700101 command = "curl -s %s/gui/link/%s/%s/%s/%s/%s" % (ONOS_GUI3_CONTROL_HOST, cmd, src_dpid, src_port, dst_dpid, dst_port)
Paul Greyson4e6dc3a2013-03-27 11:37:14 -0700102 print command
103 result = os.popen(command).read()
104 except:
105 print "REST IF has issue"
106 exit
107
108 resp = Response(result, status=200, mimetype='application/json')
109 return resp
110
Masayoshi Kobayashi03e64b42013-04-05 05:56:27 +0000111@app.route("/proxy/gui/switchctrl/<cmd>")
112def proxy_switch_controller_setting(cmd):
113 try:
114 command = "curl -s %s/gui/switchctrl/%s" % (ONOS_GUI3_CONTROL_HOST, cmd)
115 print command
116 result = os.popen(command).read()
117 except:
118 print "REST IF has issue"
119 exit
120
121 resp = Response(result, status=200, mimetype='application/json')
122 return resp
123
Paul Greyson8d1c6362013-03-27 13:05:24 -0700124@app.route("/proxy/gui/switch/<cmd>/<dpid>")
125def proxy_switch_status_change(cmd, dpid):
126 try:
127 command = "curl -s %s/gui/switch/%s/%s" % (ONOS_GUI3_CONTROL_HOST, cmd, dpid)
128 print command
129 result = os.popen(command).read()
130 except:
131 print "REST IF has issue"
132 exit
Paul Greyson4e6dc3a2013-03-27 11:37:14 -0700133
Paul Greyson8d1c6362013-03-27 13:05:24 -0700134 resp = Response(result, status=200, mimetype='application/json')
135 return resp
Paul Greyson4e6dc3a2013-03-27 11:37:14 -0700136
Paul Greyson2913af82013-03-27 14:53:17 -0700137@app.route("/proxy/gui/controller/<cmd>/<controller_name>")
138def proxy_controller_status_change(cmd, controller_name):
139 try:
140 command = "curl -s %s/gui/controller/%s/%s" % (ONOS_GUI3_CONTROL_HOST, cmd, controller_name)
141 print command
142 result = os.popen(command).read()
143 except:
144 print "REST IF has issue"
145 exit
146
147 resp = Response(result, status=200, mimetype='application/json')
148 return resp
149
Paul Greyson472da4c2013-03-28 11:43:17 -0700150@app.route("/proxy/gui/addflow/<src_dpid>/<src_port>/<dst_dpid>/<dst_port>/<srcMAC>/<dstMAC>")
151def proxy_add_flow(src_dpid, src_port, dst_dpid, dst_port, srcMAC, dstMAC):
152 try:
153 command = "curl -s %s/gui/addflow/%s/%s/%s/%s/%s/%s" % (ONOS_GUI3_CONTROL_HOST, src_dpid, src_port, dst_dpid, dst_port, srcMAC, dstMAC)
154 print command
155 result = os.popen(command).read()
156 except:
157 print "REST IF has issue"
158 exit
159
160 resp = Response(result, status=200, mimetype='application/json')
161 return resp
162
Paul Greyson6f918402013-03-28 12:18:30 -0700163@app.route("/proxy/gui/delflow/<flow_id>")
164def proxy_del_flow(flow_id):
165 try:
166 command = "curl -s %s/gui/delflow/%s" % (ONOS_GUI3_CONTROL_HOST, flow_id)
167 print command
168 result = os.popen(command).read()
169 except:
170 print "REST IF has issue"
171 exit
172
173 resp = Response(result, status=200, mimetype='application/json')
174 return resp
Masayoshi Kobayashi2ae891a2013-04-05 02:16:19 +0000175
Paul Greyson4b4c8af2013-04-04 09:02:09 -0700176@app.route("/proxy/gui/iperf/start/<flow_id>/<duration>/<samples>")
177def proxy_iperf_start(flow_id,duration,samples):
178 try:
179 command = "curl -s %s/gui/iperf/start/%s/%s/%s" % (ONOS_GUI3_CONTROL_HOST, flow_id, duration, samples)
180 print command
181 result = os.popen(command).read()
182 except:
183 print "REST IF has issue"
184 exit
185
186 resp = Response(result, status=200, mimetype='application/json')
187 return resp
188
189@app.route("/proxy/gui/iperf/rate/<flow_id>")
190def proxy_iperf_rate(flow_id):
191 try:
192 command = "curl -s %s/gui/iperf/rate/%s" % (ONOS_GUI3_CONTROL_HOST, flow_id)
193 print command
194 result = os.popen(command).read()
195 except:
196 print "REST IF has issue"
197 exit
198
199 resp = Response(result, status=200, mimetype='application/json')
200 return resp
201
202
Masayoshi Kobayashi2ae891a2013-04-05 02:16:19 +0000203###### ONOS RESET API ##############################
204## Worker Func ###
205def get_json(url):
206 code = 200
207 try:
208 command = "curl -s %s" % (url)
209 result = os.popen(command).read()
210 parsedResult = json.loads(result)
Masayoshi Kobayashi8ac33362013-04-05 03:17:26 +0000211 if type(parsedResult) == 'dict' and parsedResult.has_key('code'):
212 print "REST %s returned code %s" % (command, parsedResult['code'])
213 code=500
Masayoshi Kobayashi2ae891a2013-04-05 02:16:19 +0000214 except:
215 print "REST IF %s has issue" % command
216 result = ""
Masayoshi Kobayashi2ae891a2013-04-05 02:16:19 +0000217 code = 500
218
219 return (code, result)
220
221def pick_host():
222 if LB == True:
223 nr_host=len(controllers)
224 r=random.randint(0, nr_host - 1)
225 host=controllers[r]
226 else:
227 host=ONOS_DEFAULT_HOST
228
229 return "http://" + host + ":8080"
230
231## Switch ##
Masayoshi Kobayashi13e2ebe2013-03-26 18:38:41 +0000232@app.route("/wm/core/topology/switches/all/json")
233def switches():
234 if request.args.get('proxy') == None:
Masayoshi Kobayashi2ae891a2013-04-05 02:16:19 +0000235 host = pick_host()
Masayoshi Kobayashi13e2ebe2013-03-26 18:38:41 +0000236 else:
237 host = ONOS_GUI3_HOST
238
Masayoshi Kobayashi2ae891a2013-04-05 02:16:19 +0000239 url ="%s/wm/core/topology/switches/all/json" % (host)
240 (code, result) = get_json(url)
Masayoshi Kobayashi13e2ebe2013-03-26 18:38:41 +0000241
Masayoshi Kobayashi2ae891a2013-04-05 02:16:19 +0000242 resp = Response(result, status=code, mimetype='application/json')
Masayoshi Kobayashi13e2ebe2013-03-26 18:38:41 +0000243 return resp
244
Masayoshi Kobayashi2ae891a2013-04-05 02:16:19 +0000245## Link ##
Masayoshi Kobayashi13e2ebe2013-03-26 18:38:41 +0000246@app.route("/wm/core/topology/links/json")
247def links():
248 if request.args.get('proxy') == None:
Masayoshi Kobayashi2ae891a2013-04-05 02:16:19 +0000249 host = pick_host()
Masayoshi Kobayashi13e2ebe2013-03-26 18:38:41 +0000250 else:
251 host = ONOS_GUI3_HOST
252
Masayoshi Kobayashi2ae891a2013-04-05 02:16:19 +0000253 url ="%s/wm/core/topology/links/json" % (host)
254 (code, result) = get_json(url)
Masayoshi Kobayashi13e2ebe2013-03-26 18:38:41 +0000255
Masayoshi Kobayashi2ae891a2013-04-05 02:16:19 +0000256 resp = Response(result, status=code, mimetype='application/json')
Masayoshi Kobayashi13e2ebe2013-03-26 18:38:41 +0000257 return resp
258
Masayoshi Kobayashi2ae891a2013-04-05 02:16:19 +0000259## FlowSummary ##
Masayoshi Kobayashicdb652f2013-04-04 18:24:29 +0000260@app.route("/wm/flow/getsummary/<start>/<range>/json")
261def flows(start, range):
Masayoshi Kobayashi13e2ebe2013-03-26 18:38:41 +0000262 if request.args.get('proxy') == None:
Masayoshi Kobayashi2ae891a2013-04-05 02:16:19 +0000263 host = pick_host()
Masayoshi Kobayashi13e2ebe2013-03-26 18:38:41 +0000264 else:
265 host = ONOS_GUI3_HOST
266
Masayoshi Kobayashi2ae891a2013-04-05 02:16:19 +0000267 url ="%s/wm/flow/getsummary/%s/%s/json" % (host, start, range)
268 (code, result) = get_json(url)
Masayoshi Kobayashi13e2ebe2013-03-26 18:38:41 +0000269
Masayoshi Kobayashi2ae891a2013-04-05 02:16:19 +0000270 resp = Response(result, status=code, mimetype='application/json')
Masayoshi Kobayashi13e2ebe2013-03-26 18:38:41 +0000271 return resp
272
273@app.route("/wm/registry/controllers/json")
274def registry_controllers():
275 if request.args.get('proxy') == None:
Masayoshi Kobayashi2ae891a2013-04-05 02:16:19 +0000276 host = pick_host()
Masayoshi Kobayashi13e2ebe2013-03-26 18:38:41 +0000277 else:
278 host = ONOS_GUI3_HOST
279
Masayoshi Kobayashi2ae891a2013-04-05 02:16:19 +0000280 url= "%s/wm/registry/controllers/json" % (host)
281 (code, result) = get_json(url)
Masayoshi Kobayashi13e2ebe2013-03-26 18:38:41 +0000282
Masayoshi Kobayashi2ae891a2013-04-05 02:16:19 +0000283 resp = Response(result, status=code, mimetype='application/json')
Masayoshi Kobayashi13e2ebe2013-03-26 18:38:41 +0000284 return resp
285
Masayoshi Kobayashi2ae891a2013-04-05 02:16:19 +0000286
Masayoshi Kobayashi13e2ebe2013-03-26 18:38:41 +0000287@app.route("/wm/registry/switches/json")
288def registry_switches():
289 if request.args.get('proxy') == None:
Masayoshi Kobayashi2ae891a2013-04-05 02:16:19 +0000290 host = pick_host()
Masayoshi Kobayashi13e2ebe2013-03-26 18:38:41 +0000291 else:
292 host = ONOS_GUI3_HOST
293
Masayoshi Kobayashi2ae891a2013-04-05 02:16:19 +0000294 url="%s/wm/registry/switches/json" % (host)
295 (code, result) = get_json(url)
Masayoshi Kobayashi13e2ebe2013-03-26 18:38:41 +0000296
Masayoshi Kobayashi2ae891a2013-04-05 02:16:19 +0000297 resp = Response(result, status=code, mimetype='application/json')
Masayoshi Kobayashi13e2ebe2013-03-26 18:38:41 +0000298 return resp
299
Ubuntu82b8a832013-02-06 22:00:11 +0000300def node_id(switch_array, dpid):
301 id = -1
302 for i, val in enumerate(switch_array):
303 if val['name'] == dpid:
304 id = i
305 break
306
307 return id
308
Masayoshi Kobayashi13e2ebe2013-03-26 18:38:41 +0000309## API for ON.Lab local GUI ##
Masayoshi Kobayashif63ef2f2013-02-20 21:47:21 +0000310@app.route('/topology', methods=['GET'])
Ubuntu82b8a832013-02-06 22:00:11 +0000311def topology_for_gui():
312 try:
313 command = "curl -s \'http://%s:%s/wm/core/topology/switches/all/json\'" % (RestIP, RestPort)
314 result = os.popen(command).read()
315 parsedResult = json.loads(result)
316 except:
317 log_error("REST IF has issue: %s" % command)
318 log_error("%s" % result)
319 sys.exit(0)
320
321 topo = {}
322 switches = []
323 links = []
Ubuntu37ebda62013-03-01 00:35:31 +0000324 devices = []
Ubuntu82b8a832013-02-06 22:00:11 +0000325
326 for v in parsedResult:
327 if v.has_key('dpid'):
328# if v.has_key('dpid') and str(v['state']) == "ACTIVE":#;if you want only ACTIVE nodes
329 dpid = str(v['dpid'])
330 state = str(v['state'])
331 sw = {}
332 sw['name']=dpid
Ubuntu5b2b24a2013-02-27 09:51:13 +0000333 sw['group']= -1
Ubuntu37ebda62013-03-01 00:35:31 +0000334
Masayoshi Kobayashi1407a502013-02-27 06:23:08 +0000335 if state == "INACTIVE":
Masayoshi Kobayashi1407a502013-02-27 06:23:08 +0000336 sw['group']=0
Ubuntu82b8a832013-02-06 22:00:11 +0000337 switches.append(sw)
Masayoshi Kobayashi1407a502013-02-27 06:23:08 +0000338
Masayoshi Kobayashi1407a502013-02-27 06:23:08 +0000339 try:
340 command = "curl -s \'http://%s:%s/wm/registry/switches/json\'" % (RestIP, RestPort)
341 result = os.popen(command).read()
342 parsedResult = json.loads(result)
343 except:
344 log_error("REST IF has issue: %s" % command)
345 log_error("%s" % result)
346
347 for key in parsedResult:
348 dpid = key
349 ctrl = parsedResult[dpid][0]['controllerId']
350 sw_id = node_id(switches, dpid)
351 if sw_id != -1:
352 if switches[sw_id]['group'] != 0:
353 switches[sw_id]['group'] = controllers.index(ctrl) + 1
354
Masayoshi Kobayashi3bc5fde2013-02-28 01:02:54 +0000355 try:
356 v1 = "00:00:00:00:00:0a:0d:00"
Ubuntu765deff2013-02-28 18:39:13 +0000357# v1 = "00:00:00:00:00:0d:00:d1"
Masayoshi Kobayashi3bc5fde2013-02-28 01:02:54 +0000358 p1=1
359 v2 = "00:00:00:00:00:0b:0d:03"
Ubuntu765deff2013-02-28 18:39:13 +0000360# v2 = "00:00:00:00:00:0d:00:d3"
361 p2=1
Masayoshi Kobayashi3bc5fde2013-02-28 01:02:54 +0000362 command = "curl -s http://%s:%s/wm/topology/route/%s/%s/%s/%s/json" % (RestIP, RestPort, v1, p1, v2, p2)
363 result = os.popen(command).read()
364 parsedResult = json.loads(result)
365 except:
366 log_error("No route")
Ubuntu765deff2013-02-28 18:39:13 +0000367 parsedResult = {}
Ubuntu5b2b24a2013-02-27 09:51:13 +0000368
Ubuntu765deff2013-02-28 18:39:13 +0000369 path = []
370 if parsedResult.has_key('flowEntries'):
371 flowEntries= parsedResult['flowEntries']
372 for i, v in enumerate(flowEntries):
373 if i < len(flowEntries) - 1:
374 sdpid= flowEntries[i]['dpid']['value']
375 ddpid = flowEntries[i+1]['dpid']['value']
Paul Greyson4e6dc3a2013-03-27 11:37:14 -0700376 path.append( (sdpid, ddpid))
Ubuntu5b2b24a2013-02-27 09:51:13 +0000377
Ubuntu82b8a832013-02-06 22:00:11 +0000378 try:
379 command = "curl -s \'http://%s:%s/wm/core/topology/links/json\'" % (RestIP, RestPort)
380 result = os.popen(command).read()
381 parsedResult = json.loads(result)
382 except:
383 log_error("REST IF has issue: %s" % command)
384 log_error("%s" % result)
385 sys.exit(0)
386
387 for v in parsedResult:
388 link = {}
389 if v.has_key('dst-switch'):
390 dst_dpid = str(v['dst-switch'])
391 dst_id = node_id(switches, dst_dpid)
392 if v.has_key('src-switch'):
393 src_dpid = str(v['src-switch'])
394 src_id = node_id(switches, src_dpid)
395 link['source'] = src_id
396 link['target'] = dst_id
Masayoshi Kobayashi3bc5fde2013-02-28 01:02:54 +0000397
398 onpath = 0
399 for (s,d) in path:
400 if s == v['src-switch'] and d == v['dst-switch']:
401 onpath = 1
402 break
403 link['type'] = onpath
404
Ubuntu82b8a832013-02-06 22:00:11 +0000405 links.append(link)
406
407 topo['nodes'] = switches
408 topo['links'] = links
409
Ubuntu82b8a832013-02-06 22:00:11 +0000410 js = json.dumps(topo)
411 resp = Response(js, status=200, mimetype='application/json')
412 return resp
413
Ubuntuaea2a682013-02-08 08:30:10 +0000414#@app.route("/wm/topology/toporoute/00:00:00:00:00:a1/2/00:00:00:00:00:c1/3/json")
415#@app.route("/wm/topology/toporoute/<srcdpid>/<srcport>/<destdpid>/<destport>/json")
416@app.route("/wm/topology/toporoute/<v1>/<p1>/<v2>/<p2>/json")
417def shortest_path(v1, p1, v2, p2):
418 try:
419 command = "curl -s \'http://%s:%s/wm/core/topology/switches/all/json\'" % (RestIP, RestPort)
420 result = os.popen(command).read()
421 parsedResult = json.loads(result)
422 except:
423 log_error("REST IF has issue: %s" % command)
424 log_error("%s" % result)
425 sys.exit(0)
426
427 topo = {}
428 switches = []
429 links = []
430
431 for v in parsedResult:
432 if v.has_key('dpid'):
433 dpid = str(v['dpid'])
434 state = str(v['state'])
435 sw = {}
436 sw['name']=dpid
437 if str(v['state']) == "ACTIVE":
438 if dpid[-2:-1] == "a":
439 sw['group']=1
440 if dpid[-2:-1] == "b":
441 sw['group']=2
442 if dpid[-2:-1] == "c":
443 sw['group']=3
444 if str(v['state']) == "INACTIVE":
445 sw['group']=0
446
447 switches.append(sw)
448
449 try:
450 command = "curl -s http://%s:%s/wm/topology/route/%s/%s/%s/%s/json" % (RestIP, RestPort, v1, p1, v2, p2)
451 result = os.popen(command).read()
452 parsedResult = json.loads(result)
453 except:
454 log_error("No route")
455 parsedResult = []
456# exit(1)
457
Paul Greyson4e6dc3a2013-03-27 11:37:14 -0700458 path = [];
Ubuntuaea2a682013-02-08 08:30:10 +0000459 for i, v in enumerate(parsedResult):
460 if i < len(parsedResult) - 1:
461 sdpid= parsedResult[i]['switch']
462 ddpid = parsedResult[i+1]['switch']
Paul Greyson4e6dc3a2013-03-27 11:37:14 -0700463 path.append( (sdpid, ddpid))
Ubuntuaea2a682013-02-08 08:30:10 +0000464
465 try:
466 command = "curl -s \'http://%s:%s/wm/core/topology/links/json\'" % (RestIP, RestPort)
467 result = os.popen(command).read()
468 parsedResult = json.loads(result)
469 except:
470 log_error("REST IF has issue: %s" % command)
471 log_error("%s" % result)
472 sys.exit(0)
473
474 for v in parsedResult:
475 link = {}
476 if v.has_key('dst-switch'):
477 dst_dpid = str(v['dst-switch'])
478 dst_id = node_id(switches, dst_dpid)
479 if v.has_key('src-switch'):
480 src_dpid = str(v['src-switch'])
481 src_id = node_id(switches, src_dpid)
482 link['source'] = src_id
483 link['target'] = dst_id
484 onpath = 0
485 for (s,d) in path:
486 if s == v['src-switch'] and d == v['dst-switch']:
487 onpath = 1
488 break
489
490 link['type'] = onpath
491 links.append(link)
492
493 topo['nodes'] = switches
494 topo['links'] = links
495
Ubuntuaea2a682013-02-08 08:30:10 +0000496 js = json.dumps(topo)
497 resp = Response(js, status=200, mimetype='application/json')
498 return resp
499
Ubuntu82b8a832013-02-06 22:00:11 +0000500@app.route("/wm/core/controller/switches/json")
501def query_switch():
502 try:
503 command = "curl -s \'http://%s:%s/wm/core/topology/switches/all/json\'" % (RestIP, RestPort)
504# http://localhost:8080/wm/core/topology/switches/active/json
Masayoshi Kobayashif63ef2f2013-02-20 21:47:21 +0000505 print command
Ubuntu82b8a832013-02-06 22:00:11 +0000506 result = os.popen(command).read()
507 parsedResult = json.loads(result)
508 except:
509 log_error("REST IF has issue: %s" % command)
510 log_error("%s" % result)
511 sys.exit(0)
512
513# print command
514# print result
515 switches_ = []
516 for v in parsedResult:
517 if v.has_key('dpid'):
518 if v.has_key('dpid') and str(v['state']) == "ACTIVE":#;if you want only ACTIVE nodes
519 dpid = str(v['dpid'])
520 state = str(v['state'])
521 sw = {}
522 sw['dpid']=dpid
523 sw['active']=state
524 switches_.append(sw)
525
Masayoshi Kobayashi1407a502013-02-27 06:23:08 +0000526# pp.pprint(switches_)
Ubuntu82b8a832013-02-06 22:00:11 +0000527 js = json.dumps(switches_)
528 resp = Response(js, status=200, mimetype='application/json')
529 return resp
530
531@app.route("/wm/device/")
532def devices():
533 try:
534 command = "curl -s http://%s:%s/graphs/%s/vertices\?key=type\&value=device" % (RestIP, RestPort, DBName)
535 result = os.popen(command).read()
536 parsedResult = json.loads(result)['results']
537 except:
538 log_error("REST IF has issue: %s" % command)
539 log_error("%s" % result)
540 sys.exit(0)
541
542 devices = []
543 for v in parsedResult:
544 dl_addr = v['dl_addr']
545 nw_addr = v['nw_addr']
546 vertex = v['_id']
547 mac = []
548 mac.append(dl_addr)
549 ip = []
550 ip.append(nw_addr)
551 device = {}
552 device['entryClass']="DefaultEntryClass"
553 device['mac']=mac
554 device['ipv4']=ip
555 device['vlan']=[]
556 device['lastSeen']=0
557 attachpoints =[]
558
559 port, dpid = deviceV_to_attachpoint(vertex)
560 attachpoint = {}
561 attachpoint['port']=port
562 attachpoint['switchDPID']=dpid
563 attachpoints.append(attachpoint)
564 device['attachmentPoint']=attachpoints
565 devices.append(device)
566
Ubuntu82b8a832013-02-06 22:00:11 +0000567 js = json.dumps(devices)
568 resp = Response(js, status=200, mimetype='application/json')
569 return resp
570
571#{"entityClass":"DefaultEntityClass","mac":["7c:d1:c3:e0:8c:a3"],"ipv4":["192.168.2.102","10.1.10.35"],"vlan":[],"attachmentPoint":[{"port":13,"switchDPID":"00:01:00:12:e2:78:32:44","errorStatus":null}],"lastSeen":1357333593496}
572
Ubuntu82b8a832013-02-06 22:00:11 +0000573## return fake stat for now
574@app.route("/wm/core/switch/<switchId>/<statType>/json")
575def switch_stat(switchId, statType):
576 if statType == "desc":
577 desc=[{"length":1056,"serialNumber":"None","manufacturerDescription":"Nicira Networks, Inc.","hardwareDescription":"Open vSwitch","softwareDescription":"1.4.0+build0","datapathDescription":"None"}]
578 ret = {}
579 ret[switchId]=desc
580 elif statType == "aggregate":
581 aggr = {"packetCount":0,"byteCount":0,"flowCount":0}
582 ret = {}
583 ret[switchId]=aggr
584 else:
Paul Greyson4e6dc3a2013-03-27 11:37:14 -0700585 ret = {}
Ubuntu82b8a832013-02-06 22:00:11 +0000586
587 js = json.dumps(ret)
588 resp = Response(js, status=200, mimetype='application/json')
589 return resp
590
591
592@app.route("/wm/topology/links/json")
593def query_links():
594 try:
595 command = 'curl -s http://%s:%s/graphs/%s/vertices?key=type\&value=port' % (RestIP, RestPort, DBName)
Masayoshi Kobayashif63ef2f2013-02-20 21:47:21 +0000596 print command
Ubuntu82b8a832013-02-06 22:00:11 +0000597 result = os.popen(command).read()
598 parsedResult = json.loads(result)['results']
599 except:
600 log_error("REST IF has issue: %s" % command)
601 log_error("%s" % result)
602 sys.exit(0)
603
604 debug("query_links %s" % command)
Masayoshi Kobayashi1407a502013-02-27 06:23:08 +0000605# pp.pprint(parsedResult)
Ubuntu82b8a832013-02-06 22:00:11 +0000606 sport = []
607 links = []
608 for v in parsedResult:
609 srcport = v['_id']
610 try:
611 command = "curl -s http://%s:%s/graphs/%s/vertices/%d/out?_label=link" % (RestIP, RestPort, DBName, srcport)
612 print command
613 result = os.popen(command).read()
614 linkResults = json.loads(result)['results']
615 except:
616 log_error("REST IF has issue: %s" % command)
617 log_error("%s" % result)
618 sys.exit(0)
619
620 for p in linkResults:
621 if p.has_key('type') and p['type'] == "port":
622 dstport = p['_id']
623 (sport, sdpid) = portV_to_port_dpid(srcport)
624 (dport, ddpid) = portV_to_port_dpid(dstport)
625 link = {}
626 link["src-switch"]=sdpid
627 link["src-port"]=sport
628 link["src-port-state"]=0
629 link["dst-switch"]=ddpid
630 link["dst-port"]=dport
631 link["dst-port-state"]=0
632 link["type"]="internal"
633 links.append(link)
634
Masayoshi Kobayashi1407a502013-02-27 06:23:08 +0000635# pp.pprint(links)
Ubuntu82b8a832013-02-06 22:00:11 +0000636 js = json.dumps(links)
637 resp = Response(js, status=200, mimetype='application/json')
638 return resp
639
Ubuntuc016ba12013-02-27 21:53:41 +0000640@app.route("/controller_status")
641def controller_status():
642 onos_check="ssh -i ~/.ssh/onlabkey.pem %s ONOS/start-onos.sh status | awk '{print $1}'"
643 #cassandra_check="ssh -i ~/.ssh/onlabkey.pem %s ONOS/start-cassandra.sh status"
644
645 cont_status=[]
646 for i in controllers:
647 status={}
648 onos=os.popen(onos_check % i).read()[:-1]
649 status["name"]=i
650 status["onos"]=onos
Masayoshi Kobayashi5e91bdf2013-03-15 01:22:51 +0000651 status["cassandra"]=0
Ubuntuc016ba12013-02-27 21:53:41 +0000652 cont_status.append(status)
653
654 js = json.dumps(cont_status)
655 resp = Response(js, status=200, mimetype='application/json')
Ubuntuc016ba12013-02-27 21:53:41 +0000656 return resp
657
Masayoshi Kobayashi2ae891a2013-04-05 02:16:19 +0000658### Command ###
Masayoshi Kobayashi51011522013-03-27 00:18:12 +0000659@app.route("/gui/controller/<cmd>/<controller_name>")
660def controller_status_change(cmd, controller_name):
661 start_onos="ssh -i ~/.ssh/onlabkey.pem %s ONOS/start-onos.sh start" % (controller_name)
662 stop_onos="ssh -i ~/.ssh/onlabkey.pem %s ONOS/start-onos.sh stop" % (controller_name)
663
664 if cmd == "up":
Masayoshi Kobayashi1e072382013-03-27 05:17:09 +0000665 result=os.popen(start_onos).read()
Masayoshi Kobayashi51011522013-03-27 00:18:12 +0000666 ret = "controller %s is up" % (controller_name)
667 elif cmd == "down":
Masayoshi Kobayashi1e072382013-03-27 05:17:09 +0000668 result=os.popen(stop_onos).read()
Masayoshi Kobayashi51011522013-03-27 00:18:12 +0000669 ret = "controller %s is down" % (controller_name)
670
671 return ret
672
Masayoshi Kobayashi03e64b42013-04-05 05:56:27 +0000673@app.route("/gui/switchctrl/<cmd>")
674def switch_controller_setting(cmd):
675 if cmd =="local":
676 print "All aggr switches connects to local controller only"
677 result=""
678 for i in range(0, len(controllers)):
679 cmd_string="ssh -i ~/.ssh/onlabkey.pem %s 'cd ONOS/scripts; ./ctrl-local.sh'" % (controllers[i])
680 result += os.popen(cmd_string).read()
681 elif cmd =="all":
682 print "All aggr switches connects to all controllers except for core controller"
683 result=""
684 for i in range(0, len(controllers)):
685 cmd_string="ssh -i ~/.ssh/onlabkey.pem %s 'cd ONOS/scripts; ./ctrl-add-ext.sh'" % (controllers[i])
686 result += os.popen(cmd_string).read()
687
688 return result
689
690
691
Masayoshi Kobayashi51011522013-03-27 00:18:12 +0000692@app.route("/gui/switch/<cmd>/<dpid>")
693def switch_status_change(cmd, dpid):
694 r = re.compile(':')
695 dpid = re.sub(r, '', dpid)
Masayoshi Kobayashic0bc3192013-03-27 23:12:03 +0000696 host=controllers[0]
697 cmd_string="ssh -i ~/.ssh/onlabkey.pem %s 'cd ONOS/scripts; ./switch.sh %s %s'" % (host, dpid, cmd)
698 get_status="ssh -i ~/.ssh/onlabkey.pem %s 'cd ONOS/scripts; ./switch.sh %s'" % (host, dpid)
Masayoshi Kobayashi51011522013-03-27 00:18:12 +0000699 print "cmd_string"
700
701 if cmd =="up" or cmd=="down":
702 print "make dpid %s %s" % (dpid, cmd)
Masayoshi Kobayashi1e072382013-03-27 05:17:09 +0000703 os.popen(cmd_string)
704 result=os.popen(get_status).read()
Masayoshi Kobayashi51011522013-03-27 00:18:12 +0000705
Masayoshi Kobayashi1e072382013-03-27 05:17:09 +0000706 return result
Masayoshi Kobayashi51011522013-03-27 00:18:12 +0000707
Masayoshi Kobayashidecab442013-03-28 11:19:13 +0000708#* Link Up
Masayoshi Kobayashi51011522013-03-27 00:18:12 +0000709#http://localhost:9000/gui/link/up/<src_dpid>/<src_port>/<dst_dpid>/<dst_port>
Masayoshi Kobayashidecab442013-03-28 11:19:13 +0000710@app.route("/gui/link/up/<src_dpid>/<src_port>/<dst_dpid>/<dst_port>")
711def link_up(src_dpid, src_port, dst_dpid, dst_port):
Masayoshi Kobayashi1e072382013-03-27 05:17:09 +0000712
Masayoshi Kobayashidecab442013-03-28 11:19:13 +0000713 cmd = 'up'
714 result=""
715
Paul Greyson472da4c2013-03-28 11:43:17 -0700716 for dpid in (src_dpid, dst_dpid):
Masayoshi Kobayashidecab442013-03-28 11:19:13 +0000717 if dpid in core_switches:
718 host = controllers[0]
719 src_ports = [1, 2, 3, 4, 5]
720 else:
Masayoshi Kobayashi05f12b32013-04-01 09:08:09 +0000721 hostid=int(dpid.split(':')[-2])
Masayoshi Kobayashidecab442013-03-28 11:19:13 +0000722 host = controllers[hostid-1]
723 if hostid == 2 :
724 src_ports = [51]
725 else :
726 src_ports = [26]
727
728 for port in src_ports :
729 cmd_string="ssh -i ~/.ssh/onlabkey.pem %s 'cd ONOS/scripts; ./link.sh %s %s %s'" % (host, dpid, port, cmd)
730 print cmd_string
731 res=os.popen(cmd_string).read()
732 result = result + ' ' + res
733
734 return result
735
736
737#* Link Down
738#http://localhost:9000/gui/link/down/<src_dpid>/<src_port>/<dst_dpid>/<dst_port>
Masayoshi Kobayashi1e072382013-03-27 05:17:09 +0000739@app.route("/gui/link/<cmd>/<src_dpid>/<src_port>/<dst_dpid>/<dst_port>")
Masayoshi Kobayashidecab442013-03-28 11:19:13 +0000740def link_down(cmd, src_dpid, src_port, dst_dpid, dst_port):
741
Masayoshi Kobayashi1e072382013-03-27 05:17:09 +0000742 if src_dpid in core_switches:
743 host = controllers[0]
744 else:
745 hostid=int(src_dpid.split(':')[-2])
746 host = controllers[hostid-1]
747
748 cmd_string="ssh -i ~/.ssh/onlabkey.pem %s 'cd ONOS/scripts; ./link.sh %s %s %s'" % (host, src_dpid, src_port, cmd)
749 print cmd_string
750
Masayoshi Kobayashidecab442013-03-28 11:19:13 +0000751 result=os.popen(cmd_string).read()
Masayoshi Kobayashi1e072382013-03-27 05:17:09 +0000752
753 return result
754
Masayoshi Kobayashi51011522013-03-27 00:18:12 +0000755#* Create Flow
756#http://localhost:9000/gui/addflow/<src_dpid>/<src_port>/<dst_dpid>/<dst_port>/<srcMAC>/<dstMAC>
Masayoshi Kobayashi1e072382013-03-27 05:17:09 +0000757#1 FOOBAR 00:00:00:00:00:00:01:01 1 00:00:00:00:00:00:01:0b 1 matchSrcMac 00:00:00:00:00:00 matchDstMac 00:01:00:00:00:00
Masayoshi Kobayashi81f65652013-03-28 21:06:39 +0000758@app.route("/gui/addflow/<src_dpid>/<src_port>/<dst_dpid>/<dst_port>/<srcMAC>/<dstMAC>")
Masayoshi Kobayashi1e072382013-03-27 05:17:09 +0000759def add_flow(src_dpid, src_port, dst_dpid, dst_port, srcMAC, dstMAC):
760 command = "/home/ubuntu/ONOS/web/get_flow.py all |grep FlowPath |gawk '{print strtonum($4)}'| sort -n | tail -n 1"
761 print command
762 ret = os.popen(command).read()
763 if ret == "":
764 flow_nr=0
765 else:
766 flow_nr=int(ret)
767
768 flow_nr += 1
Umesh Krishnaswamyf22d3ed2013-04-03 11:57:54 -0700769 command = "/home/ubuntu/ONOS/web/add_flow.py -m onos %d %s %s %s %s %s matchSrcMac %s matchDstMac %s" % (flow_nr, "dummy", src_dpid, src_port, dst_dpid, dst_port, srcMAC, dstMAC)
Masayoshi Kobayashicdb652f2013-04-04 18:24:29 +0000770 command1 = "/home/ubuntu/ONOS/web/add_flow.py -m onos %d %s %s %s %s %s matchSrcMac %s matchDstMac %s" % (flow_nr, "dummy", dst_dpid, dst_port, src_dpid, src_port, dstMAC, srcMAC)
Masayoshi Kobayashi1e072382013-03-27 05:17:09 +0000771 print command
772 errcode = os.popen(command).read()
Masayoshi Kobayashicdb652f2013-04-04 18:24:29 +0000773 errcode1 = os.popen(command1).read()
774 return errcode+" "+errcode1
Masayoshi Kobayashi1e072382013-03-27 05:17:09 +0000775
Masayoshi Kobayashi51011522013-03-27 00:18:12 +0000776#* Delete Flow
777#http://localhost:9000/gui/delflow/<flow_id>
Masayoshi Kobayashi1e072382013-03-27 05:17:09 +0000778@app.route("/gui/delflow/<flow_id>")
779def del_flow(flow_id):
780 command = "/home/ubuntu/ONOS/web/delete_flow.py %s" % (flow_id)
781 print command
782 errcode = os.popen(command).read()
783 return errcode
784
Masayoshi Kobayashi51011522013-03-27 00:18:12 +0000785#* Start Iperf Througput
Umesh Krishnaswamy6689be32013-03-27 18:12:26 -0700786#http://localhost:9000/gui/iperf/start/<flow_id>/<duration>
Masayoshi Kobayashi3d049312013-04-02 22:15:16 +0000787@app.route("/gui/iperf/start/<flow_id>/<duration>/<samples>")
788def iperf_start(flow_id,duration,samples):
Masayoshi Kobayashifd566312013-04-01 10:34:01 +0000789 try:
Masayoshi Kobayashi3d049312013-04-02 22:15:16 +0000790 command = "curl -s \'http://%s:%s/wm/flow/get/%s/json\'" % (RestIP, RestPort, flow_id)
Masayoshi Kobayashifd566312013-04-01 10:34:01 +0000791 print command
792 result = os.popen(command).read()
793 if len(result) == 0:
794 print "No Flow found"
795 return;
Masayoshi Kobayashifd566312013-04-01 10:34:01 +0000796 except:
797 print "REST IF has issue"
798 exit
799
Masayoshi Kobayashi3d049312013-04-02 22:15:16 +0000800 parsedResult = json.loads(result)
801
Masayoshi Kobayashi03e64b42013-04-05 05:56:27 +0000802# flowId = int(parsedResult['flowId']['value'], 16)
Masayoshi Kobayashi3d049312013-04-02 22:15:16 +0000803 flowId = int(parsedResult['flowId']['value'], 16)
Masayoshi Kobayashifd566312013-04-01 10:34:01 +0000804 src_dpid = parsedResult['dataPath']['srcPort']['dpid']['value']
805 src_port = parsedResult['dataPath']['srcPort']['port']['value']
806 dst_dpid = parsedResult['dataPath']['dstPort']['dpid']['value']
807 dst_port = parsedResult['dataPath']['dstPort']['port']['value']
Masayoshi Kobayashi3d049312013-04-02 22:15:16 +0000808# print "FlowPath: (flowId = %s src = %s/%s dst = %s/%s" % (flowId, src_dpid, src_port, dst_dpid, dst_port)
Masayoshi Kobayashifd566312013-04-01 10:34:01 +0000809
810 if src_dpid in core_switches:
811 host = controllers[0]
812 else:
813 hostid=int(src_dpid.split(':')[-2])
814 host = controllers[hostid-1]
815
Masayoshi Kobayashi3d049312013-04-02 22:15:16 +0000816# ./runiperf.sh 2 00:00:00:00:00:00:02:02 1 00:00:00:00:00:00:03:02 1 100 15
817 cmd_string="ssh -i ~/.ssh/onlabkey.pem %s 'cd ONOS/scripts; ./runiperf.sh %d %s %s %s %s %s %s'" % (host, flowId, src_dpid, src_port, dst_dpid, dst_port, duration, samples)
Masayoshi Kobayashifd566312013-04-01 10:34:01 +0000818 print cmd_string
Masayoshi Kobayashi3d049312013-04-02 22:15:16 +0000819 os.popen(cmd_string)
Masayoshi Kobayashifd566312013-04-01 10:34:01 +0000820
Masayoshi Kobayashicdb652f2013-04-04 18:24:29 +0000821 return cmd_string
Masayoshi Kobayashi1e072382013-03-27 05:17:09 +0000822
Masayoshi Kobayashi51011522013-03-27 00:18:12 +0000823#* Get Iperf Throughput
824#http://localhost:9000/gui/iperf/rate/<flow_id>
Masayoshi Kobayashi1e072382013-03-27 05:17:09 +0000825@app.route("/gui/iperf/rate/<flow_id>")
826def iperf_rate(flow_id):
827 try:
Masayoshi Kobayashi3d049312013-04-02 22:15:16 +0000828 command = "curl -s \'http://%s:%s/wm/flow/get/%s/json\'" % (RestIP, RestPort, flow_id)
829 print command
830 result = os.popen(command).read()
831 if len(result) == 0:
Masayoshi Kobayashi2ae891a2013-04-05 02:16:19 +0000832 resp = Response(result, status=400, mimetype='text/html')
833 return "no such iperf flow (flowid %s)" % flow_id;
Masayoshi Kobayashi3d049312013-04-02 22:15:16 +0000834 except:
835 print "REST IF has issue"
836 exit
837
838 parsedResult = json.loads(result)
839
840 flowId = int(parsedResult['flowId']['value'], 16)
841 src_dpid = parsedResult['dataPath']['srcPort']['dpid']['value']
842 src_port = parsedResult['dataPath']['srcPort']['port']['value']
843 dst_dpid = parsedResult['dataPath']['dstPort']['dpid']['value']
844 dst_port = parsedResult['dataPath']['dstPort']['port']['value']
845
846 if src_dpid in core_switches:
847 host = controllers[0]
848 else:
849 hostid=int(src_dpid.split(':')[-2])
850 host = controllers[hostid-1]
851
852 try:
853 command = "curl -s http://%s:%s/log/iperf_%s.out" % (host, 9000, flow_id)
Masayoshi Kobayashi1e072382013-03-27 05:17:09 +0000854 print command
855 result = os.popen(command).read()
856 except:
Masayoshi Kobayashi1e072382013-03-27 05:17:09 +0000857 exit
Masayoshi Kobayashi51011522013-03-27 00:18:12 +0000858
Masayoshi Kobayashib56f2972013-04-05 02:57:29 +0000859 if len(result) == 0:
860 resp = Response(result, status=400, mimetype='text/html')
861 return "no iperf file found (flowid %s)" % flow_id;
862 else:
863 resp = Response(result, status=200, mimetype='application/json')
864 return resp
Masayoshi Kobayashi51011522013-03-27 00:18:12 +0000865
866
Ubuntu82b8a832013-02-06 22:00:11 +0000867if __name__ == "__main__":
Masayoshi Kobayashi2ae891a2013-04-05 02:16:19 +0000868 random.seed()
Ubuntu82b8a832013-02-06 22:00:11 +0000869 if len(sys.argv) > 1 and sys.argv[1] == "-d":
Masayoshi Kobayashi1e072382013-03-27 05:17:09 +0000870# add_flow("00:00:00:00:00:00:02:02", 1, "00:00:00:00:00:00:03:02", 1, "00:00:00:00:02:02", "00:00:00:00:03:0c")
871# link_change("up", "00:00:00:00:ba:5e:ba:11", 1, "00:00:00:00:00:00:00:00", 1)
872# link_change("down", "00:00:20:4e:7f:51:8a:35", 1, "00:00:00:00:00:00:00:00", 1)
873# link_change("up", "00:00:00:00:00:00:02:03", 1, "00:00:00:00:00:00:00:00", 1)
874# link_change("down", "00:00:00:00:00:00:07:12", 1, "00:00:00:00:00:00:00:00", 1)
Masayoshi Kobayashi3d049312013-04-02 22:15:16 +0000875# print "-- query all switches --"
876# query_switch()
877# print "-- query topo --"
878# topology_for_gui()
Masayoshi Kobayashi1e072382013-03-27 05:17:09 +0000879# link_change(1,2,3,4)
880 print "-- query all links --"
Masayoshi Kobayashi3d049312013-04-02 22:15:16 +0000881# query_links()
Ubuntu82b8a832013-02-06 22:00:11 +0000882# print "-- query all devices --"
883# devices()
Masayoshi Kobayashi2ae891a2013-04-05 02:16:19 +0000884# iperf_start(1,10,15)
885# iperf_rate(1)
886 switches()
Ubuntu82b8a832013-02-06 22:00:11 +0000887 else:
888 app.debug = True
Masayoshi Kobayashif63ef2f2013-02-20 21:47:21 +0000889 app.run(threaded=True, host="0.0.0.0", port=9000)