VOL-1054 Kubernetes Conversion and PonsimV2date Makefile with selective changes from the one from SIAB to allow compatibility with Helm Chart changes
Change Class and filenames according to best practices
Change preprovisionTest -> Preprovision
Change-Id: Ib15e34ad397d2307b5ba3890cc6e8b245e5e3004
diff --git a/tests/atests/common/auto_test.py b/tests/atests/common/auto_test.py
index d0bd327..8f1997e 100755
--- a/tests/atests/common/auto_test.py
+++ b/tests/atests/common/auto_test.py
@@ -23,15 +23,10 @@
 import time
 import argparse
 import volthaMngr
-import preprovisioningTest
+import preprovisioning
 
 DEFAULT_LOG_DIR = '/tmp/voltha_test_results'
 
-def runOnos():
-    os.system('docker-compose -f compose/docker-compose-auth-test.yml'
-              ' up -d onos freeradius' + ' > /dev/null 2>&1')
-
-
 def dirInit(logDir=DEFAULT_LOG_DIR,
          volthaDir=os.environ['VOLTHA_BASE']):
     print(__file__)
@@ -47,9 +42,9 @@
     # In future in order to keep the history of jobs, the run time should be
     # added to the log directory name
     # logDir += '_' + currentTime
-
+    
     os.system('mkdir -p ' + logDir + ' > /dev/null 2>&1')
-    os.system('rm -rf %s/*' + logDir)
+    os.system('rm -rf %s/*' % logDir)
     print('Start Provisioning Test at: %s\nRoot Directory: %s\n'
           'VOLTHA Directory: %s\nLog Directory: %s' %
           (currentTime, rootDir, volthaDir, logDir))
@@ -74,8 +69,6 @@
 
     volthaMngr.voltha_Initialize(ROOT_DIR, VOLTHA_DIR, LOG_DIR)
 
-    runOnos()
-
-    preprovisioningTest.runTest('172.17.0.1', 50060, LOG_DIR)
+    preprovisioning.runTest('olt.voltha.svc', 50060, LOG_DIR)
 
     time.sleep(5)
diff --git a/tests/atests/common/build.sh b/tests/atests/common/build.sh
new file mode 100755
index 0000000..203f59b
--- /dev/null
+++ b/tests/atests/common/build.sh
@@ -0,0 +1,45 @@
+#!/bin/bash +x
+# Copyright 2017-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+SRC_DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
+BUILD_DIR="$SRC_DIR/../build"
+
+cd $BUILD_DIR
+
+if [ $# -ne 1 ]
+  then
+    echo "No arguments supplied"
+    exit 1
+fi
+if [ -z "$1" ]
+  then
+    echo "Empty argument supplied"
+    exit 1
+fi
+if [ $1 == "clear" ]
+  then
+    sudo make reset-kubeadm
+elif [ $1 == "start" ]
+  then
+    sudo make -f Makefile
+elif [ $1 == "stop" ]
+  then
+    pods=$( /usr/bin/kubectl get pods --all-namespaces 2>&1 | grep -c -e refused -e resource )
+    if  [ $pods -eq 0 ]
+      then
+        sudo make teardown-charts
+    fi
+fi
+exit 0
diff --git a/tests/atests/common/enable_bridge.sh b/tests/atests/common/enable_bridge.sh
deleted file mode 100755
index 9d17ae5..0000000
--- a/tests/atests/common/enable_bridge.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/sh +x
-# Copyright 2017-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-echo 'Enable Bridge'
-echo 8 > /sys/class/net/ponmgmt/bridge/group_fwd_mask
diff --git a/tests/atests/common/preprovisioning.py b/tests/atests/common/preprovisioning.py
new file mode 100755
index 0000000..9b19408
--- /dev/null
+++ b/tests/atests/common/preprovisioning.py
@@ -0,0 +1,89 @@
+#
+# Copyright 2018 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+"""
+vOLT-HA Pre-provisioning Test module
+"""
+
+import time
+import os
+import commands
+import testCaseUtils
+
+class Preprovisioning(object):
+
+    """
+    This class implements voltha pre-provisioning test
+    """
+    
+    def __init__(self):
+        self.dirs = {}
+        self.dirs ['log'] = None
+        self.dirs ['root'] = None
+        self.dirs ['voltha'] = None
+        
+        self.__oltIpAddress = None
+        self.__oltPort = None
+        self.__statusLine = ""
+        self.__fields = []
+        
+    def pSetLogDirs(self, logDir):
+        testCaseUtils.configDirs(self, logDir)
+
+    def configure(self, oltIpAddress, oltPort):
+        self.__oltIpAddress = oltIpAddress       
+        self.__oltPort = oltPort
+
+    def preprovisionOlt(self):
+        print('Do PROVISIONING')
+        testCaseUtils.send_command_to_voltha_cli(testCaseUtils.getDir(self, 'log'),
+            'preprovision_olt -t ponsim_olt -H %s:%s' %
+            (self.__oltIpAddress, self.__oltPort),
+            'voltha_preprovision_olt.log')
+        time.sleep(5)
+   
+    def query_devices_before_enable(self):
+        testCaseUtils.send_command_to_voltha_cli(testCaseUtils.getDir(self, 'log'), 'devices',
+                                        'voltha_devices_before_enable.log')
+        time.sleep(5)
+        grepCommand =\
+            "grep PREPROVISIONED %s/voltha_devices_before_enable.log " % testCaseUtils.getDir(self, 'log')
+        self.__statusLine = commands.getstatusoutput(grepCommand)[1]
+        self.__fields = testCaseUtils.parseFields(self.__statusLine)
+        self.__oltDeviceId = self.__fields[1].strip()
+        print ("OLT device id = %s" % self.__oltDeviceId)
+        
+    def enable(self):
+        print('Enable %s OLT device' % self.__oltDeviceId)
+        testCaseUtils.send_command_to_voltha_cli(testCaseUtils.getDir(self, 'log'), 'enable ' + self.__oltDeviceId,
+                                        'voltha_enable.log')
+
+    def query_devices_after_enable(self):
+        testCaseUtils.send_command_to_voltha_cli(testCaseUtils.getDir(self, 'log'), 'devices',
+                                        'voltha_devices_after_enable.log')
+
+def runTest(oltIpAddress, oltPort, logDir):
+    preprovisioning = Preprovisioning()
+    preprovisioning.pSetLogDirs(logDir)
+    preprovisioning.configure(str(oltIpAddress), int(oltPort))
+    preprovisioning.preprovisionOlt()
+    preprovisioning.query_devices_before_enable()
+    preprovisioning.enable()
+    preprovisioning.query_devices_after_enable()
+    
+                                          
+                                          
+
diff --git a/tests/atests/common/preprovisioningTest.py b/tests/atests/common/preprovisioningTest.py
deleted file mode 100755
index a8bbe3e..0000000
--- a/tests/atests/common/preprovisioningTest.py
+++ /dev/null
@@ -1,105 +0,0 @@
-#
-# Copyright 2018 the original author or authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-"""
-vOLT-HA Pre-provisioning Test module
-"""
-
-import time
-import os
-import commands
-
-
-class preprovisioningTest(object):
-
-    """
-    This class implements voltha pre-provisioning test
-    """
-    
-    def __init__(self):
-        self.__oltIpAddress = None        
-        self.__oltPort = None
-        self.__logDir = None
-        self.__oltDeviceId = None
-        self.__statusLine = ""
-        self.__fields = []
-        
-    def configure(self, oltIpAddress, oltPort, logDir):
-        self.__oltIpAddress = oltIpAddress        
-        self.__oltPort = oltPort
-        self.__logDir = logDir    
-
-
-    def preprovisionOlt(self):
-        print('Do PROVISIONING')
-        self.send_command_to_voltha_cli(
-            'preprovision_olt -t ponsim_olt -H %s:%s' %
-            (self.__oltIpAddress, self.__oltPort),
-            'voltha_preprovision_olt.log')
-        time.sleep(5)
-   
-    def query_devices_before_enable(self):
-        self.send_command_to_voltha_cli('devices',
-                                        'voltha_devices_before_enable.log')
-        time.sleep(5)
-        grepCommand =\
-            "grep PREPROVISIONED %s/voltha_devices_before_enable.log " % self.__logDir
-        self.__statusLine = commands.getstatusoutput(grepCommand)[1]
-        self.__fields = self.parseFields(self.__statusLine)
-        self.__oltDeviceId = self.__fields[1].strip()
-        print ("OLT device id = %s" % self.__oltDeviceId)
-        
-    def enable(self):
-        print('Enable %s OLT device' % self.__oltDeviceId)
-        self.send_command_to_voltha_cli('enable ' + self.__oltDeviceId,
-                                        'voltha_enable.log')
-    def query_devices_after_enable(self):
-        self.send_command_to_voltha_cli('devices',
-                                        'voltha_devices_after_enable.log')
-
-    def send_command_to_voltha_cli(self, cmd, logFile):
-        # os.system("docker exec -i -t compose_cli_1 sh -c 'echo \"" + cmd +
-        #           "\" > /voltha_tmp_command.txt'")
-        os.system("docker exec compose_cli_1 sh -c 'echo \"" + cmd +
-                  "\" > /voltha_tmp_command.txt'")
-        os.system("docker exec compose_cli_1 sh -c '/cli/cli/main.py -C "
-                  "vconsul:8500 -L < /voltha_tmp_command.txt' > " +
-                  self.__logDir + '/' + logFile)
-
-    def send_command_to_onos_cli(self, cmd, logFile):
-        os.system(
-            "sshpass -p karaf ssh -o StrictHostKeyChecking=no -p 8101 "
-            "karaf@localhost " + cmd + " 2>/dev/null > " +
-            self.__logDir + '/' + logFile)
-            
-    def parseFields(self, statusLine):
-        statusList = statusLine.split("|")
-        return statusList
-
-            
- 
-def runTest(oltIpAddress, oltPort, logDir):
-    preprovisioning = preprovisioningTest()
-    preprovisioning.configure(str(oltIpAddress), int(oltPort),
-                                          str(logDir))
-    preprovisioning.preprovisionOlt()
-    preprovisioning.query_devices_before_enable()
-    preprovisioning.enable()
-    preprovisioning.query_devices_after_enable()
-    
-                                          
-                                          
-
diff --git a/tests/atests/common/run_robot.sh b/tests/atests/common/run_robot.sh
index fa60b99..b86a267 100755
--- a/tests/atests/common/run_robot.sh
+++ b/tests/atests/common/run_robot.sh
@@ -19,4 +19,4 @@
 echo "Run Robot Framework TEST. Log: $1"
 cd $VOLTHA_DIR
 source env.sh
-robot -d $1 -v LOG_DIR:$1/voltha ./tests/atests/robot/auto_testing.robot
+robot -d $1 -v LOG_DIR:$1/voltha_test_results ./tests/atests/robot/voltha_automated_test_suite.robot
diff --git a/tests/atests/common/testCaseUtils.py b/tests/atests/common/testCaseUtils.py
new file mode 100755
index 0000000..541c9c0
--- /dev/null
+++ b/tests/atests/common/testCaseUtils.py
@@ -0,0 +1,116 @@
+#
+# Copyright 2018 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+"""
+vOLT-HA Test Case Utils module
+"""
+import time
+import os
+import commands
+import subprocess
+import pexpect
+   
+def configDirs(self, logDir, rootDir = None, volthaDir = None):
+    self.dirs ['log'] = logDir
+    self.dirs ['root'] = rootDir
+    self.dirs ['voltha'] = volthaDir
+    
+def getDir(self, Dir):
+    return self.dirs.get(Dir)
+    
+def removeLeadingLine(logDir, logFile):
+    with open(logDir + '/' + logFile, 'r+') as file:
+        lines = file.readlines()
+        file.seek(0)
+        lines = lines[1:]
+        for line in lines:
+            file.write(line)
+        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)
+    child.expect('[pP]assword:')
+    child.sendline('admin')
+    child.expect('\((\\x1b\[\d*;?\d+m){1,2}voltha(\\x1b\[\d*;?\d+m){1,2}\)')
+    time.sleep(5)
+    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)
+    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.expect('[pP]assword:')
+    child.sendline('karaf')
+    child.expect('(\\x1b\[\d*;?\d+m){1,2}onos>(\\x1b\[\d*;?\d+m){1,2}')
+    child.sendline('flows')
+    child.expect('flows')
+    child.expect('(\\x1b\[\d*;?\d+m){1,2}onos>(\\x1b\[\d*;?\d+m){1,2}')
+
+    output.write(child.before)
+    
+    output.close()
+    child.close()
+
+def parseFields(statusLine):
+    statusList = statusLine.split("|")
+    return statusList
+
+def extractIpAddr(podName):
+    proc1 = subprocess.Popen(['/usr/bin/kubectl', 'get', 'svc', '--all-namespaces'],
+                             stdout=subprocess.PIPE,
+                             stderr=subprocess.PIPE)
+    proc2 = subprocess.Popen(['grep', '-e', podName], stdin=proc1.stdout,
+                             stdout=subprocess.PIPE,
+                             stderr=subprocess.PIPE)
+    proc3 = subprocess.Popen(['awk', "{print $4}"], stdin=proc2.stdout,
+                             stdout=subprocess.PIPE,
+                             stderr=subprocess.PIPE)
+                            
+    proc1.stdout.close
+    proc2.stdout.close
+    out, err = proc3.communicate()
+    return out
+    
+def extractPodName(shortPodName):
+    proc1 = subprocess.Popen(['/usr/bin/kubectl', 'get', 'pods', '--all-namespaces'],
+                             stdout=subprocess.PIPE,
+                             stderr=subprocess.PIPE)
+    proc2 = subprocess.Popen(['grep', '-e', shortPodName], stdin=proc1.stdout,
+                             stdout=subprocess.PIPE,
+                             stderr=subprocess.PIPE)
+    proc3 = subprocess.Popen(['awk', "{print $2}"], stdin=proc2.stdout,
+                             stdout=subprocess.PIPE,
+                             stderr=subprocess.PIPE)
+                      
+                      
+    proc1.stdout.close
+    proc2.stdout.close
+    out, err = proc3.communicate()
+    return out
+
diff --git a/tests/atests/common/volthaMngr.py b/tests/atests/common/volthaMngr.py
index 553f7c0..5257dfa 100755
--- a/tests/atests/common/volthaMngr.py
+++ b/tests/atests/common/volthaMngr.py
@@ -22,111 +22,103 @@
 import os
 import time
 import subprocess
-import paramiko
-import spur
+import testCaseUtils
+import urlparse
 
-class volthaMngr(object):
+class VolthaMngr(object):
 
     """
     This class implements voltha startup/shutdown callable helper functions
     """
     def __init__(self):
-        self.__rootDir = None
-        self.__volthaDir = None
-        self.__logDir = None
-        self.__rootSsh = None
-
-    def configDir(self, rootDir, volthaDir, logDir):
-        self.__rootDir = rootDir
-        self.__volthaDir = volthaDir
-        self.__logDir = logDir
+        self.dirs = {}
+        self.dirs ['root'] = None
+        self.dirs ['voltha'] = None
+        self.dirs ['log'] = None
         
-        os.chdir(volthaDir)
-
-    def openRootSsh(self):
-        shell = spur.SshShell(hostname='localhost', username='root',
-                              password='root',
-                              missing_host_key=spur.ssh.MissingHostKey.accept)
-        return shell
-
-    def getAllRunningContainers(self):
-        allContainers = []
-        proc1 = subprocess.Popen(['docker', 'ps', '-a'],
+    def vSetLogDirs(self, rootDir, volthaDir, logDir):
+        testCaseUtils.configDirs(self, logDir, rootDir, volthaDir)
+        
+    def startAllPods(self):
+        proc1 = subprocess.Popen([testCaseUtils.getDir(self, 'root') + '/build.sh', 'start'],
                                  stdout=subprocess.PIPE,
                                  stderr=subprocess.PIPE)
-        proc2 = subprocess.Popen(['grep', '-v', 'CONT'], stdin=proc1.stdout,
+        output = proc1.communicate()[0]
+        print(output)
+        proc1.stdout.close
+
+    def stopAllPods(self):
+        proc1 = subprocess.Popen([testCaseUtils.getDir(self, 'root') + '/build.sh', 'stop'],
+                                 stdout=subprocess.PIPE,
+                                 stderr=subprocess.PIPE)
+        output = proc1.communicate()[0]
+        print(output)
+        proc1.stdout.close
+        
+    def resetKubeAdm(self):
+        proc1 = subprocess.Popen([testCaseUtils.getDir(self, 'root') + '/build.sh', 'clear'],
+                                 stdout=subprocess.PIPE,
+                                 stderr=subprocess.PIPE)
+        output = proc1.communicate()[0]
+        print(output)
+        proc1.stdout.close
+
+    """
+    Because we are not deploying SEBA with XOS and NEM, and that a standalone Voltha
+    deployment is not common, in order to get flows to work, we need to alter Onos 
+    NetCfg in two fashion.
+    One is to add to device list and the other is to add the missing Sadis section
+    """        
+    def alterOnosNetCfg(self):
+        print ('Altering the Onos NetCfg to suit Voltha\'s needs')
+        time.sleep(30)
+        onosIp = testCaseUtils.extractIpAddr("onos-ui")
+        netloc = onosIp.rstrip() + ":8181"
+        devUrl = urlparse.urlunparse(('http', netloc, '/onos/v1/network/configuration/devices/', '', '', ''))
+        sadisUrl = urlparse.urlunparse(('http', netloc, '/onos/v1/network/configuration/apps/', '', '', ''))
+        os.system('curl --user karaf:karaf -X POST -H "Content-Type: application/json" '
+            '%s -d @%s/tests/atests/build/devices_json' % (devUrl, testCaseUtils.getDir(self, 'voltha')))
+        os.system('curl --user karaf:karaf -X POST -H "Content-Type: application/json" '
+            '%s -d @%s/tests/atests/build/sadis_json' % (sadisUrl, testCaseUtils.getDir(self, 'voltha')))
+            
+    def getAllRunningPods(self):
+        allRunningPods = []
+        proc1 = subprocess.Popen(['/usr/bin/kubectl', 'get', 'pods', '--all-namespaces'],
+                                 stdout=subprocess.PIPE,
+                                 stderr=subprocess.PIPE)
+        proc2 = subprocess.Popen(['grep', '-v', 'NAMESPACE'], stdin=proc1.stdout,
                                  stdout=subprocess.PIPE,
                                  stderr=subprocess.PIPE)
         proc1.stdout.close
         out, err = proc2.communicate()
+        print (out)
         if out:
             for line in out.split('\n'):
                 items = line.split()
-                if len(items):
-                    allContainers.append(items)
-        return allContainers
+                nsName = {}
+                if len(items) > 2:
+                    nsName = {}
+                    nsName['NS'] = items[0]
+                    nsName['Name'] = items[1]
+                    allRunningPods.append(nsName)
+        return allRunningPods
+ 
+    def collectPodLogs(self):
+        print('Collect logs from all Pods')
+        allRunningPods = self.getAllRunningPods()
+        for nsName in allRunningPods:
+            Namespace = nsName.get('NS')
+            podName   = nsName.get('Name')
+            os.system('/usr/bin/kubectl logs -n %s -f %s > %s/%s.log 2>&1 &' %
+                      (Namespace, podName, testCaseUtils.getDir(self, 'log'), podName))
 
-    def stopPonsim(self):
-        command = "for pid in $(ps -ef | grep ponsim | grep -v grep | " \
-                  "awk '{print $2}'); do echo $pid; done"
-        client = paramiko.SSHClient()
-        client.load_system_host_keys()
-        client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
-        client.connect('localhost', username='root', password='root')
-        transport = client.get_transport()
-        channel = transport.open_session()
-
-        channel.exec_command(command)
-        procIds = channel.recv(4096).replace('\n', ' ')
-        channel = transport.open_session()
-        channel.exec_command('sudo kill -9 %s' % procIds)
-
-    def removeExistingContainers(self):
-        allContainers = self.getAllRunningContainers()
-        for container in allContainers:
-            procID = container[0]
-            os.system('docker rm -f %s > /dev/null 2>&1' % procID)
-
-    def startVolthaContainers(self):
-        print('Start VOLTHA containers')
-        # Bring up all the containers required for VOLTHA (total 15)
-        os.system(
-            'docker-compose -f compose/docker-compose-system-test.yml '
-            'up -d > %s/start_voltha_containers.log 2>&1' %
-            self.__logDir)
-
-    def collectAllLogs(self):
-        print('Collect all VOLTHA container logs')
-        allContainers = self.getAllRunningContainers()
-        for container in allContainers:
-            containerName = container[-1]
-            os.system('docker logs --since 0m -f %s > %s/%s.log 2>&1 &' %
-                      (containerName, self.__logDir, containerName))
-
-    def enableBridge(self):
-        self.__rootSsh = self.openRootSsh()
-        result = self.__rootSsh.run([self.__rootDir + '/enable_bridge.sh'])
-        print(result.output)
-
-    def startPonsim(self, onusAmount=1):
-        command = 'source env.sh ; ./ponsim/main.py -v'
-        if onusAmount > 1:
-            command += ' -o %s' % onusAmount
-        ponsimLog = open('%s/ponsim.log' % self.__logDir, 'w')
-        process = self.__rootSsh.spawn(['bash', '-c', command],
-                                       cwd=self.__volthaDir, store_pid=True,
-                                       stdout=ponsimLog)
-        return process.pid
-
-
+        
 def voltha_Initialize(rootDir, volthaDir, logDir):
+    voltha = VolthaMngr()
+    voltha.vSetLogDirs(rootDir, volthaDir, logDir)
+    voltha.stopAllPods()
+    voltha.resetKubeAdm()
+    voltha.startAllPods()
+    voltha.alterOnosNetCfg()
+    voltha.collectPodLogs()
 
-    voltha = volthaMngr()
-    voltha.configDir(rootDir, volthaDir, logDir)
-    voltha.stopPonsim()
-    voltha.removeExistingContainers()
-    voltha.startVolthaContainers()
-    voltha.collectAllLogs()
-    voltha.enableBridge()
-    voltha.startPonsim(3)
-