blob: f6f3d390ba1a05c22faaa94836b2b276f438d8c7 [file] [log] [blame]
Pavlin Radoslavovf4ad9892013-03-04 14:15:19 -08001#! /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/delete/<flow-id>/json")
38def delete_flow_path(flow_id):
39 command = "curl -s \"http://%s:%s/wm/flow/delete/%s/json\"" % (ControllerIP, ControllerPort, flow_id)
40 debug("delete_flow_path %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 = "Usage: %s <flow_id>" % (sys.argv[0])
48
49 # app.debug = False;
50
51 # Usage info
52 if len(sys.argv) > 1 and (sys.argv[1] == "-h" or sys.argv[1] == "--help"):
53 print(usage_msg)
54 exit(0)
55
56 # Check arguments
57 if len(sys.argv) < 2:
58 log_error(usage_msg)
59 exit(1)
60
61 # Do the work
62 delete_flow_path(sys.argv[1]);