Ray Milkey | e082777 | 2015-09-11 16:49:21 -0700 | [diff] [blame] | 1 | #! /usr/bin/env python |
| 2 | |
| 3 | import requests |
| 4 | import sys |
| 5 | import urllib |
| 6 | |
| 7 | from requests.auth import HTTPBasicAuth |
| 8 | |
| 9 | if len(sys.argv) != 4: |
| 10 | print "usage: query-cluster onos-node name cluster-number" |
| 11 | sys.exit(1) |
| 12 | |
| 13 | node = sys.argv[1] |
| 14 | name = sys.argv[2] |
| 15 | cluster = sys.argv[3] |
| 16 | |
| 17 | topoRequest = requests.get('http://' + node + ':8181/onos/v1/topology/clusters/' |
| 18 | + cluster, |
| 19 | auth=HTTPBasicAuth('onos', 'rocks')) |
| 20 | |
| 21 | if topoRequest.status_code != 200: |
| 22 | print topoRequest.text |
| 23 | sys.exit(1) |
| 24 | |
| 25 | topoJson = topoRequest.json() |
| 26 | |
| 27 | print "@stc " + name + "Id=" + str(topoJson["id"]) |
| 28 | print "@stc " + name + "DeviceCount=" + str(topoJson["deviceCount"]) |
| 29 | print "@stc " + name + "LinkCount=" + str(topoJson["linkCount"]) |
| 30 | print "@stc " + name + "Root=" + topoJson["root"] |
| 31 | |
| 32 | sys.exit(0) |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |