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 |
| 10 | |
Masayoshi Kobayashi | 5101152 | 2013-03-27 00:18:12 +0000 | [diff] [blame] | 11 | import re |
| 12 | |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 13 | from flask import Flask, json, Response, render_template, make_response, request |
| 14 | |
| 15 | ## Global Var ## |
Ubuntu | f6ce96c | 2013-02-07 01:45:07 +0000 | [diff] [blame] | 16 | RestIP="localhost" |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 17 | RestPort=8080 |
| 18 | #DBName="onos-network-map" |
Masayoshi Kobayashi | 13e2ebe | 2013-03-26 18:38:41 +0000 | [diff] [blame] | 19 | #controllers=["onosgui1", "onosgui2", "onosgui3", "onosgui4"] |
| 20 | controllers=["onosgui1", "onosgui2", "onosgui3", "onosgui4", "onosgui5", "onosgui6", "onosgui7", "onosgui8"] |
Masayoshi Kobayashi | 1e07238 | 2013-03-27 05:17:09 +0000 | [diff] [blame] | 21 | 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"] |
| 22 | |
| 23 | nr_flow=0 |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 24 | |
| 25 | DEBUG=1 |
| 26 | pp = pprint.PrettyPrinter(indent=4) |
| 27 | |
| 28 | app = Flask(__name__) |
| 29 | |
| 30 | ## Worker Functions ## |
| 31 | def log_error(txt): |
| 32 | print '%s' % (txt) |
| 33 | |
| 34 | def debug(txt): |
| 35 | if DEBUG: |
| 36 | print '%s' % (txt) |
| 37 | |
| 38 | ## Rest APIs ## |
| 39 | ### File Fetch ### |
| 40 | @app.route('/ui/img/<filename>', methods=['GET']) |
| 41 | @app.route('/img/<filename>', methods=['GET']) |
| 42 | @app.route('/css/<filename>', methods=['GET']) |
| 43 | @app.route('/js/models/<filename>', methods=['GET']) |
| 44 | @app.route('/js/views/<filename>', methods=['GET']) |
| 45 | @app.route('/js/<filename>', methods=['GET']) |
| 46 | @app.route('/lib/<filename>', methods=['GET']) |
| 47 | @app.route('/', methods=['GET']) |
| 48 | @app.route('/<filename>', methods=['GET']) |
| 49 | @app.route('/tpl/<filename>', methods=['GET']) |
Masayoshi Kobayashi | 13e2ebe | 2013-03-26 18:38:41 +0000 | [diff] [blame] | 50 | @app.route('/ons-demo/<filename>', methods=['GET']) |
| 51 | @app.route('/ons-demo/js/<filename>', methods=['GET']) |
| 52 | @app.route('/ons-demo/css/<filename>', methods=['GET']) |
| 53 | @app.route('/ons-demo/assets/<filename>', methods=['GET']) |
| 54 | @app.route('/ons-demo/data/<filename>', methods=['GET']) |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 55 | def return_file(filename="index.html"): |
| 56 | if request.path == "/": |
| 57 | fullpath = "./index.html" |
| 58 | else: |
| 59 | fullpath = str(request.path)[1:] |
| 60 | |
| 61 | response = make_response(open(fullpath).read()) |
| 62 | suffix = fullpath.split(".")[-1] |
| 63 | |
| 64 | if suffix == "html" or suffix == "htm": |
| 65 | response.headers["Content-type"] = "text/html" |
| 66 | elif suffix == "js": |
| 67 | response.headers["Content-type"] = "application/javascript" |
| 68 | elif suffix == "css": |
| 69 | response.headers["Content-type"] = "text/css" |
| 70 | elif suffix == "png": |
| 71 | response.headers["Content-type"] = "image/png" |
| 72 | |
| 73 | return response |
| 74 | |
Masayoshi Kobayashi | 13e2ebe | 2013-03-26 18:38:41 +0000 | [diff] [blame] | 75 | ## PROXY API (allows development where the webui is served from someplace other than the controller)## |
| 76 | ONOS_GUI3_HOST="http://gui3.onlab.us:8080" |
Paul Greyson | 8d1c636 | 2013-03-27 13:05:24 -0700 | [diff] [blame^] | 77 | ONOS_GUI3_CONTROL_HOST="http://gui3.onlab.us:8081" |
Masayoshi Kobayashi | 13e2ebe | 2013-03-26 18:38:41 +0000 | [diff] [blame] | 78 | ONOS_LOCAL_HOST="http://localhost:8080" ;# for Amazon EC2 |
| 79 | |
Paul Greyson | 4e6dc3a | 2013-03-27 11:37:14 -0700 | [diff] [blame] | 80 | @app.route("/proxy/gui/link/<cmd>/<src_dpid>/<src_port>/<dst_dpid>/<dst_port>") |
| 81 | def proxy_link_change(cmd, src_dpid, src_port, dst_dpid, dst_port): |
| 82 | try: |
Paul Greyson | 8d1c636 | 2013-03-27 13:05:24 -0700 | [diff] [blame^] | 83 | 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] | 84 | print command |
| 85 | result = os.popen(command).read() |
| 86 | except: |
| 87 | print "REST IF has issue" |
| 88 | exit |
| 89 | |
| 90 | resp = Response(result, status=200, mimetype='application/json') |
| 91 | return resp |
| 92 | |
Paul Greyson | 8d1c636 | 2013-03-27 13:05:24 -0700 | [diff] [blame^] | 93 | @app.route("/proxy/gui/switch/<cmd>/<dpid>") |
| 94 | def proxy_switch_status_change(cmd, dpid): |
| 95 | try: |
| 96 | command = "curl -s %s/gui/switch/%s/%s" % (ONOS_GUI3_CONTROL_HOST, cmd, dpid) |
| 97 | print command |
| 98 | result = os.popen(command).read() |
| 99 | except: |
| 100 | print "REST IF has issue" |
| 101 | exit |
Paul Greyson | 4e6dc3a | 2013-03-27 11:37:14 -0700 | [diff] [blame] | 102 | |
Paul Greyson | 8d1c636 | 2013-03-27 13:05:24 -0700 | [diff] [blame^] | 103 | resp = Response(result, status=200, mimetype='application/json') |
| 104 | return resp |
Paul Greyson | 4e6dc3a | 2013-03-27 11:37:14 -0700 | [diff] [blame] | 105 | |
Masayoshi Kobayashi | 13e2ebe | 2013-03-26 18:38:41 +0000 | [diff] [blame] | 106 | @app.route("/wm/core/topology/switches/all/json") |
| 107 | def switches(): |
| 108 | if request.args.get('proxy') == None: |
| 109 | host = ONOS_LOCAL_HOST |
| 110 | else: |
| 111 | host = ONOS_GUI3_HOST |
| 112 | |
| 113 | try: |
| 114 | command = "curl -s %s/wm/core/topology/switches/all/json" % (host) |
Paul Greyson | 4e6dc3a | 2013-03-27 11:37:14 -0700 | [diff] [blame] | 115 | # print command |
Masayoshi Kobayashi | 13e2ebe | 2013-03-26 18:38:41 +0000 | [diff] [blame] | 116 | result = os.popen(command).read() |
| 117 | except: |
| 118 | print "REST IF has issue" |
| 119 | exit |
| 120 | |
| 121 | resp = Response(result, status=200, mimetype='application/json') |
| 122 | return resp |
| 123 | |
| 124 | @app.route("/wm/core/topology/links/json") |
| 125 | def links(): |
| 126 | if request.args.get('proxy') == None: |
| 127 | host = ONOS_LOCAL_HOST |
| 128 | else: |
| 129 | host = ONOS_GUI3_HOST |
| 130 | |
| 131 | try: |
| 132 | command = "curl -s %s/wm/core/topology/links/json" % (host) |
Paul Greyson | 8d1c636 | 2013-03-27 13:05:24 -0700 | [diff] [blame^] | 133 | print command |
Masayoshi Kobayashi | 13e2ebe | 2013-03-26 18:38:41 +0000 | [diff] [blame] | 134 | result = os.popen(command).read() |
| 135 | except: |
| 136 | print "REST IF has issue" |
| 137 | exit |
| 138 | |
| 139 | resp = Response(result, status=200, mimetype='application/json') |
| 140 | return resp |
| 141 | |
Masayoshi Kobayashi | 1e07238 | 2013-03-27 05:17:09 +0000 | [diff] [blame] | 142 | @app.route("/wm/flow/getsummary/0/0/json") |
Masayoshi Kobayashi | 13e2ebe | 2013-03-26 18:38:41 +0000 | [diff] [blame] | 143 | def flows(): |
| 144 | if request.args.get('proxy') == None: |
| 145 | host = ONOS_LOCAL_HOST |
| 146 | else: |
| 147 | host = ONOS_GUI3_HOST |
| 148 | |
| 149 | try: |
Masayoshi Kobayashi | 1e07238 | 2013-03-27 05:17:09 +0000 | [diff] [blame] | 150 | command = "curl -s %s/wm/flow/getsummary/0/0/json" % (host) |
Paul Greyson | 4e6dc3a | 2013-03-27 11:37:14 -0700 | [diff] [blame] | 151 | # print command |
Masayoshi Kobayashi | 13e2ebe | 2013-03-26 18:38:41 +0000 | [diff] [blame] | 152 | result = os.popen(command).read() |
| 153 | except: |
| 154 | print "REST IF has issue" |
| 155 | exit |
| 156 | |
| 157 | resp = Response(result, status=200, mimetype='application/json') |
| 158 | return resp |
| 159 | |
| 160 | @app.route("/wm/registry/controllers/json") |
| 161 | def registry_controllers(): |
| 162 | if request.args.get('proxy') == None: |
| 163 | host = ONOS_LOCAL_HOST |
| 164 | else: |
| 165 | host = ONOS_GUI3_HOST |
| 166 | |
| 167 | try: |
| 168 | command = "curl -s %s/wm/registry/controllers/json" % (host) |
Paul Greyson | 4e6dc3a | 2013-03-27 11:37:14 -0700 | [diff] [blame] | 169 | # print command |
Masayoshi Kobayashi | 13e2ebe | 2013-03-26 18:38:41 +0000 | [diff] [blame] | 170 | result = os.popen(command).read() |
| 171 | except: |
| 172 | print "REST IF has issue" |
| 173 | exit |
| 174 | |
| 175 | resp = Response(result, status=200, mimetype='application/json') |
| 176 | return resp |
| 177 | |
| 178 | @app.route("/wm/registry/switches/json") |
| 179 | def registry_switches(): |
| 180 | if request.args.get('proxy') == None: |
| 181 | host = ONOS_LOCAL_HOST |
| 182 | else: |
| 183 | host = ONOS_GUI3_HOST |
| 184 | |
| 185 | try: |
| 186 | command = "curl -s %s/wm/registry/switches/json" % (host) |
Paul Greyson | 4e6dc3a | 2013-03-27 11:37:14 -0700 | [diff] [blame] | 187 | # print command |
Masayoshi Kobayashi | 13e2ebe | 2013-03-26 18:38:41 +0000 | [diff] [blame] | 188 | result = os.popen(command).read() |
| 189 | except: |
| 190 | print "REST IF has issue" |
| 191 | exit |
| 192 | |
| 193 | resp = Response(result, status=200, mimetype='application/json') |
| 194 | return resp |
| 195 | |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 196 | |
| 197 | def node_id(switch_array, dpid): |
| 198 | id = -1 |
| 199 | for i, val in enumerate(switch_array): |
| 200 | if val['name'] == dpid: |
| 201 | id = i |
| 202 | break |
| 203 | |
| 204 | return id |
| 205 | |
Masayoshi Kobayashi | 13e2ebe | 2013-03-26 18:38:41 +0000 | [diff] [blame] | 206 | ## API for ON.Lab local GUI ## |
Masayoshi Kobayashi | f63ef2f | 2013-02-20 21:47:21 +0000 | [diff] [blame] | 207 | @app.route('/topology', methods=['GET']) |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 208 | def topology_for_gui(): |
| 209 | try: |
| 210 | command = "curl -s \'http://%s:%s/wm/core/topology/switches/all/json\'" % (RestIP, RestPort) |
| 211 | result = os.popen(command).read() |
| 212 | parsedResult = json.loads(result) |
| 213 | except: |
| 214 | log_error("REST IF has issue: %s" % command) |
| 215 | log_error("%s" % result) |
| 216 | sys.exit(0) |
| 217 | |
| 218 | topo = {} |
| 219 | switches = [] |
| 220 | links = [] |
Ubuntu | 37ebda6 | 2013-03-01 00:35:31 +0000 | [diff] [blame] | 221 | devices = [] |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 222 | |
| 223 | for v in parsedResult: |
| 224 | if v.has_key('dpid'): |
| 225 | # if v.has_key('dpid') and str(v['state']) == "ACTIVE":#;if you want only ACTIVE nodes |
| 226 | dpid = str(v['dpid']) |
| 227 | state = str(v['state']) |
| 228 | sw = {} |
| 229 | sw['name']=dpid |
Ubuntu | 5b2b24a | 2013-02-27 09:51:13 +0000 | [diff] [blame] | 230 | sw['group']= -1 |
Ubuntu | 37ebda6 | 2013-03-01 00:35:31 +0000 | [diff] [blame] | 231 | |
Masayoshi Kobayashi | 1407a50 | 2013-02-27 06:23:08 +0000 | [diff] [blame] | 232 | if state == "INACTIVE": |
Masayoshi Kobayashi | 1407a50 | 2013-02-27 06:23:08 +0000 | [diff] [blame] | 233 | sw['group']=0 |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 234 | switches.append(sw) |
Masayoshi Kobayashi | 1407a50 | 2013-02-27 06:23:08 +0000 | [diff] [blame] | 235 | |
Ubuntu | 37ebda6 | 2013-03-01 00:35:31 +0000 | [diff] [blame] | 236 | ## Comment in if we need devies |
| 237 | # sw_index = len(switches) - 1 |
| 238 | # for p in v['ports']: |
| 239 | # for d in p['devices']: |
| 240 | # device = {} |
| 241 | # device['attached_switch']=dpid |
| 242 | # device['name']=d['mac'] |
| 243 | # if d['state'] == "ACTIVE": |
| 244 | # device['group']=1000 |
| 245 | # else: |
| 246 | # device['group']=1001 |
| 247 | # |
| 248 | # switches.append(device) |
| 249 | # device_index = len (switches) -1 |
| 250 | # link = {} |
| 251 | # link['source'] = device_index |
| 252 | # link['target'] = sw_index |
| 253 | # link['type'] = -1 |
| 254 | # links.append(link) |
| 255 | # link = {} |
| 256 | # link['source'] = sw_index |
| 257 | # link['target'] = device_index |
| 258 | # link['type'] = -1 |
| 259 | # links.append(link) |
| 260 | |
Ubuntu | 5b2b24a | 2013-02-27 09:51:13 +0000 | [diff] [blame] | 261 | # try: |
| 262 | # command = "curl -s \'http://%s:%s/wm/registry/controllers/json\'" % (RestIP, RestPort) |
| 263 | # result = os.popen(command).read() |
| 264 | # controllers = json.loads(result) |
| 265 | # except: |
| 266 | # log_error("xx REST IF has issue: %s" % command) |
| 267 | # log_error("%s" % result) |
Masayoshi Kobayashi | 1407a50 | 2013-02-27 06:23:08 +0000 | [diff] [blame] | 268 | |
| 269 | try: |
| 270 | command = "curl -s \'http://%s:%s/wm/registry/switches/json\'" % (RestIP, RestPort) |
| 271 | result = os.popen(command).read() |
| 272 | parsedResult = json.loads(result) |
| 273 | except: |
| 274 | log_error("REST IF has issue: %s" % command) |
| 275 | log_error("%s" % result) |
| 276 | |
| 277 | for key in parsedResult: |
| 278 | dpid = key |
| 279 | ctrl = parsedResult[dpid][0]['controllerId'] |
| 280 | sw_id = node_id(switches, dpid) |
| 281 | if sw_id != -1: |
| 282 | if switches[sw_id]['group'] != 0: |
| 283 | switches[sw_id]['group'] = controllers.index(ctrl) + 1 |
| 284 | |
Masayoshi Kobayashi | 3bc5fde | 2013-02-28 01:02:54 +0000 | [diff] [blame] | 285 | try: |
| 286 | v1 = "00:00:00:00:00:0a:0d:00" |
Ubuntu | 765deff | 2013-02-28 18:39:13 +0000 | [diff] [blame] | 287 | # v1 = "00:00:00:00:00:0d:00:d1" |
Masayoshi Kobayashi | 3bc5fde | 2013-02-28 01:02:54 +0000 | [diff] [blame] | 288 | p1=1 |
| 289 | v2 = "00:00:00:00:00:0b:0d:03" |
Ubuntu | 765deff | 2013-02-28 18:39:13 +0000 | [diff] [blame] | 290 | # v2 = "00:00:00:00:00:0d:00:d3" |
| 291 | p2=1 |
Masayoshi Kobayashi | 3bc5fde | 2013-02-28 01:02:54 +0000 | [diff] [blame] | 292 | command = "curl -s http://%s:%s/wm/topology/route/%s/%s/%s/%s/json" % (RestIP, RestPort, v1, p1, v2, p2) |
| 293 | result = os.popen(command).read() |
| 294 | parsedResult = json.loads(result) |
| 295 | except: |
| 296 | log_error("No route") |
Ubuntu | 765deff | 2013-02-28 18:39:13 +0000 | [diff] [blame] | 297 | parsedResult = {} |
Ubuntu | 5b2b24a | 2013-02-27 09:51:13 +0000 | [diff] [blame] | 298 | |
Ubuntu | 765deff | 2013-02-28 18:39:13 +0000 | [diff] [blame] | 299 | path = [] |
| 300 | if parsedResult.has_key('flowEntries'): |
| 301 | flowEntries= parsedResult['flowEntries'] |
| 302 | for i, v in enumerate(flowEntries): |
| 303 | if i < len(flowEntries) - 1: |
| 304 | sdpid= flowEntries[i]['dpid']['value'] |
| 305 | ddpid = flowEntries[i+1]['dpid']['value'] |
Paul Greyson | 4e6dc3a | 2013-03-27 11:37:14 -0700 | [diff] [blame] | 306 | path.append( (sdpid, ddpid)) |
Ubuntu | 5b2b24a | 2013-02-27 09:51:13 +0000 | [diff] [blame] | 307 | |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 308 | try: |
| 309 | command = "curl -s \'http://%s:%s/wm/core/topology/links/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 | for v in parsedResult: |
| 318 | link = {} |
| 319 | if v.has_key('dst-switch'): |
| 320 | dst_dpid = str(v['dst-switch']) |
| 321 | dst_id = node_id(switches, dst_dpid) |
| 322 | if v.has_key('src-switch'): |
| 323 | src_dpid = str(v['src-switch']) |
| 324 | src_id = node_id(switches, src_dpid) |
| 325 | link['source'] = src_id |
| 326 | link['target'] = dst_id |
Masayoshi Kobayashi | 3bc5fde | 2013-02-28 01:02:54 +0000 | [diff] [blame] | 327 | |
| 328 | onpath = 0 |
| 329 | for (s,d) in path: |
| 330 | if s == v['src-switch'] and d == v['dst-switch']: |
| 331 | onpath = 1 |
| 332 | break |
| 333 | link['type'] = onpath |
| 334 | |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 335 | links.append(link) |
| 336 | |
| 337 | topo['nodes'] = switches |
| 338 | topo['links'] = links |
| 339 | |
Ubuntu | 37ebda6 | 2013-03-01 00:35:31 +0000 | [diff] [blame] | 340 | pp.pprint(topo) |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 341 | js = json.dumps(topo) |
| 342 | resp = Response(js, status=200, mimetype='application/json') |
| 343 | return resp |
| 344 | |
Ubuntu | aea2a68 | 2013-02-08 08:30:10 +0000 | [diff] [blame] | 345 | #@app.route("/wm/topology/toporoute/00:00:00:00:00:a1/2/00:00:00:00:00:c1/3/json") |
| 346 | #@app.route("/wm/topology/toporoute/<srcdpid>/<srcport>/<destdpid>/<destport>/json") |
| 347 | @app.route("/wm/topology/toporoute/<v1>/<p1>/<v2>/<p2>/json") |
| 348 | def shortest_path(v1, p1, v2, p2): |
| 349 | try: |
| 350 | command = "curl -s \'http://%s:%s/wm/core/topology/switches/all/json\'" % (RestIP, RestPort) |
| 351 | result = os.popen(command).read() |
| 352 | parsedResult = json.loads(result) |
| 353 | except: |
| 354 | log_error("REST IF has issue: %s" % command) |
| 355 | log_error("%s" % result) |
| 356 | sys.exit(0) |
| 357 | |
| 358 | topo = {} |
| 359 | switches = [] |
| 360 | links = [] |
| 361 | |
| 362 | for v in parsedResult: |
| 363 | if v.has_key('dpid'): |
| 364 | dpid = str(v['dpid']) |
| 365 | state = str(v['state']) |
| 366 | sw = {} |
| 367 | sw['name']=dpid |
| 368 | if str(v['state']) == "ACTIVE": |
| 369 | if dpid[-2:-1] == "a": |
| 370 | sw['group']=1 |
| 371 | if dpid[-2:-1] == "b": |
| 372 | sw['group']=2 |
| 373 | if dpid[-2:-1] == "c": |
| 374 | sw['group']=3 |
| 375 | if str(v['state']) == "INACTIVE": |
| 376 | sw['group']=0 |
| 377 | |
| 378 | switches.append(sw) |
| 379 | |
| 380 | try: |
| 381 | command = "curl -s http://%s:%s/wm/topology/route/%s/%s/%s/%s/json" % (RestIP, RestPort, v1, p1, v2, p2) |
| 382 | result = os.popen(command).read() |
| 383 | parsedResult = json.loads(result) |
| 384 | except: |
| 385 | log_error("No route") |
| 386 | parsedResult = [] |
| 387 | # exit(1) |
| 388 | |
Paul Greyson | 4e6dc3a | 2013-03-27 11:37:14 -0700 | [diff] [blame] | 389 | path = []; |
Ubuntu | aea2a68 | 2013-02-08 08:30:10 +0000 | [diff] [blame] | 390 | for i, v in enumerate(parsedResult): |
| 391 | if i < len(parsedResult) - 1: |
| 392 | sdpid= parsedResult[i]['switch'] |
| 393 | ddpid = parsedResult[i+1]['switch'] |
Paul Greyson | 4e6dc3a | 2013-03-27 11:37:14 -0700 | [diff] [blame] | 394 | path.append( (sdpid, ddpid)) |
Ubuntu | aea2a68 | 2013-02-08 08:30:10 +0000 | [diff] [blame] | 395 | |
| 396 | try: |
| 397 | command = "curl -s \'http://%s:%s/wm/core/topology/links/json\'" % (RestIP, RestPort) |
| 398 | result = os.popen(command).read() |
| 399 | parsedResult = json.loads(result) |
| 400 | except: |
| 401 | log_error("REST IF has issue: %s" % command) |
| 402 | log_error("%s" % result) |
| 403 | sys.exit(0) |
| 404 | |
| 405 | for v in parsedResult: |
| 406 | link = {} |
| 407 | if v.has_key('dst-switch'): |
| 408 | dst_dpid = str(v['dst-switch']) |
| 409 | dst_id = node_id(switches, dst_dpid) |
| 410 | if v.has_key('src-switch'): |
| 411 | src_dpid = str(v['src-switch']) |
| 412 | src_id = node_id(switches, src_dpid) |
| 413 | link['source'] = src_id |
| 414 | link['target'] = dst_id |
| 415 | onpath = 0 |
| 416 | for (s,d) in path: |
| 417 | if s == v['src-switch'] and d == v['dst-switch']: |
| 418 | onpath = 1 |
| 419 | break |
| 420 | |
| 421 | link['type'] = onpath |
| 422 | links.append(link) |
| 423 | |
| 424 | topo['nodes'] = switches |
| 425 | topo['links'] = links |
| 426 | |
Masayoshi Kobayashi | 1407a50 | 2013-02-27 06:23:08 +0000 | [diff] [blame] | 427 | # pp.pprint(topo) |
Ubuntu | aea2a68 | 2013-02-08 08:30:10 +0000 | [diff] [blame] | 428 | js = json.dumps(topo) |
| 429 | resp = Response(js, status=200, mimetype='application/json') |
| 430 | return resp |
| 431 | |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 432 | @app.route("/wm/core/controller/switches/json") |
| 433 | def query_switch(): |
| 434 | try: |
| 435 | command = "curl -s \'http://%s:%s/wm/core/topology/switches/all/json\'" % (RestIP, RestPort) |
| 436 | # http://localhost:8080/wm/core/topology/switches/active/json |
Masayoshi Kobayashi | f63ef2f | 2013-02-20 21:47:21 +0000 | [diff] [blame] | 437 | print command |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 438 | result = os.popen(command).read() |
| 439 | parsedResult = json.loads(result) |
| 440 | except: |
| 441 | log_error("REST IF has issue: %s" % command) |
| 442 | log_error("%s" % result) |
| 443 | sys.exit(0) |
| 444 | |
| 445 | # print command |
| 446 | # print result |
| 447 | switches_ = [] |
| 448 | for v in parsedResult: |
| 449 | if v.has_key('dpid'): |
| 450 | if v.has_key('dpid') and str(v['state']) == "ACTIVE":#;if you want only ACTIVE nodes |
| 451 | dpid = str(v['dpid']) |
| 452 | state = str(v['state']) |
| 453 | sw = {} |
| 454 | sw['dpid']=dpid |
| 455 | sw['active']=state |
| 456 | switches_.append(sw) |
| 457 | |
Masayoshi Kobayashi | 1407a50 | 2013-02-27 06:23:08 +0000 | [diff] [blame] | 458 | # pp.pprint(switches_) |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 459 | js = json.dumps(switches_) |
| 460 | resp = Response(js, status=200, mimetype='application/json') |
| 461 | return resp |
| 462 | |
| 463 | @app.route("/wm/device/") |
| 464 | def devices(): |
| 465 | try: |
| 466 | command = "curl -s http://%s:%s/graphs/%s/vertices\?key=type\&value=device" % (RestIP, RestPort, DBName) |
| 467 | result = os.popen(command).read() |
| 468 | parsedResult = json.loads(result)['results'] |
| 469 | except: |
| 470 | log_error("REST IF has issue: %s" % command) |
| 471 | log_error("%s" % result) |
| 472 | sys.exit(0) |
| 473 | |
| 474 | devices = [] |
| 475 | for v in parsedResult: |
| 476 | dl_addr = v['dl_addr'] |
| 477 | nw_addr = v['nw_addr'] |
| 478 | vertex = v['_id'] |
| 479 | mac = [] |
| 480 | mac.append(dl_addr) |
| 481 | ip = [] |
| 482 | ip.append(nw_addr) |
| 483 | device = {} |
| 484 | device['entryClass']="DefaultEntryClass" |
| 485 | device['mac']=mac |
| 486 | device['ipv4']=ip |
| 487 | device['vlan']=[] |
| 488 | device['lastSeen']=0 |
| 489 | attachpoints =[] |
| 490 | |
| 491 | port, dpid = deviceV_to_attachpoint(vertex) |
| 492 | attachpoint = {} |
| 493 | attachpoint['port']=port |
| 494 | attachpoint['switchDPID']=dpid |
| 495 | attachpoints.append(attachpoint) |
| 496 | device['attachmentPoint']=attachpoints |
| 497 | devices.append(device) |
| 498 | |
| 499 | print devices |
| 500 | js = json.dumps(devices) |
| 501 | resp = Response(js, status=200, mimetype='application/json') |
| 502 | return resp |
| 503 | |
| 504 | #{"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} |
| 505 | |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 506 | ## return fake stat for now |
| 507 | @app.route("/wm/core/switch/<switchId>/<statType>/json") |
| 508 | def switch_stat(switchId, statType): |
| 509 | if statType == "desc": |
| 510 | desc=[{"length":1056,"serialNumber":"None","manufacturerDescription":"Nicira Networks, Inc.","hardwareDescription":"Open vSwitch","softwareDescription":"1.4.0+build0","datapathDescription":"None"}] |
| 511 | ret = {} |
| 512 | ret[switchId]=desc |
| 513 | elif statType == "aggregate": |
| 514 | aggr = {"packetCount":0,"byteCount":0,"flowCount":0} |
| 515 | ret = {} |
| 516 | ret[switchId]=aggr |
| 517 | else: |
Paul Greyson | 4e6dc3a | 2013-03-27 11:37:14 -0700 | [diff] [blame] | 518 | ret = {} |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 519 | |
| 520 | js = json.dumps(ret) |
| 521 | resp = Response(js, status=200, mimetype='application/json') |
| 522 | return resp |
| 523 | |
| 524 | |
| 525 | @app.route("/wm/topology/links/json") |
| 526 | def query_links(): |
| 527 | try: |
| 528 | 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] | 529 | print command |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 530 | result = os.popen(command).read() |
| 531 | parsedResult = json.loads(result)['results'] |
| 532 | except: |
| 533 | log_error("REST IF has issue: %s" % command) |
| 534 | log_error("%s" % result) |
| 535 | sys.exit(0) |
| 536 | |
| 537 | debug("query_links %s" % command) |
Masayoshi Kobayashi | 1407a50 | 2013-02-27 06:23:08 +0000 | [diff] [blame] | 538 | # pp.pprint(parsedResult) |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 539 | sport = [] |
| 540 | links = [] |
| 541 | for v in parsedResult: |
| 542 | srcport = v['_id'] |
| 543 | try: |
| 544 | command = "curl -s http://%s:%s/graphs/%s/vertices/%d/out?_label=link" % (RestIP, RestPort, DBName, srcport) |
| 545 | print command |
| 546 | result = os.popen(command).read() |
| 547 | linkResults = json.loads(result)['results'] |
| 548 | except: |
| 549 | log_error("REST IF has issue: %s" % command) |
| 550 | log_error("%s" % result) |
| 551 | sys.exit(0) |
| 552 | |
| 553 | for p in linkResults: |
| 554 | if p.has_key('type') and p['type'] == "port": |
| 555 | dstport = p['_id'] |
| 556 | (sport, sdpid) = portV_to_port_dpid(srcport) |
| 557 | (dport, ddpid) = portV_to_port_dpid(dstport) |
| 558 | link = {} |
| 559 | link["src-switch"]=sdpid |
| 560 | link["src-port"]=sport |
| 561 | link["src-port-state"]=0 |
| 562 | link["dst-switch"]=ddpid |
| 563 | link["dst-port"]=dport |
| 564 | link["dst-port-state"]=0 |
| 565 | link["type"]="internal" |
| 566 | links.append(link) |
| 567 | |
Masayoshi Kobayashi | 1407a50 | 2013-02-27 06:23:08 +0000 | [diff] [blame] | 568 | # pp.pprint(links) |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 569 | js = json.dumps(links) |
| 570 | resp = Response(js, status=200, mimetype='application/json') |
| 571 | return resp |
| 572 | |
Paul Greyson | 4e6dc3a | 2013-03-27 11:37:14 -0700 | [diff] [blame] | 573 | topo_less = { |
| 574 | "nodes" : [ |
Masayoshi Kobayashi | 1407a50 | 2013-02-27 06:23:08 +0000 | [diff] [blame] | 575 | {"name" : "00:a0", "group" : 1}, |
| 576 | {"name" : "00:a1", "group" : 1}, |
| 577 | {"name" : "00:a2", "group" : 1}, |
| 578 | ], |
| 579 | "links" : [ |
| 580 | {"source" :0, "target": 1}, |
| 581 | {"source" :1, "target": 0}, |
| 582 | {"source" :0, "target": 2}, |
| 583 | {"source" :2, "target": 0}, |
| 584 | {"source" :1, "target": 2}, |
| 585 | {"source" :2, "target": 1}, |
| 586 | ] |
| 587 | } |
| 588 | |
Paul Greyson | 4e6dc3a | 2013-03-27 11:37:14 -0700 | [diff] [blame] | 589 | topo_more = { |
| 590 | "nodes" : [ |
Masayoshi Kobayashi | 1407a50 | 2013-02-27 06:23:08 +0000 | [diff] [blame] | 591 | {"name" : "00:a3", "group" : 2}, |
| 592 | {"name" : "00:a0", "group" : 1}, |
| 593 | {"name" : "00:a1", "group" : 1}, |
| 594 | {"name" : "00:a2", "group" : 1}, |
| 595 | ], |
| 596 | "links" : [ |
| 597 | {"source" :1, "target": 2}, |
| 598 | {"source" :2, "target": 1}, |
| 599 | {"source" :1, "target": 3}, |
| 600 | {"source" :3, "target": 1}, |
| 601 | {"source" :2, "target": 3}, |
| 602 | {"source" :3, "target": 2}, |
| 603 | {"source" :0, "target": 2}, |
| 604 | ] |
| 605 | } |
| 606 | |
| 607 | @app.route("/topology_more") |
| 608 | def topology_more(): |
| 609 | topo = topo_more |
| 610 | js = json.dumps(topo) |
| 611 | resp = Response(js, status=200, mimetype='application/json') |
| 612 | return resp |
| 613 | |
| 614 | @app.route("/topology_less") |
| 615 | def topology_less(): |
| 616 | topo = topo_less |
| 617 | js = json.dumps(topo) |
| 618 | resp = Response(js, status=200, mimetype='application/json') |
| 619 | return resp |
| 620 | |
| 621 | cont_status1 = [ |
| 622 | {"name":"onos9vpc", "onos": 1, "cassandra": 1}, |
| 623 | {"name":"onos10vpc", "onos": 0, "cassandra": 1}, |
| 624 | {"name":"onos11vpc", "onos": 1, "cassandra": 0}, |
| 625 | {"name":"onos12vpc", "onos": 1, "cassandra": 0}] |
| 626 | |
| 627 | cont_status2 = [ |
| 628 | {"name":"onos9vpc", "onos": 0, "cassandra": 1}, |
| 629 | {"name":"onos10vpc", "onos": 0, "cassandra": 1}, |
| 630 | {"name":"onos11vpc", "onos": 0, "cassandra": 1}, |
| 631 | {"name":"onos12vpc", "onos": 0, "cassandra": 1}] |
| 632 | |
| 633 | @app.route("/controller_status1") |
| 634 | def controller_status1(): |
| 635 | status = cont_status1 |
| 636 | js = json.dumps(status) |
| 637 | resp = Response(js, status=200, mimetype='application/json') |
| 638 | pp.pprint(resp) |
| 639 | return resp |
| 640 | |
| 641 | @app.route("/controller_status2") |
| 642 | def controller_status2(): |
| 643 | status = cont_status2 |
| 644 | js = json.dumps(status) |
| 645 | resp = Response(js, status=200, mimetype='application/json') |
| 646 | pp.pprint(resp) |
| 647 | return resp |
| 648 | |
Ubuntu | c016ba1 | 2013-02-27 21:53:41 +0000 | [diff] [blame] | 649 | @app.route("/controller_status") |
| 650 | def controller_status(): |
| 651 | onos_check="ssh -i ~/.ssh/onlabkey.pem %s ONOS/start-onos.sh status | awk '{print $1}'" |
| 652 | #cassandra_check="ssh -i ~/.ssh/onlabkey.pem %s ONOS/start-cassandra.sh status" |
| 653 | |
| 654 | cont_status=[] |
| 655 | for i in controllers: |
| 656 | status={} |
| 657 | onos=os.popen(onos_check % i).read()[:-1] |
| 658 | status["name"]=i |
| 659 | status["onos"]=onos |
Masayoshi Kobayashi | 5e91bdf | 2013-03-15 01:22:51 +0000 | [diff] [blame] | 660 | status["cassandra"]=0 |
Ubuntu | c016ba1 | 2013-02-27 21:53:41 +0000 | [diff] [blame] | 661 | cont_status.append(status) |
| 662 | |
| 663 | js = json.dumps(cont_status) |
| 664 | resp = Response(js, status=200, mimetype='application/json') |
| 665 | pp.pprint(js) |
| 666 | return resp |
| 667 | |
Masayoshi Kobayashi | 5101152 | 2013-03-27 00:18:12 +0000 | [diff] [blame] | 668 | @app.route("/gui/controller/<cmd>/<controller_name>") |
| 669 | def controller_status_change(cmd, controller_name): |
| 670 | start_onos="ssh -i ~/.ssh/onlabkey.pem %s ONOS/start-onos.sh start" % (controller_name) |
| 671 | stop_onos="ssh -i ~/.ssh/onlabkey.pem %s ONOS/start-onos.sh stop" % (controller_name) |
| 672 | |
| 673 | if cmd == "up": |
Masayoshi Kobayashi | 1e07238 | 2013-03-27 05:17:09 +0000 | [diff] [blame] | 674 | result=os.popen(start_onos).read() |
Masayoshi Kobayashi | 5101152 | 2013-03-27 00:18:12 +0000 | [diff] [blame] | 675 | ret = "controller %s is up" % (controller_name) |
| 676 | elif cmd == "down": |
Masayoshi Kobayashi | 1e07238 | 2013-03-27 05:17:09 +0000 | [diff] [blame] | 677 | result=os.popen(stop_onos).read() |
Masayoshi Kobayashi | 5101152 | 2013-03-27 00:18:12 +0000 | [diff] [blame] | 678 | ret = "controller %s is down" % (controller_name) |
| 679 | |
| 680 | return ret |
| 681 | |
| 682 | @app.route("/gui/switch/<cmd>/<dpid>") |
| 683 | def switch_status_change(cmd, dpid): |
| 684 | r = re.compile(':') |
| 685 | dpid = re.sub(r, '', dpid) |
| 686 | cmd_string="ssh -i ~/.ssh/onlabkey.pem onosgui1 'cd ONOS/scripts; ./switch.sh %s %s'" % (dpid, cmd) |
| 687 | get_status="ssh -i ~/.ssh/onlabkey.pem onosgui1 'cd ONOS/scripts; ./switch.sh %s'" % (dpid) |
| 688 | print "cmd_string" |
| 689 | |
| 690 | if cmd =="up" or cmd=="down": |
| 691 | print "make dpid %s %s" % (dpid, cmd) |
Masayoshi Kobayashi | 1e07238 | 2013-03-27 05:17:09 +0000 | [diff] [blame] | 692 | os.popen(cmd_string) |
| 693 | result=os.popen(get_status).read() |
Masayoshi Kobayashi | 5101152 | 2013-03-27 00:18:12 +0000 | [diff] [blame] | 694 | |
Masayoshi Kobayashi | 1e07238 | 2013-03-27 05:17:09 +0000 | [diff] [blame] | 695 | return result |
Masayoshi Kobayashi | 5101152 | 2013-03-27 00:18:12 +0000 | [diff] [blame] | 696 | |
Masayoshi Kobayashi | 5101152 | 2013-03-27 00:18:12 +0000 | [diff] [blame] | 697 | #* Link Up/Down |
| 698 | #http://localhost:9000/gui/link/up/<src_dpid>/<src_port>/<dst_dpid>/<dst_port> |
| 699 | #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] | 700 | |
| 701 | @app.route("/gui/link/<cmd>/<src_dpid>/<src_port>/<dst_dpid>/<dst_port>") |
| 702 | def link_change(cmd, src_dpid, src_port, dst_dpid, dst_port): |
| 703 | if src_dpid in core_switches: |
| 704 | host = controllers[0] |
| 705 | else: |
| 706 | hostid=int(src_dpid.split(':')[-2]) |
| 707 | host = controllers[hostid-1] |
| 708 | |
| 709 | cmd_string="ssh -i ~/.ssh/onlabkey.pem %s 'cd ONOS/scripts; ./link.sh %s %s %s'" % (host, src_dpid, src_port, cmd) |
| 710 | print cmd_string |
| 711 | |
| 712 | if cmd =="up" or cmd=="down": |
| 713 | result=os.popen(cmd_string).read() |
| 714 | |
| 715 | return result |
| 716 | |
Masayoshi Kobayashi | 5101152 | 2013-03-27 00:18:12 +0000 | [diff] [blame] | 717 | #* Create Flow |
| 718 | #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] | 719 | #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 |
| 720 | @app.route("/gui/addfow/<src_dpid>/<src_port>/<dst_dpid>/<dst_port>/<srcMAC>/<dstMAC>") |
| 721 | def add_flow(src_dpid, src_port, dst_dpid, dst_port, srcMAC, dstMAC): |
| 722 | command = "/home/ubuntu/ONOS/web/get_flow.py all |grep FlowPath |gawk '{print strtonum($4)}'| sort -n | tail -n 1" |
| 723 | print command |
| 724 | ret = os.popen(command).read() |
| 725 | if ret == "": |
| 726 | flow_nr=0 |
| 727 | else: |
| 728 | flow_nr=int(ret) |
| 729 | |
| 730 | flow_nr += 1 |
| 731 | command = "/home/ubuntu/ONOS/web/add_flow.py %d %s %s %s %s %s matchSrcMac %s matchDstMac %s" % (flow_nr, "dummy", src_dpid, src_port, dst_dpid, dst_port, srcMAC, dstMAC) |
| 732 | print command |
| 733 | errcode = os.popen(command).read() |
| 734 | return errcode |
| 735 | |
Masayoshi Kobayashi | 5101152 | 2013-03-27 00:18:12 +0000 | [diff] [blame] | 736 | #* Delete Flow |
| 737 | #http://localhost:9000/gui/delflow/<flow_id> |
Masayoshi Kobayashi | 1e07238 | 2013-03-27 05:17:09 +0000 | [diff] [blame] | 738 | @app.route("/gui/delflow/<flow_id>") |
| 739 | def del_flow(flow_id): |
| 740 | command = "/home/ubuntu/ONOS/web/delete_flow.py %s" % (flow_id) |
| 741 | print command |
| 742 | errcode = os.popen(command).read() |
| 743 | return errcode |
| 744 | |
Masayoshi Kobayashi | 5101152 | 2013-03-27 00:18:12 +0000 | [diff] [blame] | 745 | #* Start Iperf Througput |
| 746 | #http://localhost:9000/gui/iperf/start/<flow_id> |
Masayoshi Kobayashi | 1e07238 | 2013-03-27 05:17:09 +0000 | [diff] [blame] | 747 | @app.route("/gui/iperf/start/<flow_id>") |
| 748 | def iperf_start(flow_id): |
| 749 | command = "iperf -xCMSV -t30 -i1 -u -c 127.0.0.1 > iperf_%s.out &" % (flow_id) |
| 750 | print command |
| 751 | errcode = os.popen(command).read() |
| 752 | return errcode |
| 753 | |
| 754 | |
Masayoshi Kobayashi | 5101152 | 2013-03-27 00:18:12 +0000 | [diff] [blame] | 755 | #* Get Iperf Throughput |
| 756 | #http://localhost:9000/gui/iperf/rate/<flow_id> |
Masayoshi Kobayashi | 1e07238 | 2013-03-27 05:17:09 +0000 | [diff] [blame] | 757 | @app.route("/gui/iperf/rate/<flow_id>") |
| 758 | def iperf_rate(flow_id): |
| 759 | try: |
| 760 | command = "curl -s http://%s:%s/iperf_%s.out" % (RestIP, 9000, flow_id) |
| 761 | print command |
| 762 | result = os.popen(command).read() |
| 763 | except: |
| 764 | print "REST IF has issue" |
| 765 | exit |
Masayoshi Kobayashi | 5101152 | 2013-03-27 00:18:12 +0000 | [diff] [blame] | 766 | |
Masayoshi Kobayashi | 1e07238 | 2013-03-27 05:17:09 +0000 | [diff] [blame] | 767 | resp = Response(result, status=200, mimetype='text/html') |
| 768 | return resp |
Masayoshi Kobayashi | 5101152 | 2013-03-27 00:18:12 +0000 | [diff] [blame] | 769 | |
| 770 | |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 771 | if __name__ == "__main__": |
| 772 | if len(sys.argv) > 1 and sys.argv[1] == "-d": |
Masayoshi Kobayashi | 1e07238 | 2013-03-27 05:17:09 +0000 | [diff] [blame] | 773 | # 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") |
| 774 | # link_change("up", "00:00:00:00:ba:5e:ba:11", 1, "00:00:00:00:00:00:00:00", 1) |
| 775 | # link_change("down", "00:00:20:4e:7f:51:8a:35", 1, "00:00:00:00:00:00:00:00", 1) |
| 776 | # link_change("up", "00:00:00:00:00:00:02:03", 1, "00:00:00:00:00:00:00:00", 1) |
| 777 | # link_change("down", "00:00:00:00:00:00:07:12", 1, "00:00:00:00:00:00:00:00", 1) |
| 778 | |
| 779 | |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 780 | print "-- query all switches --" |
| 781 | query_switch() |
| 782 | print "-- query topo --" |
| 783 | topology_for_gui() |
Masayoshi Kobayashi | 1e07238 | 2013-03-27 05:17:09 +0000 | [diff] [blame] | 784 | # link_change(1,2,3,4) |
| 785 | print "-- query all links --" |
| 786 | query_links() |
Ubuntu | 82b8a83 | 2013-02-06 22:00:11 +0000 | [diff] [blame] | 787 | # print "-- query all devices --" |
| 788 | # devices() |
| 789 | else: |
| 790 | app.debug = True |
Masayoshi Kobayashi | f63ef2f | 2013-02-20 21:47:21 +0000 | [diff] [blame] | 791 | app.run(threaded=True, host="0.0.0.0", port=9000) |