blob: 9b81b4ee231e2612a29aded7fabc9cea302e5cd3 [file] [log] [blame]
Ray Milkeye0827772015-09-11 16:49:21 -07001#! /usr/bin/env python
2
3import requests
4import sys
5import urllib
6
7from requests.auth import HTTPBasicAuth
8
9if len(sys.argv) != 3:
10 print "usage: query-topo onos-node name"
11 sys.exit(1)
12
13node = sys.argv[1]
14name = sys.argv[2]
15
16topoRequest = requests.get('http://' + node + ':8181/onos/v1/topology/',
17 auth=HTTPBasicAuth('onos', 'rocks'))
18
19if topoRequest.status_code != 200:
20 print topoRequest.text
21 sys.exit(1)
22
23topoJson = topoRequest.json()
24
25print "@stc " + name + "Time=" + str(topoJson["time"])
26print "@stc " + name + "Devices=" + str(topoJson["devices"])
27print "@stc " + name + "Links=" + str(topoJson["links"])
28print "@stc " + name + "Clusters=" + str(topoJson["clusters"])
29
30sys.exit(0)
31
32
33
34
35