VOL-1478 Update statistics manager to get serial from the device rather than polling the core
Change-Id: I71af6e50fe2f99effc3c446f35bcaed309d858be
diff --git a/pyvoltha/adapters/extensions/kpi/adapter_pm_metrics.py b/pyvoltha/adapters/extensions/kpi/adapter_pm_metrics.py
index 982f11d..4ff55c7 100644
--- a/pyvoltha/adapters/extensions/kpi/adapter_pm_metrics.py
+++ b/pyvoltha/adapters/extensions/kpi/adapter_pm_metrics.py
@@ -37,7 +37,7 @@
# for collection.
TIMESTAMP_ATTRIBUTE = 'timestamp'
- def __init__(self, core_proxy, device_id, logical_device_id,
+ def __init__(self, core_proxy, device_id, logical_device_id, serial_number,
grouped=False, freq_override=False, **kwargs):
"""
Initializer for shared Device Adapter PM metrics manager
@@ -55,9 +55,7 @@
self.core_proxy = core_proxy
self.name = core_proxy.listening_topic
self.logical_device_id = logical_device_id
- device = yield self.core_proxy.get_device(self.device_id)
- self.serial_number = device.serial_number
-
+ self.serial_number = serial_number
self.default_freq = kwargs.get(AdapterPmMetrics.DEFAULT_FREQUENCY_KEY,
AdapterPmMetrics.DEFAULT_COLLECTION_FREQUENCY)
self.grouped = grouped
@@ -205,7 +203,7 @@
ts=arrow.utcnow().float_timestamp,
slice_data=data
)
- self.adapter_agent.submit_kpis(kpi_event)
+ self.core_proxy.submit_kpis(kpi_event)
except Exception as e:
self.log.exception('failed-to-submit-kpis', e=e)
diff --git a/pyvoltha/adapters/extensions/kpi/olt/olt_pm_metrics.py b/pyvoltha/adapters/extensions/kpi/olt/olt_pm_metrics.py
index 4ebaa8d..ee0a4e9 100644
--- a/pyvoltha/adapters/extensions/kpi/olt/olt_pm_metrics.py
+++ b/pyvoltha/adapters/extensions/kpi/olt/olt_pm_metrics.py
@@ -24,7 +24,7 @@
specific PM (OMCI, PON, UNI) is supported in encapsulated classes accessible
from this object
"""
- def __init__(self, core_proxy, device_id, logical_device_id,
+ def __init__(self, core_proxy, device_id, logical_device_id, serial_number,
grouped=False, freq_override=False, **kwargs):
"""
Initializer for shared ONU Device Adapter PM metrics
@@ -42,7 +42,7 @@
'nni-ports': List of objects that provide NNI (northbound) port statistics
'pon-ports': List of objects that provide PON port statistics
"""
- super(OltPmMetrics, self).__init__(core_proxy, device_id, logical_device_id,
+ super(OltPmMetrics, self).__init__(core_proxy, device_id, logical_device_id, serial_number,
grouped=grouped, freq_override=freq_override,
**kwargs)
diff --git a/pyvoltha/adapters/kafka/core_proxy.py b/pyvoltha/adapters/kafka/core_proxy.py
index 2176778..58313e0 100644
--- a/pyvoltha/adapters/kafka/core_proxy.py
+++ b/pyvoltha/adapters/kafka/core_proxy.py
@@ -30,7 +30,8 @@
from voltha_protos.voltha_pb2 import CoreInstance, AlarmFilterRuleKey
from voltha_protos.events_pb2 import AlarmEvent, AlarmEventType, \
AlarmEventState, AlarmEventCategory, AlarmEventSeverity
-
+from voltha_protos.events_pb2 import KpiEvent2, KpiEventType, MetricInformation, MetricMetaData
+
log = structlog.get_logger()
@@ -527,4 +528,14 @@
returnValue(res)
except Exception as e:
log.exception('failed-alarm-submission',
- type=type(alarm_event_msg), e=e)
\ No newline at end of file
+ type=type(alarm_event_msg), e=e)
+
+ @inlineCallbacks
+ def submit_kpis(self, kpi_event_msg):
+ try:
+ assert isinstance(kpi_event_msg, KpiEvent2)
+ res = yield self.kafka_proxy._send_kafka_message('kpis', kpi_event_msg)
+ returnValue(res)
+ except Exception as e:
+ log.exception('failed-kpis-submission',
+ type=type(kpi_event_msg), e=e)