Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 1 | #! /usr/bin/env python |
| 2 | import pprint |
| 3 | import os |
| 4 | import sys |
| 5 | import subprocess |
| 6 | import json |
| 7 | import argparse |
| 8 | import io |
| 9 | import time |
Masayoshi Kobayashi | 2ae891a | 2013-04-05 02:16:19 +0000 | [diff] [blame] | 10 | import random |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 11 | |
Masayoshi Kobayashi | 5101152 | 2013-03-27 00:18:12 +0000 | [diff] [blame] | 12 | import re |
| 13 | |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 14 | from flask import Flask, json, Response, render_template, make_response, request |
| 15 | |
Masayoshi Kobayashi | 2ae891a | 2013-04-05 02:16:19 +0000 | [diff] [blame] | 16 | ## Global Var for ON.Lab local REST ## |
Ubuntu | f6ce96c | 2013-02-07 01:45:07 +0000 | [diff] [blame] | 17 | RestIP="localhost" |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 18 | RestPort=8080 |
Masayoshi Kobayashi | a9ed33a | 2013-03-27 23:14:18 +0000 | [diff] [blame] | 19 | |
Tim Lindberg | a6c0417 | 2013-04-05 17:34:05 -0700 | [diff] [blame] | 20 | LB=False #; True or False |
Masayoshi Kobayashi | 2ae891a | 2013-04-05 02:16:19 +0000 | [diff] [blame] | 21 | ONOS_DEFAULT_HOST="localhost" ;# Has to set if LB=False |
Tim Lindberg | a6c0417 | 2013-04-05 17:34:05 -0700 | [diff] [blame] | 22 | TESTBED="hw" |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 23 | DEBUG=1 |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 24 | |
Tim Lindberg | 201ade2 | 2013-04-05 11:52:08 -0700 | [diff] [blame] | 25 | if (TESTBED == "hw"): |
| 26 | # Settings for running on hardware testbed |
| 27 | controllers=["ONOS1", "ONOS2", "ONOS3", "ONOS4", "ONOS5", "ONOS6", "ONOS7", "ONOS8"] |
| 28 | 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:01:00:16:97:08:9a:46"] |
| 29 | ONOS_GUI3_HOST="http://10.128.4.11:9000" |
| 30 | ONOS_GUI3_CONTROL_HOST="http://10.128.4.11:9000" |
| 31 | else: |
| 32 | # Settings for running on software testbed |
| 33 | controllers=["onosdevt1", "onosdevt2", "onosdevt3", "onosdevt4", "onosdevt5", "onosdevt6", "onosdevt7", "onosdevt8"] |
| 34 | # 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"] |
| 35 | core_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"] |
| 36 | ONOS_GUI3_HOST="http://devt-gui.onlab.us:8080" |
| 37 | ONOS_GUI3_CONTROL_HOST="http://devt-gui.onlab.us:8080" |
| 38 | |
Masayoshi Kobayashi | 2ae891a | 2013-04-05 02:16:19 +0000 | [diff] [blame] | 39 | pp = pprint.PrettyPrinter(indent=4) |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 40 | app = Flask(__name__) |
| 41 | |
| 42 | ## Worker Functions ## |
| 43 | def log_error(txt): |
| 44 | print '%s' % (txt) |
| 45 | |
| 46 | def debug(txt): |
| 47 | if DEBUG: |
| 48 | print '%s' % (txt) |
| 49 | |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 50 | ### File Fetch ### |
| 51 | @app.route('/ui/img/<filename>', methods=['GET']) |
| 52 | @app.route('/img/<filename>', methods=['GET']) |
| 53 | @app.route('/css/<filename>', methods=['GET']) |
| 54 | @app.route('/js/models/<filename>', methods=['GET']) |
| 55 | @app.route('/js/views/<filename>', methods=['GET']) |
| 56 | @app.route('/js/<filename>', methods=['GET']) |
| 57 | @app.route('/lib/<filename>', methods=['GET']) |
Masayoshi Kobayashi | 3d04931 | 2013-04-02 22:15:16 +0000 | [diff] [blame] | 58 | @app.route('/log/<filename>', methods=['GET']) |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 59 | @app.route('/', methods=['GET']) |
| 60 | @app.route('/<filename>', methods=['GET']) |
| 61 | @app.route('/tpl/<filename>', methods=['GET']) |
Masayoshi Kobayashi | 13e2ebe | 2013-03-26 18:38:41 +0000 | [diff] [blame] | 62 | @app.route('/ons-demo/<filename>', methods=['GET']) |
| 63 | @app.route('/ons-demo/js/<filename>', methods=['GET']) |
| 64 | @app.route('/ons-demo/css/<filename>', methods=['GET']) |
| 65 | @app.route('/ons-demo/assets/<filename>', methods=['GET']) |
| 66 | @app.route('/ons-demo/data/<filename>', methods=['GET']) |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 67 | def return_file(filename="index.html"): |
| 68 | if request.path == "/": |
| 69 | fullpath = "./index.html" |
| 70 | else: |
| 71 | fullpath = str(request.path)[1:] |
| 72 | |
Masayoshi Kobayashi | 03e64b4 | 2013-04-05 05:56:27 +0000 | [diff] [blame] | 73 | try: |
| 74 | open(fullpath) |
| 75 | except: |
| 76 | response = make_response("Cannot find a file: %s" % (fullpath), 500) |
| 77 | response.headers["Content-type"] = "text/html" |
| 78 | return response |
| 79 | |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 80 | response = make_response(open(fullpath).read()) |
| 81 | suffix = fullpath.split(".")[-1] |
| 82 | |
| 83 | if suffix == "html" or suffix == "htm": |
| 84 | response.headers["Content-type"] = "text/html" |
| 85 | elif suffix == "js": |
| 86 | response.headers["Content-type"] = "application/javascript" |
| 87 | elif suffix == "css": |
| 88 | response.headers["Content-type"] = "text/css" |
| 89 | elif suffix == "png": |
| 90 | response.headers["Content-type"] = "image/png" |
Paul Greyson | 2913af8 | 2013-03-27 14:53:17 -0700 | [diff] [blame] | 91 | elif suffix == "svg": |
| 92 | response.headers["Content-type"] = "image/svg+xml" |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 93 | |
| 94 | return response |
| 95 | |
Masayoshi Kobayashi | 2ae891a | 2013-04-05 02:16:19 +0000 | [diff] [blame] | 96 | ## Proxy ## |
Paul Greyson | 4e6dc3a | 2013-03-27 11:37:14 -0700 | [diff] [blame] | 97 | @app.route("/proxy/gui/link/<cmd>/<src_dpid>/<src_port>/<dst_dpid>/<dst_port>") |
| 98 | def proxy_link_change(cmd, src_dpid, src_port, dst_dpid, dst_port): |
| 99 | try: |
Paul Greyson | 8d1c636 | 2013-03-27 13:05:24 -0700 | [diff] [blame] | 100 | 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 Greyson | 4e6dc3a | 2013-03-27 11:37:14 -0700 | [diff] [blame] | 101 | print command |
| 102 | result = os.popen(command).read() |
| 103 | except: |
| 104 | print "REST IF has issue" |
| 105 | exit |
| 106 | |
| 107 | resp = Response(result, status=200, mimetype='application/json') |
| 108 | return resp |
| 109 | |
Masayoshi Kobayashi | 03e64b4 | 2013-04-05 05:56:27 +0000 | [diff] [blame] | 110 | @app.route("/proxy/gui/switchctrl/<cmd>") |
| 111 | def proxy_switch_controller_setting(cmd): |
| 112 | try: |
| 113 | command = "curl -s %s/gui/switchctrl/%s" % (ONOS_GUI3_CONTROL_HOST, cmd) |
| 114 | print command |
| 115 | result = os.popen(command).read() |
| 116 | except: |
| 117 | print "REST IF has issue" |
| 118 | exit |
| 119 | |
| 120 | resp = Response(result, status=200, mimetype='application/json') |
| 121 | return resp |
| 122 | |
Paul Greyson | 8d1c636 | 2013-03-27 13:05:24 -0700 | [diff] [blame] | 123 | @app.route("/proxy/gui/switch/<cmd>/<dpid>") |
| 124 | def proxy_switch_status_change(cmd, dpid): |
| 125 | try: |
| 126 | command = "curl -s %s/gui/switch/%s/%s" % (ONOS_GUI3_CONTROL_HOST, cmd, dpid) |
| 127 | print command |
| 128 | result = os.popen(command).read() |
| 129 | except: |
| 130 | print "REST IF has issue" |
| 131 | exit |
Paul Greyson | 4e6dc3a | 2013-03-27 11:37:14 -0700 | [diff] [blame] | 132 | |
Paul Greyson | 8d1c636 | 2013-03-27 13:05:24 -0700 | [diff] [blame] | 133 | resp = Response(result, status=200, mimetype='application/json') |
| 134 | return resp |
Paul Greyson | 4e6dc3a | 2013-03-27 11:37:14 -0700 | [diff] [blame] | 135 | |
Paul Greyson | 2913af8 | 2013-03-27 14:53:17 -0700 | [diff] [blame] | 136 | @app.route("/proxy/gui/controller/<cmd>/<controller_name>") |
| 137 | def proxy_controller_status_change(cmd, controller_name): |
| 138 | try: |
| 139 | command = "curl -s %s/gui/controller/%s/%s" % (ONOS_GUI3_CONTROL_HOST, cmd, controller_name) |
| 140 | print command |
| 141 | result = os.popen(command).read() |
| 142 | except: |
| 143 | print "REST IF has issue" |
| 144 | exit |
| 145 | |
| 146 | resp = Response(result, status=200, mimetype='application/json') |
| 147 | return resp |
| 148 | |
Paul Greyson | 472da4c | 2013-03-28 11:43:17 -0700 | [diff] [blame] | 149 | @app.route("/proxy/gui/addflow/<src_dpid>/<src_port>/<dst_dpid>/<dst_port>/<srcMAC>/<dstMAC>") |
| 150 | def proxy_add_flow(src_dpid, src_port, dst_dpid, dst_port, srcMAC, dstMAC): |
| 151 | try: |
| 152 | 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) |
| 153 | print command |
| 154 | result = os.popen(command).read() |
| 155 | except: |
| 156 | print "REST IF has issue" |
| 157 | exit |
| 158 | |
| 159 | resp = Response(result, status=200, mimetype='application/json') |
| 160 | return resp |
| 161 | |
Paul Greyson | 6f91840 | 2013-03-28 12:18:30 -0700 | [diff] [blame] | 162 | @app.route("/proxy/gui/delflow/<flow_id>") |
| 163 | def proxy_del_flow(flow_id): |
| 164 | try: |
| 165 | command = "curl -s %s/gui/delflow/%s" % (ONOS_GUI3_CONTROL_HOST, flow_id) |
| 166 | print command |
| 167 | result = os.popen(command).read() |
| 168 | except: |
| 169 | print "REST IF has issue" |
| 170 | exit |
| 171 | |
| 172 | resp = Response(result, status=200, mimetype='application/json') |
| 173 | return resp |
Masayoshi Kobayashi | 2ae891a | 2013-04-05 02:16:19 +0000 | [diff] [blame] | 174 | |
Paul Greyson | 4b4c8af | 2013-04-04 09:02:09 -0700 | [diff] [blame] | 175 | @app.route("/proxy/gui/iperf/start/<flow_id>/<duration>/<samples>") |
| 176 | def proxy_iperf_start(flow_id,duration,samples): |
| 177 | try: |
| 178 | command = "curl -s %s/gui/iperf/start/%s/%s/%s" % (ONOS_GUI3_CONTROL_HOST, flow_id, duration, samples) |
| 179 | print command |
| 180 | result = os.popen(command).read() |
| 181 | except: |
| 182 | print "REST IF has issue" |
| 183 | exit |
| 184 | |
| 185 | resp = Response(result, status=200, mimetype='application/json') |
| 186 | return resp |
| 187 | |
| 188 | @app.route("/proxy/gui/iperf/rate/<flow_id>") |
| 189 | def proxy_iperf_rate(flow_id): |
| 190 | try: |
| 191 | command = "curl -s %s/gui/iperf/rate/%s" % (ONOS_GUI3_CONTROL_HOST, flow_id) |
| 192 | print command |
| 193 | result = os.popen(command).read() |
| 194 | except: |
| 195 | print "REST IF has issue" |
| 196 | exit |
| 197 | |
| 198 | resp = Response(result, status=200, mimetype='application/json') |
| 199 | return resp |
| 200 | |
| 201 | |
Masayoshi Kobayashi | 2ae891a | 2013-04-05 02:16:19 +0000 | [diff] [blame] | 202 | ###### ONOS RESET API ############################## |
| 203 | ## Worker Func ### |
| 204 | def get_json(url): |
| 205 | code = 200 |
| 206 | try: |
| 207 | command = "curl -s %s" % (url) |
| 208 | result = os.popen(command).read() |
| 209 | parsedResult = json.loads(result) |
Masayoshi Kobayashi | 8ac3336 | 2013-04-05 03:17:26 +0000 | [diff] [blame] | 210 | if type(parsedResult) == 'dict' and parsedResult.has_key('code'): |
| 211 | print "REST %s returned code %s" % (command, parsedResult['code']) |
| 212 | code=500 |
Masayoshi Kobayashi | 2ae891a | 2013-04-05 02:16:19 +0000 | [diff] [blame] | 213 | except: |
| 214 | print "REST IF %s has issue" % command |
| 215 | result = "" |
Masayoshi Kobayashi | 2ae891a | 2013-04-05 02:16:19 +0000 | [diff] [blame] | 216 | code = 500 |
| 217 | |
| 218 | return (code, result) |
| 219 | |
| 220 | def pick_host(): |
| 221 | if LB == True: |
| 222 | nr_host=len(controllers) |
| 223 | r=random.randint(0, nr_host - 1) |
| 224 | host=controllers[r] |
| 225 | else: |
| 226 | host=ONOS_DEFAULT_HOST |
| 227 | |
| 228 | return "http://" + host + ":8080" |
| 229 | |
| 230 | ## Switch ## |
Masayoshi Kobayashi | 13e2ebe | 2013-03-26 18:38:41 +0000 | [diff] [blame] | 231 | @app.route("/wm/core/topology/switches/all/json") |
| 232 | def switches(): |
| 233 | if request.args.get('proxy') == None: |
Masayoshi Kobayashi | 2ae891a | 2013-04-05 02:16:19 +0000 | [diff] [blame] | 234 | host = pick_host() |
Masayoshi Kobayashi | 13e2ebe | 2013-03-26 18:38:41 +0000 | [diff] [blame] | 235 | else: |
| 236 | host = ONOS_GUI3_HOST |
| 237 | |
Masayoshi Kobayashi | 2ae891a | 2013-04-05 02:16:19 +0000 | [diff] [blame] | 238 | url ="%s/wm/core/topology/switches/all/json" % (host) |
| 239 | (code, result) = get_json(url) |
Masayoshi Kobayashi | 13e2ebe | 2013-03-26 18:38:41 +0000 | [diff] [blame] | 240 | |
Masayoshi Kobayashi | 2ae891a | 2013-04-05 02:16:19 +0000 | [diff] [blame] | 241 | resp = Response(result, status=code, mimetype='application/json') |
Masayoshi Kobayashi | 13e2ebe | 2013-03-26 18:38:41 +0000 | [diff] [blame] | 242 | return resp |
| 243 | |
Masayoshi Kobayashi | 2ae891a | 2013-04-05 02:16:19 +0000 | [diff] [blame] | 244 | ## Link ## |
Masayoshi Kobayashi | 13e2ebe | 2013-03-26 18:38:41 +0000 | [diff] [blame] | 245 | @app.route("/wm/core/topology/links/json") |
| 246 | def links(): |
| 247 | if request.args.get('proxy') == None: |
Masayoshi Kobayashi | 2ae891a | 2013-04-05 02:16:19 +0000 | [diff] [blame] | 248 | host = pick_host() |
Masayoshi Kobayashi | 13e2ebe | 2013-03-26 18:38:41 +0000 | [diff] [blame] | 249 | else: |
| 250 | host = ONOS_GUI3_HOST |
| 251 | |
Masayoshi Kobayashi | 2ae891a | 2013-04-05 02:16:19 +0000 | [diff] [blame] | 252 | url ="%s/wm/core/topology/links/json" % (host) |
| 253 | (code, result) = get_json(url) |
Masayoshi Kobayashi | 13e2ebe | 2013-03-26 18:38:41 +0000 | [diff] [blame] | 254 | |
Masayoshi Kobayashi | 2ae891a | 2013-04-05 02:16:19 +0000 | [diff] [blame] | 255 | resp = Response(result, status=code, mimetype='application/json') |
Masayoshi Kobayashi | 13e2ebe | 2013-03-26 18:38:41 +0000 | [diff] [blame] | 256 | return resp |
| 257 | |
Masayoshi Kobayashi | 2ae891a | 2013-04-05 02:16:19 +0000 | [diff] [blame] | 258 | ## FlowSummary ## |
Masayoshi Kobayashi | cdb652f | 2013-04-04 18:24:29 +0000 | [diff] [blame] | 259 | @app.route("/wm/flow/getsummary/<start>/<range>/json") |
| 260 | def flows(start, range): |
Masayoshi Kobayashi | 13e2ebe | 2013-03-26 18:38:41 +0000 | [diff] [blame] | 261 | if request.args.get('proxy') == None: |
Masayoshi Kobayashi | 2ae891a | 2013-04-05 02:16:19 +0000 | [diff] [blame] | 262 | host = pick_host() |
Masayoshi Kobayashi | 13e2ebe | 2013-03-26 18:38:41 +0000 | [diff] [blame] | 263 | else: |
| 264 | host = ONOS_GUI3_HOST |
| 265 | |
Masayoshi Kobayashi | 2ae891a | 2013-04-05 02:16:19 +0000 | [diff] [blame] | 266 | url ="%s/wm/flow/getsummary/%s/%s/json" % (host, start, range) |
| 267 | (code, result) = get_json(url) |
Masayoshi Kobayashi | 13e2ebe | 2013-03-26 18:38:41 +0000 | [diff] [blame] | 268 | |
Masayoshi Kobayashi | 2ae891a | 2013-04-05 02:16:19 +0000 | [diff] [blame] | 269 | resp = Response(result, status=code, mimetype='application/json') |
Masayoshi Kobayashi | 13e2ebe | 2013-03-26 18:38:41 +0000 | [diff] [blame] | 270 | return resp |
| 271 | |
| 272 | @app.route("/wm/registry/controllers/json") |
| 273 | def registry_controllers(): |
| 274 | if request.args.get('proxy') == None: |
Masayoshi Kobayashi | 2ae891a | 2013-04-05 02:16:19 +0000 | [diff] [blame] | 275 | host = pick_host() |
Masayoshi Kobayashi | 13e2ebe | 2013-03-26 18:38:41 +0000 | [diff] [blame] | 276 | else: |
| 277 | host = ONOS_GUI3_HOST |
| 278 | |
Masayoshi Kobayashi | 2ae891a | 2013-04-05 02:16:19 +0000 | [diff] [blame] | 279 | url= "%s/wm/registry/controllers/json" % (host) |
| 280 | (code, result) = get_json(url) |
Masayoshi Kobayashi | 13e2ebe | 2013-03-26 18:38:41 +0000 | [diff] [blame] | 281 | |
Masayoshi Kobayashi | 2ae891a | 2013-04-05 02:16:19 +0000 | [diff] [blame] | 282 | resp = Response(result, status=code, mimetype='application/json') |
Masayoshi Kobayashi | 13e2ebe | 2013-03-26 18:38:41 +0000 | [diff] [blame] | 283 | return resp |
| 284 | |
Masayoshi Kobayashi | 2ae891a | 2013-04-05 02:16:19 +0000 | [diff] [blame] | 285 | |
Masayoshi Kobayashi | 13e2ebe | 2013-03-26 18:38:41 +0000 | [diff] [blame] | 286 | @app.route("/wm/registry/switches/json") |
| 287 | def registry_switches(): |
| 288 | if request.args.get('proxy') == None: |
Masayoshi Kobayashi | 2ae891a | 2013-04-05 02:16:19 +0000 | [diff] [blame] | 289 | host = pick_host() |
Masayoshi Kobayashi | 13e2ebe | 2013-03-26 18:38:41 +0000 | [diff] [blame] | 290 | else: |
| 291 | host = ONOS_GUI3_HOST |
| 292 | |
Masayoshi Kobayashi | 2ae891a | 2013-04-05 02:16:19 +0000 | [diff] [blame] | 293 | url="%s/wm/registry/switches/json" % (host) |
| 294 | (code, result) = get_json(url) |
Masayoshi Kobayashi | 13e2ebe | 2013-03-26 18:38:41 +0000 | [diff] [blame] | 295 | |
Masayoshi Kobayashi | 2ae891a | 2013-04-05 02:16:19 +0000 | [diff] [blame] | 296 | resp = Response(result, status=code, mimetype='application/json') |
Masayoshi Kobayashi | 13e2ebe | 2013-03-26 18:38:41 +0000 | [diff] [blame] | 297 | return resp |
| 298 | |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 299 | def node_id(switch_array, dpid): |
| 300 | id = -1 |
| 301 | for i, val in enumerate(switch_array): |
| 302 | if val['name'] == dpid: |
| 303 | id = i |
| 304 | break |
| 305 | |
| 306 | return id |
| 307 | |
Masayoshi Kobayashi | 13e2ebe | 2013-03-26 18:38:41 +0000 | [diff] [blame] | 308 | ## API for ON.Lab local GUI ## |
Masayoshi Kobayashi | f63ef2f | 2013-02-20 21:47:21 +0000 | [diff] [blame] | 309 | @app.route('/topology', methods=['GET']) |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 310 | def topology_for_gui(): |
| 311 | try: |
| 312 | command = "curl -s \'http://%s:%s/wm/core/topology/switches/all/json\'" % (RestIP, RestPort) |
| 313 | result = os.popen(command).read() |
| 314 | parsedResult = json.loads(result) |
| 315 | except: |
| 316 | log_error("REST IF has issue: %s" % command) |
| 317 | log_error("%s" % result) |
| 318 | sys.exit(0) |
| 319 | |
| 320 | topo = {} |
| 321 | switches = [] |
| 322 | links = [] |
Ubuntu | 37ebda6 | 2013-03-01 00:35:31 +0000 | [diff] [blame] | 323 | devices = [] |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 324 | |
| 325 | for v in parsedResult: |
| 326 | if v.has_key('dpid'): |
| 327 | # if v.has_key('dpid') and str(v['state']) == "ACTIVE":#;if you want only ACTIVE nodes |
| 328 | dpid = str(v['dpid']) |
| 329 | state = str(v['state']) |
| 330 | sw = {} |
| 331 | sw['name']=dpid |
Ubuntu | 5b2b24a | 2013-02-27 09:51:13 +0000 | [diff] [blame] | 332 | sw['group']= -1 |
Ubuntu | 37ebda6 | 2013-03-01 00:35:31 +0000 | [diff] [blame] | 333 | |
Masayoshi Kobayashi | 1407a50 | 2013-02-27 06:23:08 +0000 | [diff] [blame] | 334 | if state == "INACTIVE": |
Masayoshi Kobayashi | 1407a50 | 2013-02-27 06:23:08 +0000 | [diff] [blame] | 335 | sw['group']=0 |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 336 | switches.append(sw) |
Masayoshi Kobayashi | 1407a50 | 2013-02-27 06:23:08 +0000 | [diff] [blame] | 337 | |
Masayoshi Kobayashi | 1407a50 | 2013-02-27 06:23:08 +0000 | [diff] [blame] | 338 | try: |
| 339 | command = "curl -s \'http://%s:%s/wm/registry/switches/json\'" % (RestIP, RestPort) |
| 340 | result = os.popen(command).read() |
| 341 | parsedResult = json.loads(result) |
| 342 | except: |
| 343 | log_error("REST IF has issue: %s" % command) |
| 344 | log_error("%s" % result) |
| 345 | |
| 346 | for key in parsedResult: |
| 347 | dpid = key |
| 348 | ctrl = parsedResult[dpid][0]['controllerId'] |
| 349 | sw_id = node_id(switches, dpid) |
| 350 | if sw_id != -1: |
| 351 | if switches[sw_id]['group'] != 0: |
| 352 | switches[sw_id]['group'] = controllers.index(ctrl) + 1 |
| 353 | |
Masayoshi Kobayashi | 3bc5fde | 2013-02-28 01:02:54 +0000 | [diff] [blame] | 354 | try: |
| 355 | v1 = "00:00:00:00:00:0a:0d:00" |
Ubuntu | 765deff | 2013-02-28 18:39:13 +0000 | [diff] [blame] | 356 | # v1 = "00:00:00:00:00:0d:00:d1" |
Masayoshi Kobayashi | 3bc5fde | 2013-02-28 01:02:54 +0000 | [diff] [blame] | 357 | p1=1 |
| 358 | v2 = "00:00:00:00:00:0b:0d:03" |
Ubuntu | 765deff | 2013-02-28 18:39:13 +0000 | [diff] [blame] | 359 | # v2 = "00:00:00:00:00:0d:00:d3" |
| 360 | p2=1 |
Masayoshi Kobayashi | 3bc5fde | 2013-02-28 01:02:54 +0000 | [diff] [blame] | 361 | command = "curl -s http://%s:%s/wm/topology/route/%s/%s/%s/%s/json" % (RestIP, RestPort, v1, p1, v2, p2) |
| 362 | result = os.popen(command).read() |
| 363 | parsedResult = json.loads(result) |
| 364 | except: |
| 365 | log_error("No route") |
Ubuntu | 765deff | 2013-02-28 18:39:13 +0000 | [diff] [blame] | 366 | parsedResult = {} |
Ubuntu | 5b2b24a | 2013-02-27 09:51:13 +0000 | [diff] [blame] | 367 | |
Ubuntu | 765deff | 2013-02-28 18:39:13 +0000 | [diff] [blame] | 368 | path = [] |
| 369 | if parsedResult.has_key('flowEntries'): |
| 370 | flowEntries= parsedResult['flowEntries'] |
| 371 | for i, v in enumerate(flowEntries): |
| 372 | if i < len(flowEntries) - 1: |
| 373 | sdpid= flowEntries[i]['dpid']['value'] |
| 374 | ddpid = flowEntries[i+1]['dpid']['value'] |
Paul Greyson | 4e6dc3a | 2013-03-27 11:37:14 -0700 | [diff] [blame] | 375 | path.append( (sdpid, ddpid)) |
Ubuntu | 5b2b24a | 2013-02-27 09:51:13 +0000 | [diff] [blame] | 376 | |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 377 | try: |
| 378 | command = "curl -s \'http://%s:%s/wm/core/topology/links/json\'" % (RestIP, RestPort) |
| 379 | result = os.popen(command).read() |
| 380 | parsedResult = json.loads(result) |
| 381 | except: |
| 382 | log_error("REST IF has issue: %s" % command) |
| 383 | log_error("%s" % result) |
| 384 | sys.exit(0) |
| 385 | |
| 386 | for v in parsedResult: |
| 387 | link = {} |
| 388 | if v.has_key('dst-switch'): |
| 389 | dst_dpid = str(v['dst-switch']) |
| 390 | dst_id = node_id(switches, dst_dpid) |
| 391 | if v.has_key('src-switch'): |
| 392 | src_dpid = str(v['src-switch']) |
| 393 | src_id = node_id(switches, src_dpid) |
| 394 | link['source'] = src_id |
| 395 | link['target'] = dst_id |
Masayoshi Kobayashi | 3bc5fde | 2013-02-28 01:02:54 +0000 | [diff] [blame] | 396 | |
| 397 | onpath = 0 |
| 398 | for (s,d) in path: |
| 399 | if s == v['src-switch'] and d == v['dst-switch']: |
| 400 | onpath = 1 |
| 401 | break |
| 402 | link['type'] = onpath |
| 403 | |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 404 | links.append(link) |
| 405 | |
| 406 | topo['nodes'] = switches |
| 407 | topo['links'] = links |
| 408 | |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 409 | js = json.dumps(topo) |
| 410 | resp = Response(js, status=200, mimetype='application/json') |
| 411 | return resp |
| 412 | |
Ubuntu | aea2a68 | 2013-02-08 08:30:10 +0000 | [diff] [blame] | 413 | #@app.route("/wm/topology/toporoute/00:00:00:00:00:a1/2/00:00:00:00:00:c1/3/json") |
| 414 | #@app.route("/wm/topology/toporoute/<srcdpid>/<srcport>/<destdpid>/<destport>/json") |
| 415 | @app.route("/wm/topology/toporoute/<v1>/<p1>/<v2>/<p2>/json") |
| 416 | def shortest_path(v1, p1, v2, p2): |
| 417 | try: |
| 418 | command = "curl -s \'http://%s:%s/wm/core/topology/switches/all/json\'" % (RestIP, RestPort) |
| 419 | result = os.popen(command).read() |
| 420 | parsedResult = json.loads(result) |
| 421 | except: |
| 422 | log_error("REST IF has issue: %s" % command) |
| 423 | log_error("%s" % result) |
| 424 | sys.exit(0) |
| 425 | |
| 426 | topo = {} |
| 427 | switches = [] |
| 428 | links = [] |
| 429 | |
| 430 | for v in parsedResult: |
| 431 | if v.has_key('dpid'): |
| 432 | dpid = str(v['dpid']) |
| 433 | state = str(v['state']) |
| 434 | sw = {} |
| 435 | sw['name']=dpid |
| 436 | if str(v['state']) == "ACTIVE": |
| 437 | if dpid[-2:-1] == "a": |
| 438 | sw['group']=1 |
| 439 | if dpid[-2:-1] == "b": |
| 440 | sw['group']=2 |
| 441 | if dpid[-2:-1] == "c": |
| 442 | sw['group']=3 |
| 443 | if str(v['state']) == "INACTIVE": |
| 444 | sw['group']=0 |
| 445 | |
| 446 | switches.append(sw) |
| 447 | |
| 448 | try: |
| 449 | command = "curl -s http://%s:%s/wm/topology/route/%s/%s/%s/%s/json" % (RestIP, RestPort, v1, p1, v2, p2) |
| 450 | result = os.popen(command).read() |
| 451 | parsedResult = json.loads(result) |
| 452 | except: |
| 453 | log_error("No route") |
| 454 | parsedResult = [] |
| 455 | # exit(1) |
| 456 | |
Paul Greyson | 4e6dc3a | 2013-03-27 11:37:14 -0700 | [diff] [blame] | 457 | path = []; |
Ubuntu | aea2a68 | 2013-02-08 08:30:10 +0000 | [diff] [blame] | 458 | for i, v in enumerate(parsedResult): |
| 459 | if i < len(parsedResult) - 1: |
| 460 | sdpid= parsedResult[i]['switch'] |
| 461 | ddpid = parsedResult[i+1]['switch'] |
Paul Greyson | 4e6dc3a | 2013-03-27 11:37:14 -0700 | [diff] [blame] | 462 | path.append( (sdpid, ddpid)) |
Ubuntu | aea2a68 | 2013-02-08 08:30:10 +0000 | [diff] [blame] | 463 | |
| 464 | try: |
| 465 | command = "curl -s \'http://%s:%s/wm/core/topology/links/json\'" % (RestIP, RestPort) |
| 466 | result = os.popen(command).read() |
| 467 | parsedResult = json.loads(result) |
| 468 | except: |
| 469 | log_error("REST IF has issue: %s" % command) |
| 470 | log_error("%s" % result) |
| 471 | sys.exit(0) |
| 472 | |
| 473 | for v in parsedResult: |
| 474 | link = {} |
| 475 | if v.has_key('dst-switch'): |
| 476 | dst_dpid = str(v['dst-switch']) |
| 477 | dst_id = node_id(switches, dst_dpid) |
| 478 | if v.has_key('src-switch'): |
| 479 | src_dpid = str(v['src-switch']) |
| 480 | src_id = node_id(switches, src_dpid) |
| 481 | link['source'] = src_id |
| 482 | link['target'] = dst_id |
| 483 | onpath = 0 |
| 484 | for (s,d) in path: |
| 485 | if s == v['src-switch'] and d == v['dst-switch']: |
| 486 | onpath = 1 |
| 487 | break |
| 488 | |
| 489 | link['type'] = onpath |
| 490 | links.append(link) |
| 491 | |
| 492 | topo['nodes'] = switches |
| 493 | topo['links'] = links |
| 494 | |
Ubuntu | aea2a68 | 2013-02-08 08:30:10 +0000 | [diff] [blame] | 495 | js = json.dumps(topo) |
| 496 | resp = Response(js, status=200, mimetype='application/json') |
| 497 | return resp |
| 498 | |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 499 | @app.route("/wm/core/controller/switches/json") |
| 500 | def query_switch(): |
| 501 | try: |
| 502 | command = "curl -s \'http://%s:%s/wm/core/topology/switches/all/json\'" % (RestIP, RestPort) |
| 503 | # http://localhost:8080/wm/core/topology/switches/active/json |
Masayoshi Kobayashi | f63ef2f | 2013-02-20 21:47:21 +0000 | [diff] [blame] | 504 | print command |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 505 | result = os.popen(command).read() |
| 506 | parsedResult = json.loads(result) |
| 507 | except: |
| 508 | log_error("REST IF has issue: %s" % command) |
| 509 | log_error("%s" % result) |
| 510 | sys.exit(0) |
| 511 | |
| 512 | # print command |
| 513 | # print result |
| 514 | switches_ = [] |
| 515 | for v in parsedResult: |
| 516 | if v.has_key('dpid'): |
| 517 | if v.has_key('dpid') and str(v['state']) == "ACTIVE":#;if you want only ACTIVE nodes |
| 518 | dpid = str(v['dpid']) |
| 519 | state = str(v['state']) |
| 520 | sw = {} |
| 521 | sw['dpid']=dpid |
| 522 | sw['active']=state |
| 523 | switches_.append(sw) |
| 524 | |
Masayoshi Kobayashi | 1407a50 | 2013-02-27 06:23:08 +0000 | [diff] [blame] | 525 | # pp.pprint(switches_) |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 526 | js = json.dumps(switches_) |
| 527 | resp = Response(js, status=200, mimetype='application/json') |
| 528 | return resp |
| 529 | |
| 530 | @app.route("/wm/device/") |
| 531 | def devices(): |
| 532 | try: |
| 533 | command = "curl -s http://%s:%s/graphs/%s/vertices\?key=type\&value=device" % (RestIP, RestPort, DBName) |
| 534 | result = os.popen(command).read() |
| 535 | parsedResult = json.loads(result)['results'] |
| 536 | except: |
| 537 | log_error("REST IF has issue: %s" % command) |
| 538 | log_error("%s" % result) |
| 539 | sys.exit(0) |
| 540 | |
| 541 | devices = [] |
| 542 | for v in parsedResult: |
| 543 | dl_addr = v['dl_addr'] |
| 544 | nw_addr = v['nw_addr'] |
| 545 | vertex = v['_id'] |
| 546 | mac = [] |
| 547 | mac.append(dl_addr) |
| 548 | ip = [] |
| 549 | ip.append(nw_addr) |
| 550 | device = {} |
| 551 | device['entryClass']="DefaultEntryClass" |
| 552 | device['mac']=mac |
| 553 | device['ipv4']=ip |
| 554 | device['vlan']=[] |
| 555 | device['lastSeen']=0 |
| 556 | attachpoints =[] |
| 557 | |
| 558 | port, dpid = deviceV_to_attachpoint(vertex) |
| 559 | attachpoint = {} |
| 560 | attachpoint['port']=port |
| 561 | attachpoint['switchDPID']=dpid |
| 562 | attachpoints.append(attachpoint) |
| 563 | device['attachmentPoint']=attachpoints |
| 564 | devices.append(device) |
| 565 | |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 566 | js = json.dumps(devices) |
| 567 | resp = Response(js, status=200, mimetype='application/json') |
| 568 | return resp |
| 569 | |
| 570 | #{"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} |
| 571 | |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 572 | ## return fake stat for now |
| 573 | @app.route("/wm/core/switch/<switchId>/<statType>/json") |
| 574 | def switch_stat(switchId, statType): |
| 575 | if statType == "desc": |
| 576 | desc=[{"length":1056,"serialNumber":"None","manufacturerDescription":"Nicira Networks, Inc.","hardwareDescription":"Open vSwitch","softwareDescription":"1.4.0+build0","datapathDescription":"None"}] |
| 577 | ret = {} |
| 578 | ret[switchId]=desc |
| 579 | elif statType == "aggregate": |
| 580 | aggr = {"packetCount":0,"byteCount":0,"flowCount":0} |
| 581 | ret = {} |
| 582 | ret[switchId]=aggr |
| 583 | else: |
Paul Greyson | 4e6dc3a | 2013-03-27 11:37:14 -0700 | [diff] [blame] | 584 | ret = {} |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 585 | |
| 586 | js = json.dumps(ret) |
| 587 | resp = Response(js, status=200, mimetype='application/json') |
| 588 | return resp |
| 589 | |
| 590 | |
| 591 | @app.route("/wm/topology/links/json") |
| 592 | def query_links(): |
| 593 | try: |
| 594 | command = 'curl -s http://%s:%s/graphs/%s/vertices?key=type\&value=port' % (RestIP, RestPort, DBName) |
Masayoshi Kobayashi | f63ef2f | 2013-02-20 21:47:21 +0000 | [diff] [blame] | 595 | print command |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 596 | result = os.popen(command).read() |
| 597 | parsedResult = json.loads(result)['results'] |
| 598 | except: |
| 599 | log_error("REST IF has issue: %s" % command) |
| 600 | log_error("%s" % result) |
| 601 | sys.exit(0) |
| 602 | |
| 603 | debug("query_links %s" % command) |
Masayoshi Kobayashi | 1407a50 | 2013-02-27 06:23:08 +0000 | [diff] [blame] | 604 | # pp.pprint(parsedResult) |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 605 | sport = [] |
| 606 | links = [] |
| 607 | for v in parsedResult: |
| 608 | srcport = v['_id'] |
| 609 | try: |
| 610 | command = "curl -s http://%s:%s/graphs/%s/vertices/%d/out?_label=link" % (RestIP, RestPort, DBName, srcport) |
| 611 | print command |
| 612 | result = os.popen(command).read() |
| 613 | linkResults = json.loads(result)['results'] |
| 614 | except: |
| 615 | log_error("REST IF has issue: %s" % command) |
| 616 | log_error("%s" % result) |
| 617 | sys.exit(0) |
| 618 | |
| 619 | for p in linkResults: |
| 620 | if p.has_key('type') and p['type'] == "port": |
| 621 | dstport = p['_id'] |
| 622 | (sport, sdpid) = portV_to_port_dpid(srcport) |
| 623 | (dport, ddpid) = portV_to_port_dpid(dstport) |
| 624 | link = {} |
| 625 | link["src-switch"]=sdpid |
| 626 | link["src-port"]=sport |
| 627 | link["src-port-state"]=0 |
| 628 | link["dst-switch"]=ddpid |
| 629 | link["dst-port"]=dport |
| 630 | link["dst-port-state"]=0 |
| 631 | link["type"]="internal" |
| 632 | links.append(link) |
| 633 | |
Masayoshi Kobayashi | 1407a50 | 2013-02-27 06:23:08 +0000 | [diff] [blame] | 634 | # pp.pprint(links) |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 635 | js = json.dumps(links) |
| 636 | resp = Response(js, status=200, mimetype='application/json') |
| 637 | return resp |
| 638 | |
Ubuntu | c016ba1 | 2013-02-27 21:53:41 +0000 | [diff] [blame] | 639 | @app.route("/controller_status") |
| 640 | def controller_status(): |
Tim Lindberg | 201ade2 | 2013-04-05 11:52:08 -0700 | [diff] [blame] | 641 | # onos_check="ssh -i ~/.ssh/onlabkey.pem %s ONOS/start-onos.sh status | awk '{print $1}'" |
| 642 | onos_check="cd; onos status %s | grep %s | awk '{print $2}'" |
Ubuntu | c016ba1 | 2013-02-27 21:53:41 +0000 | [diff] [blame] | 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] |
Tim Lindberg | 201ade2 | 2013-04-05 11:52:08 -0700 | [diff] [blame] | 649 | onos=os.popen(onos_check % (i, i.lower())).read()[:-1] |
Ubuntu | c016ba1 | 2013-02-27 21:53:41 +0000 | [diff] [blame] | 650 | status["name"]=i |
| 651 | status["onos"]=onos |
Masayoshi Kobayashi | 5e91bdf | 2013-03-15 01:22:51 +0000 | [diff] [blame] | 652 | status["cassandra"]=0 |
Ubuntu | c016ba1 | 2013-02-27 21:53:41 +0000 | [diff] [blame] | 653 | cont_status.append(status) |
| 654 | |
| 655 | js = json.dumps(cont_status) |
| 656 | resp = Response(js, status=200, mimetype='application/json') |
Ubuntu | c016ba1 | 2013-02-27 21:53:41 +0000 | [diff] [blame] | 657 | return resp |
| 658 | |
Masayoshi Kobayashi | 2ae891a | 2013-04-05 02:16:19 +0000 | [diff] [blame] | 659 | ### Command ### |
Masayoshi Kobayashi | 5101152 | 2013-03-27 00:18:12 +0000 | [diff] [blame] | 660 | @app.route("/gui/controller/<cmd>/<controller_name>") |
| 661 | def controller_status_change(cmd, controller_name): |
Tim Lindberg | 201ade2 | 2013-04-05 11:52:08 -0700 | [diff] [blame] | 662 | # start_onos="ssh -i ~/.ssh/onlabkey.pem %s ONOS/start-onos.sh start" % (controller_name) |
| 663 | # stop_onos="ssh -i ~/.ssh/onlabkey.pem %s ONOS/start-onos.sh stop" % (controller_name) |
| 664 | start_onos="cd; onos start %s" % (controller_name[-1:]) |
| 665 | stop_onos="cd; onos stop %s" % (controller_name[-1:]) |
Masayoshi Kobayashi | 5101152 | 2013-03-27 00:18:12 +0000 | [diff] [blame] | 666 | |
| 667 | if cmd == "up": |
Masayoshi Kobayashi | 1e07238 | 2013-03-27 05:17:09 +0000 | [diff] [blame] | 668 | result=os.popen(start_onos).read() |
Masayoshi Kobayashi | 5101152 | 2013-03-27 00:18:12 +0000 | [diff] [blame] | 669 | ret = "controller %s is up" % (controller_name) |
| 670 | elif cmd == "down": |
Masayoshi Kobayashi | 1e07238 | 2013-03-27 05:17:09 +0000 | [diff] [blame] | 671 | result=os.popen(stop_onos).read() |
Masayoshi Kobayashi | 5101152 | 2013-03-27 00:18:12 +0000 | [diff] [blame] | 672 | ret = "controller %s is down" % (controller_name) |
| 673 | |
| 674 | return ret |
| 675 | |
Masayoshi Kobayashi | 03e64b4 | 2013-04-05 05:56:27 +0000 | [diff] [blame] | 676 | @app.route("/gui/switchctrl/<cmd>") |
| 677 | def switch_controller_setting(cmd): |
| 678 | if cmd =="local": |
| 679 | print "All aggr switches connects to local controller only" |
| 680 | result="" |
Tim Lindberg | 201ade2 | 2013-04-05 11:52:08 -0700 | [diff] [blame] | 681 | if (TESTBED == "sw"): |
| 682 | for i in range(0, len(controllers)): |
| 683 | cmd_string="ssh -i ~/.ssh/onlabkey.pem %s 'cd ONOS/scripts; ./ctrl-local.sh'" % (controllers[i]) |
| 684 | result += os.popen(cmd_string).read() |
| 685 | else: |
| 686 | cmd_string="cd; switch local" |
Masayoshi Kobayashi | 03e64b4 | 2013-04-05 05:56:27 +0000 | [diff] [blame] | 687 | result += os.popen(cmd_string).read() |
| 688 | elif cmd =="all": |
| 689 | print "All aggr switches connects to all controllers except for core controller" |
| 690 | result="" |
Tim Lindberg | 201ade2 | 2013-04-05 11:52:08 -0700 | [diff] [blame] | 691 | if (TESTBED == "sw"): |
| 692 | for i in range(0, len(controllers)): |
| 693 | cmd_string="ssh -i ~/.ssh/onlabkey.pem %s 'cd ONOS/scripts; ./ctrl-add-ext.sh'" % (controllers[i]) |
| 694 | result += os.popen(cmd_string).read() |
| 695 | else: |
| 696 | cmd_string="cd; switch all" |
Masayoshi Kobayashi | 03e64b4 | 2013-04-05 05:56:27 +0000 | [diff] [blame] | 697 | result += os.popen(cmd_string).read() |
| 698 | |
| 699 | return result |
| 700 | |
| 701 | |
| 702 | |
Masayoshi Kobayashi | 5101152 | 2013-03-27 00:18:12 +0000 | [diff] [blame] | 703 | @app.route("/gui/switch/<cmd>/<dpid>") |
| 704 | def switch_status_change(cmd, dpid): |
Tim Lindberg | 201ade2 | 2013-04-05 11:52:08 -0700 | [diff] [blame] | 705 | result = "" |
| 706 | if (TESTBED == "hw"): |
| 707 | return result |
| 708 | |
Masayoshi Kobayashi | 5101152 | 2013-03-27 00:18:12 +0000 | [diff] [blame] | 709 | r = re.compile(':') |
| 710 | dpid = re.sub(r, '', dpid) |
Masayoshi Kobayashi | c0bc319 | 2013-03-27 23:12:03 +0000 | [diff] [blame] | 711 | host=controllers[0] |
| 712 | cmd_string="ssh -i ~/.ssh/onlabkey.pem %s 'cd ONOS/scripts; ./switch.sh %s %s'" % (host, dpid, cmd) |
| 713 | get_status="ssh -i ~/.ssh/onlabkey.pem %s 'cd ONOS/scripts; ./switch.sh %s'" % (host, dpid) |
Masayoshi Kobayashi | 5101152 | 2013-03-27 00:18:12 +0000 | [diff] [blame] | 714 | print "cmd_string" |
| 715 | |
| 716 | if cmd =="up" or cmd=="down": |
| 717 | print "make dpid %s %s" % (dpid, cmd) |
Masayoshi Kobayashi | 1e07238 | 2013-03-27 05:17:09 +0000 | [diff] [blame] | 718 | os.popen(cmd_string) |
| 719 | result=os.popen(get_status).read() |
Masayoshi Kobayashi | 5101152 | 2013-03-27 00:18:12 +0000 | [diff] [blame] | 720 | |
Masayoshi Kobayashi | 1e07238 | 2013-03-27 05:17:09 +0000 | [diff] [blame] | 721 | return result |
Masayoshi Kobayashi | 5101152 | 2013-03-27 00:18:12 +0000 | [diff] [blame] | 722 | |
Masayoshi Kobayashi | decab44 | 2013-03-28 11:19:13 +0000 | [diff] [blame] | 723 | #* Link Up |
Masayoshi Kobayashi | 5101152 | 2013-03-27 00:18:12 +0000 | [diff] [blame] | 724 | #http://localhost:9000/gui/link/up/<src_dpid>/<src_port>/<dst_dpid>/<dst_port> |
Masayoshi Kobayashi | decab44 | 2013-03-28 11:19:13 +0000 | [diff] [blame] | 725 | @app.route("/gui/link/up/<src_dpid>/<src_port>/<dst_dpid>/<dst_port>") |
| 726 | def link_up(src_dpid, src_port, dst_dpid, dst_port): |
Tim Lindberg | 201ade2 | 2013-04-05 11:52:08 -0700 | [diff] [blame] | 727 | result = "" |
| 728 | |
| 729 | if (TESTBED == "sw"): |
| 730 | result = link_up_sw(src_dpid, src_port, dst_dpid, dst_port) |
| 731 | else: |
| 732 | result = link_up_hw(src_dpid, src_port, dst_dpid, dst_port) |
| 733 | return result |
| 734 | |
| 735 | # Link up on software testbed |
| 736 | def link_up_sw(src_dpid, src_port, dst_dpid, dst_port): |
Masayoshi Kobayashi | 1e07238 | 2013-03-27 05:17:09 +0000 | [diff] [blame] | 737 | |
Masayoshi Kobayashi | decab44 | 2013-03-28 11:19:13 +0000 | [diff] [blame] | 738 | cmd = 'up' |
| 739 | result="" |
| 740 | |
Paul Greyson | 472da4c | 2013-03-28 11:43:17 -0700 | [diff] [blame] | 741 | for dpid in (src_dpid, dst_dpid): |
Masayoshi Kobayashi | decab44 | 2013-03-28 11:19:13 +0000 | [diff] [blame] | 742 | if dpid in core_switches: |
| 743 | host = controllers[0] |
| 744 | src_ports = [1, 2, 3, 4, 5] |
| 745 | else: |
Masayoshi Kobayashi | 05f12b3 | 2013-04-01 09:08:09 +0000 | [diff] [blame] | 746 | hostid=int(dpid.split(':')[-2]) |
Masayoshi Kobayashi | decab44 | 2013-03-28 11:19:13 +0000 | [diff] [blame] | 747 | host = controllers[hostid-1] |
| 748 | if hostid == 2 : |
| 749 | src_ports = [51] |
| 750 | else : |
| 751 | src_ports = [26] |
| 752 | |
| 753 | for port in src_ports : |
| 754 | cmd_string="ssh -i ~/.ssh/onlabkey.pem %s 'cd ONOS/scripts; ./link.sh %s %s %s'" % (host, dpid, port, cmd) |
| 755 | print cmd_string |
| 756 | res=os.popen(cmd_string).read() |
| 757 | result = result + ' ' + res |
| 758 | |
| 759 | return result |
| 760 | |
Tim Lindberg | 201ade2 | 2013-04-05 11:52:08 -0700 | [diff] [blame] | 761 | # Link up on hardware testbed |
| 762 | def link_up_hw(src_dpid, src_port, dst_dpid, dst_port): |
| 763 | |
| 764 | port1 = src_port |
| 765 | port2 = dst_port |
| 766 | if src_dpid == "00:00:00:00:ba:5e:ba:11": |
| 767 | if dst_dpid == "00:00:00:08:a2:08:f9:01": |
| 768 | port1 = 24 |
| 769 | port2 = 24 |
| 770 | elif dst_dpid == "00:01:00:16:97:08:9a:46": |
| 771 | port1 = 23 |
| 772 | port2 = 23 |
| 773 | elif src_dpid == "00:00:00:00:ba:5e:ba:13": |
| 774 | if dst_dpid == "00:00:20:4e:7f:51:8a:35": |
| 775 | port1 = 22 |
| 776 | port2 = 22 |
| 777 | elif dst_dpid == "00:00:00:00:00:00:ba:12": |
| 778 | port1 = 23 |
| 779 | port2 = 23 |
| 780 | elif src_dpid == "00:00:00:00:00:00:ba:12": |
| 781 | if dst_dpid == "00:00:00:00:ba:5e:ba:13": |
| 782 | port1 = 23 |
| 783 | port2 = 23 |
| 784 | elif dst_dpid == "00:00:00:08:a2:08:f9:01": |
| 785 | port1 = 22 |
| 786 | port2 = 22 |
| 787 | elif dst_dpid == "00:00:20:4e:7f:51:8a:35": |
| 788 | port1 = 24 |
| 789 | port2 = 21 |
| 790 | elif src_dpid == "00:01:00:16:97:08:9a:46": |
| 791 | if dst_dpid == "00:00:00:00:ba:5e:ba:11": |
| 792 | port1 = 23 |
| 793 | port2 = 23 |
| 794 | elif dst_dpid == "00:00:20:4e:7f:51:8a:35": |
| 795 | port1 = 24 |
| 796 | port2 = 24 |
| 797 | elif src_dpid == "00:00:00:08:a2:08:f9:01": |
| 798 | if dst_dpid == "00:00:00:00:ba:5e:ba:11": |
| 799 | port1 = 24 |
| 800 | port2 = 24 |
| 801 | elif dst_dpid == "00:00:00:00:00:00:ba:12": |
| 802 | port1 = 22 |
| 803 | port2 = 22 |
| 804 | elif dst_dpid == "00:00:20:4e:7f:51:8a:35": |
| 805 | port1 = 23 |
| 806 | port2 = 23 |
| 807 | elif src_dpid == "00:00:20:4e:7f:51:8a:35": |
| 808 | if dst_dpid == "00:00:00:00:00:00:ba:12": |
| 809 | port1 = 21 |
| 810 | port2 = 24 |
| 811 | elif dst_dpid == "00:00:00:00:ba:5e:ba:13": |
| 812 | port1 = 22 |
| 813 | port2 = 22 |
| 814 | elif dst_dpid == "00:01:00:16:97:08:9a:46": |
| 815 | port1 = 24 |
| 816 | port2 = 24 |
| 817 | elif dst_dpid == "00:00:00:08:a2:08:f9:01": |
| 818 | port1 = 23 |
| 819 | port2 = 23 |
| 820 | |
| 821 | cmd = 'up' |
| 822 | result="" |
| 823 | host = controllers[0] |
| 824 | cmd_string="~/ONOS/scripts/link.sh %s %s %s " % (src_dpid, port1, cmd) |
| 825 | print cmd_string |
| 826 | res=os.popen(cmd_string).read() |
| 827 | result = result + ' ' + res |
| 828 | cmd_string="~/ONOS/scripts/link.sh %s %s %s " % (dst_dpid, port2, cmd) |
| 829 | print cmd_string |
| 830 | res=os.popen(cmd_string).read() |
| 831 | result = result + ' ' + res |
| 832 | |
| 833 | |
| 834 | return result |
| 835 | |
Masayoshi Kobayashi | decab44 | 2013-03-28 11:19:13 +0000 | [diff] [blame] | 836 | |
| 837 | #* Link Down |
| 838 | #http://localhost:9000/gui/link/down/<src_dpid>/<src_port>/<dst_dpid>/<dst_port> |
Masayoshi Kobayashi | 1e07238 | 2013-03-27 05:17:09 +0000 | [diff] [blame] | 839 | @app.route("/gui/link/<cmd>/<src_dpid>/<src_port>/<dst_dpid>/<dst_port>") |
Masayoshi Kobayashi | decab44 | 2013-03-28 11:19:13 +0000 | [diff] [blame] | 840 | def link_down(cmd, src_dpid, src_port, dst_dpid, dst_port): |
| 841 | |
Masayoshi Kobayashi | 1e07238 | 2013-03-27 05:17:09 +0000 | [diff] [blame] | 842 | if src_dpid in core_switches: |
| 843 | host = controllers[0] |
| 844 | else: |
| 845 | hostid=int(src_dpid.split(':')[-2]) |
| 846 | host = controllers[hostid-1] |
| 847 | |
Tim Lindberg | 201ade2 | 2013-04-05 11:52:08 -0700 | [diff] [blame] | 848 | if (TESTBED == "sw"): |
| 849 | cmd_string="ssh -i ~/.ssh/onlabkey.pem %s 'cd ONOS/scripts; ./link.sh %s %s %s'" % (host, src_dpid, src_port, cmd) |
| 850 | else: |
Tim Lindberg | a6c0417 | 2013-04-05 17:34:05 -0700 | [diff] [blame] | 851 | if ( src_dpid == "00:00:00:08:a2:08:f9:01" ): |
| 852 | cmd_string="~/ONOS/scripts/link.sh %s %s %s " % ( dst_dpid, dst_port, cmd) |
| 853 | else: |
| 854 | cmd_string="~/ONOS/scripts/link.sh %s %s %s " % ( src_dpid, src_port, cmd) |
Masayoshi Kobayashi | 1e07238 | 2013-03-27 05:17:09 +0000 | [diff] [blame] | 855 | print cmd_string |
| 856 | |
Masayoshi Kobayashi | decab44 | 2013-03-28 11:19:13 +0000 | [diff] [blame] | 857 | result=os.popen(cmd_string).read() |
Masayoshi Kobayashi | 1e07238 | 2013-03-27 05:17:09 +0000 | [diff] [blame] | 858 | |
| 859 | return result |
| 860 | |
Masayoshi Kobayashi | 5101152 | 2013-03-27 00:18:12 +0000 | [diff] [blame] | 861 | #* Create Flow |
| 862 | #http://localhost:9000/gui/addflow/<src_dpid>/<src_port>/<dst_dpid>/<dst_port>/<srcMAC>/<dstMAC> |
Masayoshi Kobayashi | 1e07238 | 2013-03-27 05:17:09 +0000 | [diff] [blame] | 863 | #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 Kobayashi | 81f6565 | 2013-03-28 21:06:39 +0000 | [diff] [blame] | 864 | @app.route("/gui/addflow/<src_dpid>/<src_port>/<dst_dpid>/<dst_port>/<srcMAC>/<dstMAC>") |
Masayoshi Kobayashi | 1e07238 | 2013-03-27 05:17:09 +0000 | [diff] [blame] | 865 | def add_flow(src_dpid, src_port, dst_dpid, dst_port, srcMAC, dstMAC): |
| 866 | command = "/home/ubuntu/ONOS/web/get_flow.py all |grep FlowPath |gawk '{print strtonum($4)}'| sort -n | tail -n 1" |
| 867 | print command |
| 868 | ret = os.popen(command).read() |
| 869 | if ret == "": |
| 870 | flow_nr=0 |
| 871 | else: |
| 872 | flow_nr=int(ret) |
| 873 | |
| 874 | flow_nr += 1 |
Umesh Krishnaswamy | f22d3ed | 2013-04-03 11:57:54 -0700 | [diff] [blame] | 875 | 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 Kobayashi | cdb652f | 2013-04-04 18:24:29 +0000 | [diff] [blame] | 876 | 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 Kobayashi | 1e07238 | 2013-03-27 05:17:09 +0000 | [diff] [blame] | 877 | print command |
| 878 | errcode = os.popen(command).read() |
Masayoshi Kobayashi | cdb652f | 2013-04-04 18:24:29 +0000 | [diff] [blame] | 879 | errcode1 = os.popen(command1).read() |
| 880 | return errcode+" "+errcode1 |
Masayoshi Kobayashi | 1e07238 | 2013-03-27 05:17:09 +0000 | [diff] [blame] | 881 | |
Masayoshi Kobayashi | 5101152 | 2013-03-27 00:18:12 +0000 | [diff] [blame] | 882 | #* Delete Flow |
| 883 | #http://localhost:9000/gui/delflow/<flow_id> |
Masayoshi Kobayashi | 1e07238 | 2013-03-27 05:17:09 +0000 | [diff] [blame] | 884 | @app.route("/gui/delflow/<flow_id>") |
| 885 | def del_flow(flow_id): |
| 886 | command = "/home/ubuntu/ONOS/web/delete_flow.py %s" % (flow_id) |
| 887 | print command |
| 888 | errcode = os.popen(command).read() |
| 889 | return errcode |
| 890 | |
Masayoshi Kobayashi | 5101152 | 2013-03-27 00:18:12 +0000 | [diff] [blame] | 891 | #* Start Iperf Througput |
Umesh Krishnaswamy | 6689be3 | 2013-03-27 18:12:26 -0700 | [diff] [blame] | 892 | #http://localhost:9000/gui/iperf/start/<flow_id>/<duration> |
Masayoshi Kobayashi | 3d04931 | 2013-04-02 22:15:16 +0000 | [diff] [blame] | 893 | @app.route("/gui/iperf/start/<flow_id>/<duration>/<samples>") |
| 894 | def iperf_start(flow_id,duration,samples): |
Masayoshi Kobayashi | fd56631 | 2013-04-01 10:34:01 +0000 | [diff] [blame] | 895 | try: |
Masayoshi Kobayashi | 3d04931 | 2013-04-02 22:15:16 +0000 | [diff] [blame] | 896 | command = "curl -s \'http://%s:%s/wm/flow/get/%s/json\'" % (RestIP, RestPort, flow_id) |
Masayoshi Kobayashi | fd56631 | 2013-04-01 10:34:01 +0000 | [diff] [blame] | 897 | print command |
| 898 | result = os.popen(command).read() |
| 899 | if len(result) == 0: |
| 900 | print "No Flow found" |
| 901 | return; |
Masayoshi Kobayashi | fd56631 | 2013-04-01 10:34:01 +0000 | [diff] [blame] | 902 | except: |
| 903 | print "REST IF has issue" |
| 904 | exit |
| 905 | |
Masayoshi Kobayashi | 3d04931 | 2013-04-02 22:15:16 +0000 | [diff] [blame] | 906 | parsedResult = json.loads(result) |
| 907 | |
Masayoshi Kobayashi | 03e64b4 | 2013-04-05 05:56:27 +0000 | [diff] [blame] | 908 | # flowId = int(parsedResult['flowId']['value'], 16) |
Masayoshi Kobayashi | 3d04931 | 2013-04-02 22:15:16 +0000 | [diff] [blame] | 909 | flowId = int(parsedResult['flowId']['value'], 16) |
Masayoshi Kobayashi | fd56631 | 2013-04-01 10:34:01 +0000 | [diff] [blame] | 910 | src_dpid = parsedResult['dataPath']['srcPort']['dpid']['value'] |
| 911 | src_port = parsedResult['dataPath']['srcPort']['port']['value'] |
| 912 | dst_dpid = parsedResult['dataPath']['dstPort']['dpid']['value'] |
| 913 | dst_port = parsedResult['dataPath']['dstPort']['port']['value'] |
Masayoshi Kobayashi | 3d04931 | 2013-04-02 22:15:16 +0000 | [diff] [blame] | 914 | # print "FlowPath: (flowId = %s src = %s/%s dst = %s/%s" % (flowId, src_dpid, src_port, dst_dpid, dst_port) |
Masayoshi Kobayashi | fd56631 | 2013-04-01 10:34:01 +0000 | [diff] [blame] | 915 | |
| 916 | if src_dpid in core_switches: |
| 917 | host = controllers[0] |
| 918 | else: |
| 919 | hostid=int(src_dpid.split(':')[-2]) |
| 920 | host = controllers[hostid-1] |
| 921 | |
Masayoshi Kobayashi | 3d04931 | 2013-04-02 22:15:16 +0000 | [diff] [blame] | 922 | # ./runiperf.sh 2 00:00:00:00:00:00:02:02 1 00:00:00:00:00:00:03:02 1 100 15 |
| 923 | 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 Kobayashi | fd56631 | 2013-04-01 10:34:01 +0000 | [diff] [blame] | 924 | print cmd_string |
Masayoshi Kobayashi | 3d04931 | 2013-04-02 22:15:16 +0000 | [diff] [blame] | 925 | os.popen(cmd_string) |
Masayoshi Kobayashi | fd56631 | 2013-04-01 10:34:01 +0000 | [diff] [blame] | 926 | |
Masayoshi Kobayashi | cdb652f | 2013-04-04 18:24:29 +0000 | [diff] [blame] | 927 | return cmd_string |
Masayoshi Kobayashi | 1e07238 | 2013-03-27 05:17:09 +0000 | [diff] [blame] | 928 | |
Masayoshi Kobayashi | 5101152 | 2013-03-27 00:18:12 +0000 | [diff] [blame] | 929 | #* Get Iperf Throughput |
| 930 | #http://localhost:9000/gui/iperf/rate/<flow_id> |
Masayoshi Kobayashi | 1e07238 | 2013-03-27 05:17:09 +0000 | [diff] [blame] | 931 | @app.route("/gui/iperf/rate/<flow_id>") |
| 932 | def iperf_rate(flow_id): |
Tim Lindberg | a6c0417 | 2013-04-05 17:34:05 -0700 | [diff] [blame] | 933 | if (TESTBED == "hw"): |
| 934 | return "{}" |
| 935 | |
Masayoshi Kobayashi | 1e07238 | 2013-03-27 05:17:09 +0000 | [diff] [blame] | 936 | try: |
Masayoshi Kobayashi | 3d04931 | 2013-04-02 22:15:16 +0000 | [diff] [blame] | 937 | command = "curl -s \'http://%s:%s/wm/flow/get/%s/json\'" % (RestIP, RestPort, flow_id) |
| 938 | print command |
| 939 | result = os.popen(command).read() |
| 940 | if len(result) == 0: |
Masayoshi Kobayashi | 2ae891a | 2013-04-05 02:16:19 +0000 | [diff] [blame] | 941 | resp = Response(result, status=400, mimetype='text/html') |
| 942 | return "no such iperf flow (flowid %s)" % flow_id; |
Masayoshi Kobayashi | 3d04931 | 2013-04-02 22:15:16 +0000 | [diff] [blame] | 943 | except: |
| 944 | print "REST IF has issue" |
| 945 | exit |
| 946 | |
| 947 | parsedResult = json.loads(result) |
| 948 | |
| 949 | flowId = int(parsedResult['flowId']['value'], 16) |
| 950 | src_dpid = parsedResult['dataPath']['srcPort']['dpid']['value'] |
| 951 | src_port = parsedResult['dataPath']['srcPort']['port']['value'] |
| 952 | dst_dpid = parsedResult['dataPath']['dstPort']['dpid']['value'] |
| 953 | dst_port = parsedResult['dataPath']['dstPort']['port']['value'] |
| 954 | |
| 955 | if src_dpid in core_switches: |
| 956 | host = controllers[0] |
| 957 | else: |
| 958 | hostid=int(src_dpid.split(':')[-2]) |
| 959 | host = controllers[hostid-1] |
| 960 | |
| 961 | try: |
| 962 | command = "curl -s http://%s:%s/log/iperf_%s.out" % (host, 9000, flow_id) |
Masayoshi Kobayashi | 1e07238 | 2013-03-27 05:17:09 +0000 | [diff] [blame] | 963 | print command |
| 964 | result = os.popen(command).read() |
| 965 | except: |
Masayoshi Kobayashi | 1e07238 | 2013-03-27 05:17:09 +0000 | [diff] [blame] | 966 | exit |
Masayoshi Kobayashi | 5101152 | 2013-03-27 00:18:12 +0000 | [diff] [blame] | 967 | |
Masayoshi Kobayashi | b56f297 | 2013-04-05 02:57:29 +0000 | [diff] [blame] | 968 | if len(result) == 0: |
| 969 | resp = Response(result, status=400, mimetype='text/html') |
| 970 | return "no iperf file found (flowid %s)" % flow_id; |
| 971 | else: |
| 972 | resp = Response(result, status=200, mimetype='application/json') |
| 973 | return resp |
Masayoshi Kobayashi | 5101152 | 2013-03-27 00:18:12 +0000 | [diff] [blame] | 974 | |
| 975 | |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 976 | if __name__ == "__main__": |
Masayoshi Kobayashi | 2ae891a | 2013-04-05 02:16:19 +0000 | [diff] [blame] | 977 | random.seed() |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 978 | if len(sys.argv) > 1 and sys.argv[1] == "-d": |
Masayoshi Kobayashi | 1e07238 | 2013-03-27 05:17:09 +0000 | [diff] [blame] | 979 | # 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") |
| 980 | # link_change("up", "00:00:00:00:ba:5e:ba:11", 1, "00:00:00:00:00:00:00:00", 1) |
| 981 | # link_change("down", "00:00:20:4e:7f:51:8a:35", 1, "00:00:00:00:00:00:00:00", 1) |
| 982 | # link_change("up", "00:00:00:00:00:00:02:03", 1, "00:00:00:00:00:00:00:00", 1) |
| 983 | # link_change("down", "00:00:00:00:00:00:07:12", 1, "00:00:00:00:00:00:00:00", 1) |
Masayoshi Kobayashi | 3d04931 | 2013-04-02 22:15:16 +0000 | [diff] [blame] | 984 | # print "-- query all switches --" |
| 985 | # query_switch() |
| 986 | # print "-- query topo --" |
| 987 | # topology_for_gui() |
Masayoshi Kobayashi | 1e07238 | 2013-03-27 05:17:09 +0000 | [diff] [blame] | 988 | # link_change(1,2,3,4) |
| 989 | print "-- query all links --" |
Masayoshi Kobayashi | 3d04931 | 2013-04-02 22:15:16 +0000 | [diff] [blame] | 990 | # query_links() |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 991 | # print "-- query all devices --" |
| 992 | # devices() |
Masayoshi Kobayashi | 2ae891a | 2013-04-05 02:16:19 +0000 | [diff] [blame] | 993 | # iperf_start(1,10,15) |
| 994 | # iperf_rate(1) |
| 995 | switches() |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 996 | else: |
| 997 | app.debug = True |
Masayoshi Kobayashi | f63ef2f | 2013-02-20 21:47:21 +0000 | [diff] [blame] | 998 | app.run(threaded=True, host="0.0.0.0", port=9000) |