blob: ed5622e56a8a0aba077f5b1e99d7d5ca04dbf58d [file] [log] [blame]
Ray Milkeya0f983b2016-06-23 19:39:55 -07001#! /usr/bin/env python
2
3import requests
4import sys
5
6from requests.auth import HTTPBasicAuth
7
8if len(sys.argv) < 3:
9 print "usage: find-dhcp-netcfg onos-node name1=value1 ..."
10 sys.exit(1)
11
12node = sys.argv[1]
13
14cfgRequest = requests.get('http://' + node + ':8181/onos/v1/network/configuration',
15 auth=HTTPBasicAuth('onos', 'rocks'))
16
17if cfgRequest.status_code != 200:
18 print cfgRequest.text
19 sys.exit(1)
20
21cfgJson = cfgRequest.json()
22appFound = False
23
24
25for index in range(2, len(sys.argv)):
26 pair = sys.argv[index].split("=")
27 for app in cfgJson["apps"]:
28 if app == "org.onosproject.dhcp":
29 dhcp = cfgJson["apps"][app]["dhcp"]
30 appFound = True
31
32 name = pair[0]
33 value = pair[1]
34
35 if dhcp[name] != value:
36 print name + " differs: expected " + value + " but found " + dhcp[name]
37 print cfgJson
38 sys.exit(1)
39
40if appFound:
41 sys.exit(0)
42
43print "DHCP app not found"
44print cfgJson
45sys.exit(2)
46
47
48
49