blob: d99070e90fc01a120435d16ec9a221ad9a06e8f0 [file] [log] [blame]
Pavlin Radoslavovcdda1f72013-05-07 23:19:38 +00001#! /usr/bin/env python
2# -*- Mode: python; py-indent-offset: 4; tab-width: 8; indent-tabs-mode: t; -*-
3
4import pprint
5import os
6import sys
7import subprocess
8import json
9import argparse
10import io
11import time
12
13from flask import Flask, json, Response, render_template, make_response, request
14
15#
16# TODO: remove this! We don't use JSON argument here!
17# curl http://127.0.0.1:8080/wm/flow/delete/{"value":"0xf"}/json'
18#
19
20## Global Var ##
21ControllerIP="127.0.0.1"
22ControllerPort=8080
23
24DEBUG=0
25pp = pprint.PrettyPrinter(indent=4)
26
27app = Flask(__name__)
28
29## Worker Functions ##
30def log_error(txt):
31 print '%s' % (txt)
32
33def debug(txt):
34 if DEBUG:
35 print '%s' % (txt)
36
37# @app.route("/wm/flow/measurement-install-paths/<num-threads>/json")
38def measurement_install_paths(num_threads):
39 command = "curl -s \"http://%s:%s/wm/flow/measurement-install-paths/%s/json\"" % (ControllerIP, ControllerPort, num_threads)
40 debug("measurement_install_paths %s" % command)
41 result = os.popen(command).read()
42 debug("result %s" % result)
43 # parsedResult = json.loads(result)
44 # debug("parsed %s" % parsedResult)
45
46if __name__ == "__main__":
47 usage_msg = "Install flow paths and start measurements\n"
48 usage_msg = usage_msg + "Usage: %s <num-threads>\n" % (sys.argv[0])
49 usage_msg = usage_msg + "\n"
50 usage_msg = usage_msg + " Arguments:\n"
51 usage_msg = usage_msg + " <num-threads> Number of threads to use to install the flows\n"
52
53 # app.debug = False;
54
55 # Usage info
56 if len(sys.argv) > 1 and (sys.argv[1] == "-h" or sys.argv[1] == "--help"):
57 print(usage_msg)
58 exit(0)
59
60 # Check arguments
61 if len(sys.argv) < 2:
62 log_error(usage_msg)
63 exit(1)
64 num_threads = int(sys.argv[1], 0)
65
66 # Do the work
67 measurement_install_paths(num_threads)