VOL-1057: Test Case: ONU discovery
Reverse previous solution to use onos from repo with encryption disabled and use new
voltha-apps charts to load onos-apps
Instead, wtih onos encryption disabled as the outcome of VOL-1343,
the original case where we use all locally built voltha images including onos
will now work

Change-Id: I3f5ac9e511e33cca0eee53f8d8fae53819586354
diff --git a/tests/atests/common/testCaseUtils.py b/tests/atests/common/testCaseUtils.py
index 72ba087..ead244d 100755
--- a/tests/atests/common/testCaseUtils.py
+++ b/tests/atests/common/testCaseUtils.py
@@ -22,6 +22,7 @@
 import commands
 import subprocess
 import pexpect
+import sys
    
 def configDirs(self, logDir, rootDir = None, volthaDir = None):
     self.dirs ['log'] = logDir
@@ -41,30 +42,40 @@
         file.truncate()
         file.close()      
 
-def send_command_to_voltha_cli(logDir, cmd, logFile):
-    vcliIp = extractIpAddr('vcli')
-    print (vcliIp)
-    print (cmd)
-    output = open(logDir + '/' + logFile, 'w')
-    child = pexpect.spawn('ssh -p 5022 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no voltha@' + vcliIp)
+def send_command_to_voltha_cli(logDir, logFile1, cmd1, logFile2 = None, cmd2 = None, logFile3 = None, cmd3 = None):
+    output = open(logDir + '/' + logFile1, 'w')
+    child = pexpect.spawn('ssh -p 30110 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no voltha@localhost')
     child.expect('[pP]assword:')
     child.sendline('admin')
     child.expect('\((\\x1b\[\d*;?\d+m){1,2}voltha(\\x1b\[\d*;?\d+m){1,2}\)')
     time.sleep(10)
-    bytes = child.sendline(cmd)
-    child.expect('\((\\x1b\[\d*;?\d+m){1,2}voltha(\\x1b\[\d*;?\d+m){1,2}\)')
-    print (child.before)
-    output.write(child.before)
-    output.close()
-    removeLeadingLine(logDir, logFile)
+    bytes = child.sendline(cmd1)
+    i = child.expect(['\((\\x1b\[\d*;?\d+m){1,2}voltha(\\x1b\[\d*;?\d+m){1,2}\)',
+    '\((\\x1b\[\d*;?\d+m){1,2}.*device [0-9a-f]{16}(\\x1b\[\d*;?\d+m){1,2}\)'])
+    if i == 0:
+        output.write(child.before)
+        output.close()
+        removeLeadingLine(logDir, logFile1)
+    elif i == 1:
+        if logFile2 != None and cmd2 != None:
+            output = open(logDir + '/' + logFile2, 'w')
+            bytes = child.sendline(cmd2)
+            child.expect('\((\\x1b\[\d*;?\d+m){1,2}.*device [0-9a-f]{16}(\\x1b\[\d*;?\d+m){1,2}\)')
+            output.write(child.before)
+            output.close()
+            removeLeadingLine(logDir, logFile2)
+        if logFile3 != None and cmd3 != None:
+            output = open(logDir + '/' + logFile3, 'w')
+            bytes = child.sendline(cmd3)
+            child.expect('\((\\x1b\[\d*;?\d+m){1,2}.*device [0-9a-f]{16}(\\x1b\[\d*;?\d+m){1,2}\)')
+            output.write(child.before)
+            output.close()
+            removeLeadingLine(logDir, logFile3)
     child.close()
 
 def send_command_to_onos_cli(logDir, cmd, logFile):
-    onosIp = extractIpAddr('onos-ssh')
-    print (onosIp)
     output = open(logDir + '/' + logFile, 'w')
-    child = pexpect.spawn('ssh -p 8101 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no karaf@' + onosIp)
-    
+    child = pexpect.spawn('ssh -p 30115 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no karaf@localhost')
     child.expect('[pP]assword:')
     child.sendline('karaf')
     child.expect('(\\x1b\[\d*;?\d+m){1,2}onos>(\\x1b\[\d*;?\d+m){1,2}')
@@ -77,10 +88,23 @@
     output.close()
     child.close()
 
+def get_fields_from_grep_command(self, searchWord, logFile):
+    grepCommand =\
+        "grep %s %s/%s" % (searchWord, getDir(self, 'log'), logFile)  
+    statusLines = commands.getstatusoutput(grepCommand)[1]
+    return statusLines
+    
 def parseFields(statusLine):
     statusList = statusLine.split("|")
     return statusList
 
+def printLogFile(self, logFile):
+    with open(getDir(self, 'log') + '/' + logFile, 'r+') as file:
+        lines = file.readlines()
+        print
+        for line in lines:
+            sys.stdout.write (line)
+
 def extractIpAddr(podName):
     proc1 = subprocess.Popen(['/usr/bin/kubectl', 'get', 'svc', '--all-namespaces'],
                              stdout=subprocess.PIPE,