VOL-853: Adtran ONU fix for custom ME entries if multiple ADTN ONUs

Change-Id: Idc56f9f6bd8e0e703d46ffe861c07c3f6fb87552
diff --git a/voltha/adapters/adtran_onu/omci/omci_entities.py b/voltha/adapters/adtran_onu/omci/omci_entities.py
index 6cef5ee..e982ee7 100644
--- a/voltha/adapters/adtran_onu/omci/omci_entities.py
+++ b/voltha/adapters/adtran_onu/omci/omci_entities.py
@@ -17,7 +17,7 @@
 import inspect
 
 import sys
-from scapy.fields import ShortField
+from scapy.fields import ShortField, IntField, ByteField, StrFixedLenField
 from voltha.extensions.omci.omci_entities import EntityClassAttribute, \
     AttributeAccess, EntityOperations, EntityClass
 
@@ -31,6 +31,7 @@
     class_id = 65300
     attributes = [
         ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
+        ECA(StrFixedLenField("time_of_day", None, 8), {AA.R, AA.W}),
     ]
     mandatory_operations = {OP.Get}
 
@@ -39,22 +40,38 @@
     class_id = 65400
     attributes = [
         ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
+        ECA(IntField("supported_specification_version", None), {AA.R}),
+        ECA(ShortField("pon_device_type", None), {AA.R}),
+        ECA(IntField("specification_in_use", None), {AA.R, AA.W})
     ]
-    mandatory_operations = {OP.Get}
+    mandatory_operations = {OP.Get, OP.Set}
 
 
 class TwdmSystemProfile(EntityClass):
     class_id = 65401
     attributes = [
         ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
+        ECA(ByteField("total_twdm_channel_number", None), {AA.R}),
+        ECA(ByteField("channel_partition_index", None), {AA.R, AA.W}),
+        ECA(IntField("channel_partion_waiver_timer", None), {AA.R, AA.W}),
+        ECA(IntField("lods_re_initialization_timer", None), {AA.R, AA.W}),
+        ECA(IntField("lods_protection_timer", None), {AA.R, AA.W}),
+        ECA(IntField("downstream_tuning_timer", None), {AA.R, AA.W}),
+        ECA(IntField("upstream_tuning_timer", None), {AA.R, AA.W}),
+        ECA(StrFixedLenField("location_label_1", None, 24), {AA.R, AA.W}),
+        ECA(StrFixedLenField("location_label_2", None, 24), {AA.R, AA.W}),
     ]
-    mandatory_operations = {OP.Get}
+    mandatory_operations = {OP.Get, OP.Set}
 
 
 class TwdmChannel(EntityClass):
     class_id = 65402
     attributes = [
         ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
+        ECA(ByteField("active_channel_indication", None), {AA.R}),
+        ECA(ByteField("operational_channel_indication", None), {AA.R}),
+        ECA(ByteField("downstream_wavelength_channel", None), {AA.R}),
+        ECA(ByteField("upstream_wavelength_channel", None), {AA.R}),
     ]
     mandatory_operations = {OP.Get}
 
@@ -63,24 +80,52 @@
     class_id = 65403
     attributes = [
         ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
+        ECA(IntField("upstream_transmission_timing_drift_self_monitoring_capability", None), {AA.R}),
+        ECA(IntField("upstream_transmission_wavelength_drift_self_monitoring_capability", None), {AA.R}),
+        ECA(IntField("upstream_transmission_optical_power_self_monitoring_capability", None), {AA.R}),
+        ECA(IntField("mean_out_of_channel_optical_power_spectral_density_self_monitoring_capability", None), {AA.R}),
+        ECA(IntField("mean_optical_power_spectral_density_self_monitoring_capability", None), {AA.R}),
     ]
     mandatory_operations = {OP.Get}
 
 
-class FCPortalOrSraStat(EntityClass):
+class FlexibleConfigurationStatusPortal(EntityClass):
     class_id = 65420
     attributes = [
         ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
+        ECA(IntField("service_instance", None), {AA.R, AA.W}),
+        ECA(ShortField("configuration_method", None), {AA.R, AA.W}),
+        ECA(ShortField("network_address", None), {AA.R, AA.W}),
+        ECA(ByteField("administrative_state", None), {AA.R, AA}),
+        ECA(ByteField("operational_state", None), {AA.R}, avc=True),
+        ECA(ShortField("cause_for_last_abnormal_halt", None), {AA.R}),
+        ECA(ShortField("configuration_portal_update_available", None), {AA.R, AA.W}),
+        ECA(StrFixedLenField("configuration_portal_table", None, 25), {AA.R, AA.W}),
+        ECA(ByteField("configuration_portal_result", None), {AA.R, AA.W}, avc=True),
+        ECA(ShortField("status_message_available", None), {AA.R, AA.W}, avc=True),
+        ECA(ByteField("status_message", None), {AA.R, AA.W}),
+        ECA(ByteField("status_message_result", None), {AA.R, AA.W}),
+        ECA(ShortField("associated_me_class", None), {AA.R}),
+        ECA(ShortField("associated_me_class_instance", None), {AA.R}),
     ]
-    mandatory_operations = {OP.Get, OP.Set, OP.Create, OP.Delete}
+    mandatory_operations = {OP.Get, OP.Set, OP.Create, OP.Delete, OP.GetNext, OP.SetTable}
 
 
-class Onu3gOrInvStat2(EntityClass):
+class Onu3G(EntityClass):
     class_id = 65422
     attributes = [
         ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
+        ECA(ByteField("flash_memory_performance_value", None), {AA.R}),
+        ECA(ByteField("latest_restart_reason", None), {AA.R}),
+        ECA(ShortField("total_number_of_status_snapshots", None), {AA.R}),
+        ECA(ShortField("number_of_valid_status_snapshots", None), {AA.R}),
+        ECA(ShortField("next_status_snapshot_index", None), {AA.R}),
+        ECA(ByteField("status_snapshot_record_table", None), {AA.R}),      # TODO: MxN field
+        ECA(ByteField("snap_action", None), {AA.W}),
+        ECA(ByteField("most_recent_status_snapshot", None), {AA.R}),        # TODO: N field
+        ECA(ByteField("reset_action", None), {AA.W}),
     ]
-    mandatory_operations = {OP.Set, OP.Get, OP.Create, OP.Delete}
+    mandatory_operations = {OP.Get, OP.Set, OP.GetNext}
 
 
 #################################################################################
@@ -94,10 +139,11 @@
 
 
 def onu_custom_me_entities():
-    for entity_class in _onu_custom_entity_classes:
-        assert entity_class.class_id not in _onu_custom_entity_id_to_class_map, \
-            "Class ID '{}' already exists in the class map".format(entity_class.class_id)
-        _onu_custom_entity_id_to_class_map[entity_class.class_id] = entity_class
+    if len(_onu_custom_entity_id_to_class_map) == 0:
+        for entity_class in _onu_custom_entity_classes:
+            assert entity_class.class_id not in _onu_custom_entity_id_to_class_map, \
+                "Class ID '{}' already exists in the class map".format(entity_class.class_id)
+            _onu_custom_entity_id_to_class_map[entity_class.class_id] = entity_class
 
     return _onu_custom_entity_id_to_class_map