Enable igmp test to work under voltha.
Also change cordSubscriber voltha test to work with the voltha auto configure.
Import teardown_module as well in other test cases.
The tests that are not supposed to work with voltha or rely on auto configure should set:
VOLTHA_AUTO_CONFIGURE = False
in their test class.

Change-Id: Ibbe60e524d31e7079e0423e9e3c390ee17dee2a7
diff --git a/src/test/acl/aclTest.py b/src/test/acl/aclTest.py
index 87257c3..fdc6b1d 100644
--- a/src/test/acl/aclTest.py
+++ b/src/test/acl/aclTest.py
@@ -24,7 +24,7 @@
 from portmaps import g_subscriber_port_map
 from CordTestServer import cord_test_onos_restart
 from ACL import ACLTest
-from CordTestConfig import setup_module
+from CordTestConfig import setup_module, teardown_module
 import threading
 import time
 import os
diff --git a/src/test/cluster/clusterTest.py b/src/test/cluster/clusterTest.py
index ed5f84a..4bebb77 100644
--- a/src/test/cluster/clusterTest.py
+++ b/src/test/cluster/clusterTest.py
@@ -34,7 +34,7 @@
 from ACL import ACLTest
 from OnosLog import OnosLog
 from CordLogger import CordLogger
-from CordTestConfig import setup_module
+from CordTestConfig import setup_module, teardown_module
 import os
 import json
 import random
diff --git a/src/test/cordSubscriber/cordSubscriberTest.py b/src/test/cordSubscriber/cordSubscriberTest.py
index 9aeba36..64143c0 100644
--- a/src/test/cordSubscriber/cordSubscriberTest.py
+++ b/src/test/cordSubscriber/cordSubscriberTest.py
@@ -27,7 +27,6 @@
 import requests
 from Stats import Stats
 from OnosCtrl import OnosCtrl
-from VolthaCtrl import VolthaCtrl
 from DHCP import DHCPTest
 from EapTLS import TLSAuthTest
 from Channels import Channels, IgmpChannel
@@ -38,7 +37,7 @@
 from CordTestServer import cord_test_onos_restart, cord_test_shell, cord_test_radius_restart
 from CordTestUtils import log_test, get_controller
 from CordLogger import CordLogger
-from CordTestConfig import setup_module
+from CordTestConfig import setup_module, teardown_module
 from CordContainer import Onos
 
 log_test.setLevel('INFO')
@@ -267,8 +266,6 @@
 yg==
 -----END CERTIFICATE-----'''
 
-      #disable voltha auto configuration
-      VOLTHA_AUTO_CONFIGURE = False
       VOLTHA_HOST = None
       VOLTHA_REST_PORT = 8881
       VOLTHA_UPLINK_VLAN_MAP = { 'of:0000000000000001' : '222' }
@@ -277,6 +274,9 @@
       VOLTHA_OLT_TYPE = 'simulated_olt'
       VOLTHA_OLT_MAC = '00:0c:e2:31:12:00'
       VOLTHA_ENABLED = bool(int(os.getenv('VOLTHA_ENABLED', 0)))
+      voltha_ctrl = None
+      voltha_device = None
+      voltha_switch_map = None
 
       @classmethod
       def update_apps_version(cls):
@@ -2623,32 +2623,13 @@
           if self.VOLTHA_HOST is None:
                 log_test.info('Skipping test as no voltha host')
                 return
-          voltha = VolthaCtrl(self.VOLTHA_HOST,
-                              rest_port = self.VOLTHA_REST_PORT,
-                              uplink_vlan_map = self.VOLTHA_UPLINK_VLAN_MAP)
-          if self.VOLTHA_OLT_TYPE.startswith('ponsim'):
-                ponsim_address = '{}:50060'.format(self.VOLTHA_HOST)
-                log_test.info('Enabling ponsim olt')
-                device_id, status = voltha.enable_device(self.VOLTHA_OLT_TYPE, address = ponsim_address)
-          else:
-                log_test.info('Enabling OLT instance for %s with mac %s' %(self.VOLTHA_OLT_TYPE, self.VOLTHA_OLT_MAC))
-                device_id, status = voltha.enable_device(self.VOLTHA_OLT_TYPE, self.VOLTHA_OLT_MAC)
-
-          assert_not_equal(device_id, None)
-          if status == False:
-                voltha.disable_device(device_id, delete = True)
-          assert_equal(status, True)
-          time.sleep(10)
           switch_map = None
           olt_configured = False
           try:
-                switch_map = voltha.config(fake = self.VOLTHA_CONFIG_FAKE)
+                switch_map = self.voltha_switch_map
                 if not switch_map:
                       log_test.info('No voltha devices found')
                       return
-                log_test.info('Installing OLT app')
-                OnosCtrl.install_app(self.olt_app_file)
-                time.sleep(5)
                 log_test.info('Adding subscribers through OLT app')
                 self.config_olt(switch_map)
                 olt_configured = True
@@ -2666,13 +2647,9 @@
                 if switch_map is not None:
                       if olt_configured is True:
                             self.remove_olt(switch_map)
-                      voltha.disable_device(device_id, delete = True)
-                      time.sleep(10)
-                      log_test.info('Uninstalling OLT app')
-                      OnosCtrl.uninstall_app(self.olt_app_name)
 
       def test_cord_subscriber_voltha_tls(self):
-          """Test subscriber join next for channel surfing"""
+          """Test subscriber TLS authentication with voltha"""
           if self.VOLTHA_HOST is None:
                 log_test.info('Skipping test as no voltha host')
                 return
@@ -2685,7 +2662,7 @@
                                       num_channels = num_channels)
 
       def test_cord_subscriber_voltha_tls_igmp(self):
-          """Test subscriber join next for channel surfing"""
+          """Test subscriber TLS and IGMP with voltha with 1 channel"""
           if self.VOLTHA_HOST is None:
                 log_test.info('Skipping test as no voltha host')
                 return
@@ -2698,7 +2675,7 @@
                                       num_channels = num_channels)
 
       def test_cord_subscriber_voltha_tls_igmp_3(self):
-          """Test subscriber join next for channel surfing with 3 subscribers browsing 3 channels each"""
+          """Test subscriber TLS and IGMP with voltha for channel surfing with 3 subscribers browsing 3 channels each"""
           if self.VOLTHA_HOST is None:
                 log_test.info('Skipping test as no voltha host')
                 return
diff --git a/src/test/dhcp/dhcpTest.py b/src/test/dhcp/dhcpTest.py
index c6a3d0d..f54af5f 100644
--- a/src/test/dhcp/dhcpTest.py
+++ b/src/test/dhcp/dhcpTest.py
@@ -24,7 +24,7 @@
 from OnosCtrl import OnosCtrl
 from portmaps import g_subscriber_port_map
 from CordLogger import CordLogger
-from CordTestConfig import setup_module
+from CordTestConfig import setup_module, teardown_module
 from CordTestUtils import log_test
 log_test.setLevel('INFO')
 
diff --git a/src/test/igmp/igmpTest.py b/src/test/igmp/igmpTest.py
index 041a324..8e18145 100644
--- a/src/test/igmp/igmpTest.py
+++ b/src/test/igmp/igmpTest.py
@@ -28,7 +28,7 @@
 from OltConfig import OltConfig
 from Channels import IgmpChannel
 from CordLogger import CordLogger
-from CordTestConfig import setup_module
+from CordTestConfig import setup_module, teardown_module
 from CordTestUtils import log_test
 
 log_test.setLevel('INFO')
diff --git a/src/test/onboarding/onboardingTest.py b/src/test/onboarding/onboardingTest.py
index 718fa91..1f6226f 100644
--- a/src/test/onboarding/onboardingTest.py
+++ b/src/test/onboarding/onboardingTest.py
@@ -31,7 +31,7 @@
 from OltConfig import OltConfig
 from OnboardingServiceUtils import OnboardingServiceUtils
 from SSHTestAgent import SSHTestAgent
-from CordTestConfig import setup_module, running_on_ciab
+from CordTestConfig import setup_module, running_on_ciab, teardown_module
 from CordLogger import CordLogger
 from CordTestUtils import *
 from CordTestUtils import log_test as log
@@ -39,7 +39,6 @@
 import time
 import json
 from VSGAccess import VSGAccess
-from CordTestConfig import setup_module, running_on_ciab
 log.setLevel('INFO')
 
 class onboarding_exchange(CordLogger):
@@ -1285,4 +1284,3 @@
             df.callback(0)
         reactor.callLater(0,test_exampleservice,df)
         return df
-
diff --git a/src/test/scale/scaleTest.py b/src/test/scale/scaleTest.py
index 19740ad..f6a1ee0 100644
--- a/src/test/scale/scaleTest.py
+++ b/src/test/scale/scaleTest.py
@@ -31,7 +31,7 @@
 from CordLogger import CordLogger
 from VSGAccess import VSGAccess
 from CordTestUtils import log_test as log
-from CordTestConfig import setup_module, running_on_ciab
+from CordTestConfig import setup_module, running_on_ciab, teardown_module
 from OnosCtrl import OnosCtrl
 from CordContainer import Onos
 from CordSubscriberUtils import CordSubscriberUtils, XosUtils
diff --git a/src/test/tls/tlsTest.py b/src/test/tls/tlsTest.py
index 3417b1f..c9648d4 100644
--- a/src/test/tls/tlsTest.py
+++ b/src/test/tls/tlsTest.py
@@ -24,7 +24,6 @@
 from CordLogger import CordLogger
 from CordTestUtils import log_test
 from CordTestConfig import setup_module, teardown_module
-from VolthaCtrl import VolthaCtrl
 from scapy.all import *
 from scapy_ssl_tls.ssl_tls import *
 from scapy_ssl_tls.ssl_tls_crypto import *
diff --git a/src/test/utils/CordTestConfig.py b/src/test/utils/CordTestConfig.py
index e57b948..f41d0da 100644
--- a/src/test/utils/CordTestConfig.py
+++ b/src/test/utils/CordTestConfig.py
@@ -78,7 +78,7 @@
     voltha_attrs = dict(host='172.17.0.1',
                         rest_port = 8881,
                         config_fake = False,
-                        olt_type = 'ponsim',
+                        olt_type = 'ponsim_olt',
                         olt_mac = '00:0c:e2:31:12:00',
                         uplink_vlan_map = { 'of:0000000000000001' : '222' }
                         )
diff --git a/src/test/utils/VolthaCtrl.py b/src/test/utils/VolthaCtrl.py
index 9e9b757..d7ab139 100644
--- a/src/test/utils/VolthaCtrl.py
+++ b/src/test/utils/VolthaCtrl.py
@@ -304,7 +304,7 @@
     return olt_app_file
 
 def voltha_setup(host = '172.17.0.1', rest_port = VolthaCtrl.REST_PORT,
-                 olt_type = 'ponsim', olt_mac = '00:0c:e2:31:12:00',
+                 olt_type = 'ponsim_olt', olt_mac = '00:0c:e2:31:12:00',
                  uplink_vlan_map = VolthaCtrl.UPLINK_VLAN_MAP,
                  config_fake = False, olt_app = None):
 
@@ -318,7 +318,8 @@
         device_id, status = voltha.enable_device(olt_type, olt_mac)
 
     if device_id is None or status is False:
-        voltha.disable_device(device_id)
+        if device_id:
+            voltha.disable_device(device_id)
         return None
 
     switch_map = None
diff --git a/src/test/voltha/volthaTest.py b/src/test/voltha/volthaTest.py
index be2ad7d..6844e0d 100644
--- a/src/test/voltha/volthaTest.py
+++ b/src/test/voltha/volthaTest.py
@@ -11,7 +11,7 @@
 from nose.tools import *
 from nose.twistedtools import reactor, deferred
 from twisted.internet import defer
-from CordTestConfig import setup_module
+from CordTestConfig import setup_module, teardown_module
 from CordTestUtils import log_test
 from VolthaCtrl import VolthaCtrl
 from CordTestUtils import log_test, get_controller
@@ -167,6 +167,7 @@
     #onos_config_path = os.path.join(test_path, '..', 'setup/onos-config')
     olt_conf_file = os.getenv('OLT_CONFIG_FILE', os.path.join(test_path, '..', 'setup/olt_config.json'))
     onos_restartable = bool(int(os.getenv('ONOS_RESTART', 0)))
+    VOLTHA_AUTO_CONFIGURE = False
     VOLTHA_ENABLED  = True
     INTF_TX_DEFAULT = 'veth2'
     INTF_RX_DEFAULT = 'veth0'
@@ -4395,4 +4396,3 @@
         12. Enable olt device which is disable at step 9.
         13. Repeat steps 4,5, 7 and 8.
         """
-
diff --git a/src/test/vsg/vsgTest.py b/src/test/vsg/vsgTest.py
index ee192ba..8f733ed 100644
--- a/src/test/vsg/vsgTest.py
+++ b/src/test/vsg/vsgTest.py
@@ -27,7 +27,7 @@
 from CordLogger import CordLogger
 from VSGAccess import VSGAccess
 from CordTestUtils import log_test as log
-from CordTestConfig import setup_module, running_on_ciab
+from CordTestConfig import setup_module, running_on_ciab, teardown_module
 from OnosCtrl import OnosCtrl
 from CordContainer import Onos
 from CordSubscriberUtils import CordSubscriberUtils, XosUtils