check-dhcp-netcfg.py
852 Bytes
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
36
37
38
39
40
41
42
43
44
45
#! /usr/bin/env python
import requests
import sys
from requests.auth import HTTPBasicAuth
if len(sys.argv) < 3:
print "usage: find-dhcp-netcfg onos-node name1=value1 ..."
sys.exit(1)
node = sys.argv[1]
cfgRequest = requests.get('http://' + node +
':8181/onos/v1/network/configuration/apps/org.onosproject.dhcp',
auth=HTTPBasicAuth('onos', 'rocks'))
print cfgRequest.text
if cfgRequest.status_code != 200:
sys.exit(1)
cfgJson = cfgRequest.json()
for index in range(2, len(sys.argv)):
pair = sys.argv[index].split("=")
dhcp = cfgJson["dhcp"]
appFound = True
name = pair[0]
value = pair[1]
if dhcp[name] != value:
print name + " differs: expected " + value + " but found " + dhcp[name]
print cfgJson
sys.exit(1)
sys.exit(0)