Jonathan Hart | 0210289 | 2013-04-10 12:55:50 -0700 | [diff] [blame] | 1 | #! /usr/bin/env python |
| 2 | |
| 3 | import os |
| 4 | import json |
| 5 | |
| 6 | CONFIG_FILE=os.getenv("HOME") + "/ONOS/web/config.json" |
| 7 | |
| 8 | def read_config(): |
| 9 | global LB, TESTBED, controllers, core_switches, ONOS_GUI3_HOST, ONOS_GUI3_CONTROL_HOST |
| 10 | f = open(CONFIG_FILE) |
| 11 | conf = json.load(f) |
| 12 | LB = conf['LB'] |
| 13 | TESTBED = conf['TESTBED'] |
| 14 | controllers = conf['controllers'] |
| 15 | core_switches=conf['core_switches'] |
| 16 | ONOS_GUI3_HOST=conf['ONOS_GUI3_HOST'] |
| 17 | ONOS_GUI3_CONTROL_HOST=conf['ONOS_GUI3_CONTROL_HOST'] |
| 18 | f.close() |
| 19 | |
| 20 | if __name__ == "__main__": |
| 21 | onos_rest_port = 8080 |
| 22 | read_config() |
| 23 | |
| 24 | try: |
| 25 | sw_list = json.dumps(core_switches) |
| 26 | command = "curl -s -H 'Content-Type: application/json' -d '%s' http://%s:%s/wm/core/clearflowtable/json" % (sw_list, controllers[0], onos_rest_port) |
| 27 | |
| 28 | print command |
| 29 | result = os.popen(command).read() |
| 30 | print result |
| 31 | except: |
| 32 | print "REST IF has issue" |
| 33 | exit |