VOL-2462 Do not produce PON_Optical PMs faster than group_freq

Change-Id: I01dea253e247a2441f3613b4b810b25a53a182c9
diff --git a/VERSION b/VERSION
index e75da3e..c2417c3 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.3.6
+2.3.7-dev
diff --git a/pyvoltha/adapters/extensions/events/kpi/adapter_pm_metrics.py b/pyvoltha/adapters/extensions/events/kpi/adapter_pm_metrics.py
index 9f41f90..34cff6e 100644
--- a/pyvoltha/adapters/extensions/events/kpi/adapter_pm_metrics.py
+++ b/pyvoltha/adapters/extensions/events/kpi/adapter_pm_metrics.py
@@ -82,7 +82,7 @@
 
         :param callback: (callable) Function to call to collect PM data
         """
-        self.log.info("starting-pm-collection", device_name=self.name)
+        self.log.info("starting-pm-collection", device_name=self.name, default_freq=self.default_freq)
         if callback is None:
             callback = self.collect_and_publish_metrics
 
diff --git a/pyvoltha/adapters/extensions/events/kpi/onu/onu_omci_pm.py b/pyvoltha/adapters/extensions/events/kpi/onu/onu_omci_pm.py
index 11f45cd..b95dae3 100644
--- a/pyvoltha/adapters/extensions/events/kpi/onu/onu_omci_pm.py
+++ b/pyvoltha/adapters/extensions/events/kpi/onu/onu_omci_pm.py
@@ -112,6 +112,8 @@
         self.openomci_interval_pm = OnuPmIntervalMetrics(event_mgr, core_proxy, device_id, logical_device_id,
                                                          serial_number)
 
+        self.last_collect_optical_metrics = None
+
     def update(self, pm_config):
         # TODO: Test frequency override capability for a particular group
         if self.default_freq != pm_config.default_freq:
@@ -221,6 +223,15 @@
         if now is None or not self.pm_group_metrics[group_name].enabled:
             return []
 
+        # Because several different metrics are collected by this class,
+        # and the collection interval may be more often than the group interval,
+        # check and make sure these metrics are actually due at this time.
+        if self.last_collect_optical_metrics:
+            elapsed_tenths = (now-self.last_collect_optical_metrics)*10
+            if elapsed_tenths < self.pm_group_metrics[group_name].group_freq:
+                self.log.info("collect-optical-metrics-not-time-yet", elapsed_tenths=elapsed_tenths)
+                return []
+
         # Scan all ANI-G ports
         ani_g_entities = self._omci_onu_device.configuration.ani_g_entities
         ani_g_entities_ids = list(ani_g_entities.keys()) if ani_g_entities is not None else None
@@ -254,6 +265,8 @@
                                                     metrics=metrics)
                     metrics_info.append(metric_data)
 
+        self.last_collect_optical_metrics = now
+
         return metrics_info
 
     def collect_uni_status_metrics(self):
diff --git a/pyvoltha/adapters/extensions/omci/tasks/omci_test_request.py b/pyvoltha/adapters/extensions/omci/tasks/omci_test_request.py
index 8176bc4..a7020ee 100644
--- a/pyvoltha/adapters/extensions/omci/tasks/omci_test_request.py
+++ b/pyvoltha/adapters/extensions/omci/tasks/omci_test_request.py
@@ -134,7 +134,7 @@
 
                 :param callback: (callable) Function to call to collect PM data
         """
-        self.log.info("starting-pm-collection", device_name=self.name)
+        self.log.info("starting-pm-collection", device_name=self.name, default_freq=self.default_freq)
         if callback is None:
             callback = self.perform_test_omci