aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/tools/test/scenarios/bin/query-topo.py
blob: 9b81b4ee231e2612a29aded7fabc9cea302e5cd3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#! /usr/bin/env python

import requests
import sys
import urllib

from requests.auth import HTTPBasicAuth

if len(sys.argv) != 3:
    print "usage: query-topo onos-node name"
    sys.exit(1)

node = sys.argv[1]
name = sys.argv[2]

topoRequest = requests.get('http://' + node + ':8181/onos/v1/topology/',
                           auth=HTTPBasicAuth('onos', 'rocks'))

if topoRequest.status_code != 200:
    print topoRequest.text
    sys.exit(1)

topoJson = topoRequest.json()

print "@stc " + name + "Time=" + str(topoJson["time"])
print "@stc " + name + "Devices=" + str(topoJson["devices"])
print "@stc " + name + "Links=" + str(topoJson["links"])
print "@stc " + name + "Clusters=" + str(topoJson["clusters"])

sys.exit(0)