SEBA-319 Add parent information to context of Ethernet_Bridge_Port_History

Change-Id: I911fa2cce35c26a8b3ecab248a45f8cec5a51462
diff --git a/voltha/extensions/kpi/onu/onu_pm_interval_metrics.py b/voltha/extensions/kpi/onu/onu_pm_interval_metrics.py
index 46d0e2a..bf6ac03 100644
--- a/voltha/extensions/kpi/onu/onu_pm_interval_metrics.py
+++ b/voltha/extensions/kpi/onu/onu_pm_interval_metrics.py
@@ -63,6 +63,9 @@
             ('class_id', PmConfig.CONTEXT),
             ('entity_id', PmConfig.CONTEXT),
             ("interval_end_time", PmConfig.CONTEXT),
+            ('parent_class_id', PmConfig.CONTEXT),
+            ('parent_entity_id', PmConfig.CONTEXT),
+            ('upstream', PmConfig.CONTEXT),
 
             ("drop_events", PmConfig.COUNTER),
             ("octets", PmConfig.COUNTER),
diff --git a/voltha/extensions/omci/state_machines/performance_intervals.py b/voltha/extensions/omci/state_machines/performance_intervals.py
index 486eba8..8144a56 100644
--- a/voltha/extensions/omci/state_machines/performance_intervals.py
+++ b/voltha/extensions/omci/state_machines/performance_intervals.py
@@ -158,6 +158,7 @@
 
         # (Class ID, Instance ID) -> Collect attempts remaining
         self._pm_me_collect_retries = dict()
+        self._pm_me_extended_info = dict()
         self._add_pm_me = dict()        # (pm cid, pm eid) -> (me cid, me eid, upstream)
         self._del_pm_me = set()
 
@@ -503,6 +504,7 @@
             # an already-exists status code which we consider successful
             for pm, me in mes.items():
                 self._pm_me_collect_retries[pm] = self.pm_collected(pm)
+                self._pm_me_extended_info[pm] = me
 
             self._current_task = None
             self._deferred = reactor.callLater(0, self.success)
@@ -598,8 +600,23 @@
 
                 # start the task
                 self.log.info('collect-task-start')
+
+                if key in self._pm_me_extended_info:
+                    self.log.debug('collect-extended-info-found', key=key, extended_info=self._pm_me_extended_info[key])
+                    parent_class_id = self._pm_me_extended_info[key][0]
+                    parent_entity_id = self._pm_me_extended_info[key][1]
+                    upstream = self._pm_me_extended_info[key][2]
+                else:
+                    self.log.debug('collect-extended-info-not-found', key=key)
+                    parent_class_id = None
+                    parent_entity_id = None
+                    upstream = None
+
                 self._current_task = self._get_interval_task(self._agent, self._device_id,
-                                                             class_id, entity_id)
+                                                             class_id, entity_id,
+                                                             parent_class_id=parent_class_id,
+                                                             parent_entity_id=parent_entity_id,
+                                                             upstream=upstream)
                 self._task_deferred = self._device.task_runner.queue_task(self._current_task)
                 self._task_deferred.addCallbacks(success, failure)
                 self._task_deferred.addCallback(self.publish_data)
diff --git a/voltha/extensions/omci/tasks/interval_data_task.py b/voltha/extensions/omci/tasks/interval_data_task.py
index 9475cd8..369f817 100644
--- a/voltha/extensions/omci/tasks/interval_data_task.py
+++ b/voltha/extensions/omci/tasks/interval_data_task.py
@@ -34,7 +34,10 @@
     max_payload = 29
 
     def __init__(self, omci_agent, device_id, class_id, entity_id,
-                 max_get_response_payload=max_payload):
+                 max_get_response_payload=max_payload,
+                 parent_class_id=None,
+                 parent_entity_id=None,
+                 upstream=None):
         """
         Class initialization
 
@@ -54,6 +57,10 @@
         self._class_id = class_id
         self._entity_id = entity_id
 
+        self._parent_class_id = parent_class_id
+        self._parent_entity_id = parent_entity_id
+        self._upstream = upstream
+
         me_map = self.omci_agent.get_device(self.device_id).me_map
         if self._class_id not in me_map:
             msg = "The requested ME Class () does not exist in the ONU's ME Map".format(self._class_id)
@@ -116,6 +123,9 @@
             'entity_id': self._entity_id,
             'me_name': self._entity.__name__,   # Mostly for debugging...
             'interval_utc_time': None,
+            'parent_class_id': self._parent_class_id,
+            'parent_entity_id': self._parent_entity_id,
+            'upstream': self._upstream
             # Counters added here as they are retrieved
         }
         last_end_time = None