blob: be834b9bf29990b3ee69d9229086155e6ba9e6c9 [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) != 5:
10 print "usage: verify-topo-links onos-node cluster-id first-index last-index"
11 sys.exit(1)
12
13node = sys.argv[1]
14cluster = sys.argv[2]
15first = int(sys.argv[3])
16last = int(sys.argv[4])
17
18found = 0
19
20topoRequest = requests.get('http://' + node + ':8181/onos/v1/topology/clusters/'
21 + cluster
22 + "/devices",
23 auth=HTTPBasicAuth('onos', 'rocks'))
24
25if topoRequest.status_code != 200:
26 print topoRequest.text
27 sys.exit(1)
28
29topoJson = topoRequest.json()
30
31for deviceIndex in range(first, last+1):
32 lookingFor = "of:" + format(deviceIndex, '016x')
33 print lookingFor
34 for arrayIndex in range(0, len(topoJson["devices"])):
35 device = topoJson["devices"][arrayIndex]
36 if device == lookingFor:
37 found = found + 1
38 print "Match found for " + device
39 break
40
41
42if found == last - first:
43 sys.exit(0)
44
45print "Found " + str(found) + " matches, need " + str(last - first)
46sys.exit(2)
47
48
49
50
51