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