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) != 3: |
| 10 | print "usage: query-topo onos-node name" |
| 11 | sys.exit(1) |
| 12 | |
| 13 | node = sys.argv[1] |
| 14 | name = sys.argv[2] |
| 15 | |
| 16 | topoRequest = requests.get('http://' + node + ':8181/onos/v1/topology/', |
| 17 | auth=HTTPBasicAuth('onos', 'rocks')) |
| 18 | |
| 19 | if topoRequest.status_code != 200: |
| 20 | print topoRequest.text |
| 21 | sys.exit(1) |
| 22 | |
| 23 | topoJson = topoRequest.json() |
| 24 | |
| 25 | print "@stc " + name + "Time=" + str(topoJson["time"]) |
| 26 | print "@stc " + name + "Devices=" + str(topoJson["devices"]) |
| 27 | print "@stc " + name + "Links=" + str(topoJson["links"]) |
| 28 | print "@stc " + name + "Clusters=" + str(topoJson["clusters"]) |
| 29 | |
| 30 | sys.exit(0) |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |