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