opticalUtil:
Authenticate against REST API. Caveat: assume sane default user/pw.
Change-Id: Id4197ce648dbc8de9b56f180beefcbf9b7d6c529
diff --git a/tools/test/topos/opticalUtils.py b/tools/test/topos/opticalUtils.py
index ef0b9a0..bef9dec 100644
--- a/tools/test/topos/opticalUtils.py
+++ b/tools/test/topos/opticalUtils.py
@@ -70,6 +70,9 @@
SLEEP_TIME = 2
TIMEOUT = 60
+REST_USER = 'onos'
+REST_PW = 'rocks'
+
class OpticalSwitch(Switch):
"""
For now, same as Switch class.
@@ -428,6 +431,13 @@
info('*** Waiting for all devices to be available in ONOS...\n')
url = 'http://%s:8181/onos/v1/devices' % LINCSwitch.controllers[0].ip
time = 0
+ # Set up password authentication
+ pw_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
+ pw_mgr.add_password(None, url, REST_USER, REST_PW)
+ handler = urllib2.HTTPBasicAuthHandler(pw_mgr)
+ opener = urllib2.build_opener(handler)
+ opener.open(url)
+ urllib2.install_opener(opener)
while True:
response = json.load(urllib2.urlopen(url))
devs = response.get('devices')