Test: Restart ONOS with default network cfg after vrouter/dhcprelay tests are run.
This puts ONOS back to initial state for other tests.

Change-Id: Ib20538399737789c11def76189a77bc651289506
diff --git a/src/test/cordSubscriber/cordSubscriberTest.py b/src/test/cordSubscriber/cordSubscriberTest.py
index 27dbc97..0447fcf 100644
--- a/src/test/cordSubscriber/cordSubscriberTest.py
+++ b/src/test/cordSubscriber/cordSubscriberTest.py
@@ -196,7 +196,7 @@
       num_subscribers = 0
       num_channels = 0
       recv_timeout = False
-      onos_restartable = not bool(int(os.getenv('ONOS_RESTART_DISABLED', 0)))
+      onos_restartable = bool(int(os.getenv('ONOS_RESTART', 0)))
 
       INTF_TX_DEFAULT = 'veth2'
       INTF_RX_DEFAULT = 'veth0'
diff --git a/src/test/dhcprelay/dhcprelayTest.py b/src/test/dhcprelay/dhcprelayTest.py
index c9de4e4..a5a7cf6 100644
--- a/src/test/dhcprelay/dhcprelayTest.py
+++ b/src/test/dhcprelay/dhcprelayTest.py
@@ -23,6 +23,7 @@
 from DHCP import DHCPTest
 from OnosCtrl import OnosCtrl, get_mac
 from OltConfig import OltConfig
+from CordTestServer import cord_test_onos_restart
 from portmaps import g_subscriber_port_map
 import threading, random
 from threading import current_thread
@@ -64,6 +65,8 @@
     running_time = 0
     total_success = 0
     total_failure = 0
+    #just in case we want to reset ONOS to default network cfg after relay tests
+    onos_restartable = bool(int(os.getenv('ONOS_RESTART', 0)))
 
     @classmethod
     def setUpClass(cls):
@@ -87,6 +90,7 @@
         except: pass
         cls.onos_ctrl.deactivate()
         cls.dhcpd_stop()
+        cls.dhcp_relay_cleanup()
 
     @classmethod
     def dhcp_relay_setup(cls):
@@ -117,6 +121,13 @@
             cls.onos_interface_load(interface_list)
 
     @classmethod
+    def dhcp_relay_cleanup(cls):
+        ##reset the ONOS port configuration back to default
+        if cls.onos_restartable is True:
+            log.info('Cleaning up dhcp relay config by restarting ONOS with default network cfg')
+            return cord_test_onos_restart(config = {})
+
+    @classmethod
     def onos_load_config(cls, config):
         status, code = OnosCtrl.config(config)
         if status is False:
diff --git a/src/test/setup/cord-test.py b/src/test/setup/cord-test.py
index 31d72ab..4f406e3 100755
--- a/src/test/setup/cord-test.py
+++ b/src/test/setup/cord-test.py
@@ -302,7 +302,7 @@
 
     test_containers = []
     #These tests end up restarting ONOS/quagga/radius
-    tests_exempt = ('vrouter', 'cordSubscriber', 'proxyarp')
+    tests_exempt = ('vrouter', 'cordSubscriber', 'proxyarp', 'dhcprelay')
     if args.test_type.lower() == 'all':
         tests = CordTester.ALL_TESTS
         args.quagga = True
@@ -362,7 +362,7 @@
                      'QUAGGA_IP': test_host,
                      'CORD_TEST_HOST' : test_host,
                      'CORD_TEST_PORT' : test_port,
-                     'ONOS_RESTART_DISABLED' : 1 if args.olt and args.test_controller else 0,
+                     'ONOS_RESTART' : 0 if args.olt and args.test_controller else 1,
                    }
     if args.olt:
         olt_conf_test_loc = os.path.join(CordTester.sandbox_setup, 'olt_config.json')
@@ -398,6 +398,7 @@
         if test_cnt.create and (args.start_switch or not args.olt):
             test_cnt.start_switch()
         if test_cnt.create and test_cnt.olt:
+            print('Test container create with port num: %d' %port_num)
             _, port_num = test_cnt.setup_intfs(port_num = port_num)
 
     thread_pool = ThreadPool(len(test_containers), queue_size = 1, wait_timeout=1)
@@ -504,7 +505,7 @@
                          'QUAGGA_IP': ip,
                          'CORD_TEST_HOST' : ip,
                          'CORD_TEST_PORT' : port,
-                         'ONOS_RESTART_DISABLED' : 1 if args.olt and args.test_controller else 0,
+                         'ONOS_RESTART' : 0 if args.olt and args.test_controller else 1,
                        }
         if args.olt:
             olt_conf_test_loc = os.path.join(CordTester.sandbox_setup, 'olt_config.json')
diff --git a/src/test/utils/OnosCtrl.py b/src/test/utils/OnosCtrl.py
index 22afa56..6083d85 100644
--- a/src/test/utils/OnosCtrl.py
+++ b/src/test/utils/OnosCtrl.py
@@ -52,7 +52,7 @@
 
     @classmethod
     def config(cls, config):
-        if config:
+        if config is not None:
             json_data = json.dumps(config)
             resp = requests.post(cls.cfg_url, auth = cls.auth, data = json_data)
             return resp.ok, resp.status_code
diff --git a/src/test/vrouter/vrouterTest.py b/src/test/vrouter/vrouterTest.py
index 89f11fc..9ca696a 100644
--- a/src/test/vrouter/vrouterTest.py
+++ b/src/test/vrouter/vrouterTest.py
@@ -92,6 +92,7 @@
     def tearDownClass(cls):
         '''Deactivate the vrouter apps'''
         #cls.vrouter_host_unload()
+        cls.start_onos(network_cfg = {})
 
     @classmethod
     def load_device_id(cls):