blob: c828c8476a6e4ae69dc8b52be6dcb1a872449902 [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
Ray Milkeye685d7d2016-08-04 17:00:14 -070014cfgRequest = requests.get('http://' + node +
15 ':8181/onos/v1/network/configuration/apps/org.onosproject.dhcp',
Ray Milkeya0f983b2016-06-23 19:39:55 -070016 auth=HTTPBasicAuth('onos', 'rocks'))
17
Ray Milkeye685d7d2016-08-04 17:00:14 -070018print cfgRequest.text
19
Ray Milkeya0f983b2016-06-23 19:39:55 -070020if cfgRequest.status_code != 200:
Ray Milkeya0f983b2016-06-23 19:39:55 -070021 sys.exit(1)
22
23cfgJson = cfgRequest.json()
Ray Milkeya0f983b2016-06-23 19:39:55 -070024
25for index in range(2, len(sys.argv)):
26 pair = sys.argv[index].split("=")
Ray Milkeya0f983b2016-06-23 19:39:55 -070027
Ray Milkeye685d7d2016-08-04 17:00:14 -070028 dhcp = cfgJson["dhcp"]
29 appFound = True
Ray Milkeya0f983b2016-06-23 19:39:55 -070030
Ray Milkeye685d7d2016-08-04 17:00:14 -070031 name = pair[0]
32 value = pair[1]
Ray Milkeya0f983b2016-06-23 19:39:55 -070033
Ray Milkeye685d7d2016-08-04 17:00:14 -070034 if dhcp[name] != value:
35 print name + " differs: expected " + value + " but found " + dhcp[name]
36 print cfgJson
37 sys.exit(1)
Ray Milkeya0f983b2016-06-23 19:39:55 -070038
Ray Milkeye685d7d2016-08-04 17:00:14 -070039
40sys.exit(0)
41
Ray Milkeya0f983b2016-06-23 19:39:55 -070042
43
44
45