[VOL-1698] OMCI PM does not work

Pass ONU's serial number to OnuPmMetrics, fix update_device to device_update

Change-Id: Iccfebdd83384dba18724c3739a921bc5952e1c48
diff --git a/python/adapters/brcm_openomci_onu/brcm_openomci_onu_handler.py b/python/adapters/brcm_openomci_onu/brcm_openomci_onu_handler.py
index ca6c7ef..82b6c90 100644
--- a/python/adapters/brcm_openomci_onu/brcm_openomci_onu_handler.py
+++ b/python/adapters/brcm_openomci_onu/brcm_openomci_onu_handler.py
@@ -240,9 +240,10 @@
                 'heartbeat': self.heartbeat,
                 OnuOmciPmMetrics.OMCI_DEV_KEY: self._onu_omci_device
             }
+            self.log.debug('create-OnuPmMetrics', serial_number=device.serial_number)
             self.pm_metrics = OnuPmMetrics(self.core_proxy, self.device_id,
-                                           self.logical_device_id, grouped=True,
-                                           freq_override=False, **kwargs)
+                                           self.logical_device_id, device.serial_number,
+                                           grouped=True, freq_override=False, **kwargs)
             pm_config = self.pm_metrics.make_proto()
             self._onu_omci_device.set_pm_config(self.pm_metrics.omci_pm.openomci_interval_pm)
             self.log.info("initial-pm-config", pm_config=pm_config)
@@ -250,7 +251,8 @@
 
             ############################################################################
             # Setup Alarm handler
-            self.alarms = AdapterAlarms(self.core_proxy, device.id, self.logical_device_id)
+            self.alarms = AdapterAlarms(self.core_proxy, device.id, self.logical_device_id,
+                                        device.serial_number)
             # Note, ONU ID and UNI intf set in add_uni_port method
             self._onu_omci_device.alarm_synchronizer.set_alarm_params(mgr=self.alarms,
                                                                       ani_ports=[self._pon])
diff --git a/python/adapters/brcm_openomci_onu/heartbeat.py b/python/adapters/brcm_openomci_onu/heartbeat.py
index 13f1d62..ffe4b69 100644
--- a/python/adapters/brcm_openomci_onu/heartbeat.py
+++ b/python/adapters/brcm_openomci_onu/heartbeat.py
@@ -14,6 +14,7 @@
 
 import structlog
 from twisted.internet import reactor
+from twisted.internet.defer import inlineCallbacks
 from voltha_protos.common_pb2 import OperStatus, ConnectStatus
 from pyvoltha.adapters.extensions.omci.omci_me import OntGFrame
 
@@ -138,6 +139,7 @@
         #  TODO: If failed (active = true) due to bad serial-number shut off the UNI port?
         pass
 
+    @inlineCallbacks
     def heartbeat_check_status(self, results):
         """
         Check the number of heartbeat failures against the limit and emit an alarm if needed
@@ -153,7 +155,7 @@
                     device.connect_status = ConnectStatus.UNREACHABLE
                     device.oper_status = OperStatus.FAILED
                     device.reason = self.heartbeat_last_reason
-                    self._handler.core_proxy.update_device(device)
+                    yield self._handler.core_proxy.device_update(device)
                     HeartbeatAlarm(self._handler.alarms, 'onu', self._heartbeat_miss).raise_alarm()
                     self._alarm_active = True
                     self.on_heartbeat_alarm(True)
@@ -163,7 +165,7 @@
                     device.connect_status = ConnectStatus.REACHABLE
                     device.oper_status = OperStatus.ACTIVE
                     device.reason = ''
-                    self._handler.core_proxy.update_device(device)
+                    yield self._handler.core_proxy.device_update(device)
                     HeartbeatAlarm(self._handler.alarms, 'onu').clear_alarm()
 
                     self._alarm_active = False
diff --git a/python/adapters/brcm_openomci_onu/omci/brcm_mib_download_task.py b/python/adapters/brcm_openomci_onu/omci/brcm_mib_download_task.py
index 7116364..d159a23 100644
--- a/python/adapters/brcm_openomci_onu/omci/brcm_mib_download_task.py
+++ b/python/adapters/brcm_openomci_onu/omci/brcm_mib_download_task.py
@@ -181,7 +181,7 @@
 
             if self._handler.enabled and len(self._handler.uni_ports) > 0:
                 device.reason = 'performing-initial-mib-download'
-                yield self._handler.core_proxy.update_device(device)
+                yield self._handler.core_proxy.device_update(device)
 
             try:
                 # Lock the UNI ports to prevent any alarms during initial configuration