Support sending TAGGED, untagged traffic for cord-tester test case. (dhcp,etc.)

Change-Id: I6d71a23f9f824ef3d37ec12ba372902c35addb33
diff --git a/src/test/dhcpl2relay/dhcpl2relayTest.json b/src/test/dhcpl2relay/dhcpl2relayTest.json
index 105156a..1c72d60 100644
--- a/src/test/dhcpl2relay/dhcpl2relayTest.json
+++ b/src/test/dhcpl2relay/dhcpl2relayTest.json
@@ -1,7 +1,8 @@
 {
-    "VOLTHA_OLT_MAC": "00:0c:e2:31:12:00", 
-    "VOLTHA_HOST": "172.17.0.1", 
-    "VOLTHA_OLT_TYPE": "ponsim_olt", 
-    "VOLTHA_REST_PORT": 8882, 
+    "TAGGED_TRAFFIC" : false,
+    "VOLTHA_OLT_MAC": "00:0c:e2:31:12:00",
+    "VOLTHA_HOST": "172.17.0.1",
+    "VOLTHA_OLT_TYPE": "ponsim_olt",
+    "VOLTHA_REST_PORT": 8882,
     "VOLTHA_TEARDOWN": false
-}
\ No newline at end of file
+}
diff --git a/src/test/dhcpl2relay/dhcpl2relayTest.py b/src/test/dhcpl2relay/dhcpl2relayTest.py
index cbaeea8..102ebf7 100644
--- a/src/test/dhcpl2relay/dhcpl2relayTest.py
+++ b/src/test/dhcpl2relay/dhcpl2relayTest.py
@@ -58,7 +58,7 @@
     VOLTHA_OLT_TYPE = 'simulated_olt'
     VOLTHA_OLT_MAC = '00:0c:e2:31:12:00'
     VOLTHA_UPLINK_VLAN_MAP = { 'of:0000000000000001' : '222' }
-
+    TAGGED_TRAFFIC = false
     app = 'org.opencord.dhcpl2relay'
     sadis_app = 'org.opencord.sadis'
     app_dhcp = 'org.onosproject.dhcp'
@@ -255,10 +255,18 @@
         if os.access(lease_file, os.F_OK) is False:
             with open(lease_file, 'w') as fd: pass
 
+        lease_file_tagged = '{}/dhcpd-tagged.leases'.format(cls.dhcp_data_dir)
+        if os.access(lease_file_tagged, os.F_OK) is False:
+            with open(lease_file_tagged, 'w') as fd: pass
+
         conf_file = '{}/dhcpd.conf'.format(cls.dhcp_data_dir)
         with open(conf_file, 'w') as fd:
             fd.write(dhcp_conf)
 
+        conf_file_tagged = '{}/dhcpd-tagged.conf'.format(cls.dhcp_data_dir)
+        with open(conf_file_tagged, 'w') as fd:
+            fd.write(dhcp_conf)
+
         #now configure the dhcpd interfaces for various subnets
         index = 0
         intf_info = []
@@ -283,7 +291,7 @@
         print('Starting DHCPD server with command: %s' %dhcpd_cmd)
         status = os.system(dhcpd_cmd)
         vlan_intf_str = ','.join(vlan_intf_list)
-        dhcpd_cmd = '/usr/sbin/dhcpd -4 --no-pid -cf {0} -lf {1} {2}'.format('/root/test/src/test/setup/dhcpd.conf','/root/test/src/test/setup/dhcpd.leases', vlan_intf_str)
+        dhcpd_cmd = '/usr/sbin/dhcpd -4 --no-pid -cf {0} -lf {1} {2}'.format('/root/test/src/test/setup/dhcpd-tagged.conf','/root/test/src/test/setup/dhcpd-tagged.leases', vlan_intf_str)
         print('Starting DHCPD server with command: %s' %dhcpd_cmd)
         status = os.system(dhcpd_cmd)
         if status > 255:
diff --git a/src/test/utils/CordTestConfig.py b/src/test/utils/CordTestConfig.py
index 8234cf0..34dbb85 100644
--- a/src/test/utils/CordTestConfig.py
+++ b/src/test/utils/CordTestConfig.py
@@ -112,6 +112,10 @@
     if hasattr(class_test, 'VOLTHA_AUTO_CONFIGURE'):
         voltha_configure = getattr(class_test, 'VOLTHA_AUTO_CONFIGURE')
 
+    tagged_traffic = False
+    if hasattr(class_test, 'TAGGED_TRAFFIC'):
+        tagged_traffic = getattr(class_test, 'TAGGED_TRAFFIC')
+
     if hasattr(class_test, 'VOLTHA_HOST'):
         #update the voltha host ip based on chameleon IP for rest interface
         rest_interface = VolthaService.get_ip('chameleon')
@@ -140,7 +144,7 @@
                 setattr(class_test, 'VOLTHA_TEARDOWN', False)
 
     #load the sadis and aaa config
-    OnosCtrl.sadis_load_config(olt_switch_map = olt_switch_map)
+    OnosCtrl.sadis_load_config(olt_switch_map = olt_switch_map, tagged_traffic = tagged_traffic)
     OnosCtrl.aaa_load_config()
     #OnosCtrl('org.opencord.aaa').deactivate()
     #time.sleep(3)
diff --git a/src/test/utils/OnosCtrl.py b/src/test/utils/OnosCtrl.py
index f460450..21dbe74 100644
--- a/src/test/utils/OnosCtrl.py
+++ b/src/test/utils/OnosCtrl.py
@@ -379,7 +379,7 @@
         return switch_map
 
     @classmethod
-    def sadis_load_config(cls, controller = None, olt_switch_map = {}, olt_conf_file = ''):
+    def sadis_load_config(cls, controller = None, olt_switch_map = {}, olt_conf_file = '', tagged_traffic = False):
         sadis_app = 'org.opencord.sadis'
         aaa_app = 'org.opencord.aaa'
         sadis_cfg = {
@@ -417,8 +417,8 @@
                 sadis_entry = dict(nasId = nasId, nasPortId = nasPortId, slot = 1)
                 sadis_entry['id'] = uni_port_names[p]
                 sadis_entry['hardwareIdentifier'] = uni_port_macs[p]
-                sadis_entry['cTag'] = uni_ports[p]
-                sadis_entry['sTag'] = s_tag
+                sadis_entry['cTag'] = uni_ports[p] if tagged_traffic else -1
+                sadis_entry['sTag'] = s_tag if tagged_traffic else -1
                 sadis_entry['port'] = uni_ports[p]
                 sadis_entry['ipAddress'] = controller or cls.controller
                 sadis_entries.append(sadis_entry)
@@ -426,8 +426,8 @@
                 sadis_entry = dict(nasId = nasId, nasPortId = nasPortId, slot = 1)
                 sadis_entry['id']  = serial
                 sadis_entry['hardwareIdentifier'] = cls.device_id_to_mac(device)
-                sadis_entry['cTag'] = uni_ports[p]
-                sadis_entry['sTag'] = s_tag
+                sadis_entry['cTag'] = uni_ports[p] if tagged_traffic else -1
+                sadis_entry['sTag'] = s_tag if tagged_traffic else -1
                 sadis_entry['port'] = uni_ports[p]
                 sadis_entry['ipAddress'] = controller or cls.controller
                 sadis_entries.append(sadis_entry)