Add support for configuring OLT access device data with uplink/vlan information.
This is required when running on target OLT switches where we have to configure
the uplink/vlan information with the device ids for ONOS to program IGMP flows correctly.
Add methods for getting devices and flows from ONOS rest interface.
Change relevant OnosCtrl methods to class methods that are applicable for global onos configurations.
diff --git a/src/test/utils/OnosCtrl.py b/src/test/utils/OnosCtrl.py
index 043438f..bad2016 100644
--- a/src/test/utils/OnosCtrl.py
+++ b/src/test/utils/OnosCtrl.py
@@ -3,21 +3,24 @@
 import os,sys,time
 
 class OnosCtrl:
-    
+
+    auth = ('karaf', 'karaf')
+    controller = os.getenv('ONOS_CONTROLLER_IP') or 'localhost'
+    cfg_url = 'http://%s:8181/onos/v1/network/configuration/' %(controller)
+
     def __init__(self, app, controller = None):
         self.app = app
-        if controller is None:
-            self.controller = os.getenv('ONOS_CONTROLLER_IP') or 'localhost'
-        else:
+        if controller is not None:
             self.controller = controller
         self.app_url = 'http://%s:8181/onos/v1/applications/%s' %(self.controller, self.app)
         self.cfg_url = 'http://%s:8181/onos/v1/network/configuration/' %(self.controller)
         self.auth = ('karaf', 'karaf')
 
-    def config(self, config):
+    @classmethod
+    def config(cls, config):
         if config:
             json_data = json.dumps(config)
-            resp = requests.post(self.cfg_url, auth = self.auth, data = json_data)
+            resp = requests.post(cls.cfg_url, auth = cls.auth, data = json_data)
             return resp.ok, resp.status_code
         return False, 400
 
@@ -29,4 +32,39 @@
         resp = requests.delete(self.app_url + '/active', auth = self.auth)
         return resp.ok, resp.status_code
 
+    @classmethod
+    def get_devices(cls):
+        url = 'http://%s:8181/onos/v1/devices' %(cls.controller)
+        result = requests.get(url, auth = cls.auth)
+        if result.ok:
+            devices = result.json()['devices']
+            return filter(lambda d: d['available'], devices)
 
+        return None
+
+    @classmethod
+    def get_flows(cls, device_id):
+        url = 'http://%s:8181/onos/v1/flows/' %(cls.controller) + device_id
+        result = requests.get(url, auth = cls.auth)
+        if result.ok:
+            return result.json()['flows']
+        return None
+
+    @classmethod
+    def cord_olt_config(cls, olt_device_data = None):
+        '''Configures OLT data for existing devices/switches'''
+        if olt_device_data is None:
+            return
+        did_dict = {}
+        config = { 'devices' : did_dict }
+        devices = cls.get_devices()
+        if not devices:
+            return
+        device_ids = map(lambda d: d['id'], devices)
+        for did in device_ids:
+            access_device_dict = {}
+            access_device_dict['accessDevice'] = olt_device_data
+            did_dict[did] = access_device_dict
+
+        ##configure the device list with access information
+        return cls.config(config)