Changes to CHO test for parsing onoscell option

Change-Id: I6521fea90b1d66b1b2a9a3a7b86f107c47d845e7

updated verifyOnosCell option and deleted getOnosIPfromCell

Change-Id: Ie8eccbf88c7b3f3a258efa0c5b33a6648e017684
diff --git a/TestON/core/teston.py b/TestON/core/teston.py
index e4dbf9d..3b89282 100644
--- a/TestON/core/teston.py
+++ b/TestON/core/teston.py
@@ -35,6 +35,7 @@
 import threading
 module = new.module("test")
 import openspeak
+import subprocess
 global path, drivers_path, core_path, tests_path,logs_path
 path = re.sub("(core|bin)$", "", os.getcwd())
 drivers_path = path+"drivers/"
@@ -167,6 +168,9 @@
         driverClass = getattr(driverModule, driverName)
         driverObject = driverClass()
 
+        if ( "OCN" in self.componentDictionary[component]['host'] and main.onoscell ):
+            self.componentDictionary[component]['host'] = main.mnIP
+
         connect_result = driverObject.connect(user_name = self.componentDictionary[component]['user'] if ('user' in self.componentDictionary[component].keys()) else getpass.getuser(),
                                               ip_address= self.componentDictionary[component]['host'] if ('host' in self.componentDictionary[component].keys()) else 'localhost',
                                               pwd = self.componentDictionary[component]['password'] if ('password' in self.componentDictionary[component].keys()) else 'changeme',
@@ -683,9 +687,22 @@
             sys.exit()
 
 def verifyOnosCell(options):
-    # Verifying onoscell option. This could be extended to do even more from here.
+    # Verifying onoscell option
     if options.onoscell:
         main.onoscell = options.onoscell
+        main.onosIPs = []
+        main.mnIP = ""
+        cellCMD = ". ~/.profile; cell "+main.onoscell
+        output=subprocess.check_output( ["bash", '-c', cellCMD] )
+        splitOutput = output.splitlines()
+        for i in range( len(splitOutput) ):
+            if( re.match( "OCN", splitOutput[i] ) ):
+                mnNode=splitOutput[i].split("=")
+                main.mnIP = mnNode[1]
+            # cell already sorts OC variables in bash, so no need to sort in TestON
+            if( re.match( "OC[1-9]", splitOutput[i] ) ):
+                onosNodes = splitOutput[i].split("=")
+                main.onosIPs.append( onosNodes[1] )
     else :
         main.onoscell = main.FALSE