Replaced references to adapter_agent

Change-Id: Ic1cf6326f8799e8ce5f4c9293efb3b1701ffe7ce
diff --git a/pyvoltha/adapters/extensions/kpi/README.md b/pyvoltha/adapters/extensions/kpi/README.md
index a55c7d2..43d72bb 100644
--- a/pyvoltha/adapters/extensions/kpi/README.md
+++ b/pyvoltha/adapters/extensions/kpi/README.md
@@ -29,7 +29,7 @@
 2. Create the ProtoBuf message for your metrics by calling the newly created _manager's_
    **_make_proto_**() method. 
    
-3. Register the ProtoBuf message configuration with the adapter agent via the 
+3. Register the ProtoBuf message configuration with the core_proxy via the 
    _update_device_pm_config_() method with the optional init parameter set to **True**.
    
 4. Request the manager to schedule the first PM collection interval by calling the
@@ -51,7 +51,7 @@
         'nni-ports': self.northbound_ports.values(),
         'pon-ports': self.southbound_ports.values()
     }
-    self.pm_metrics = OltPmMetrics(self.adapter_agent, self.device_id, self.logical_device_id,
+    self.pm_metrics = OltPmMetrics(self.core_proxy, self.device_id, self.logical_device_id,
                                    grouped=True, freq_override=False,
                                    **kwargs)
 
@@ -59,8 +59,8 @@
     pm_config = self.pm_metrics.make_proto()
     self.log.debug("initial-pm-config", pm_config=pm_config)
     
-    # Create the PM information in the adapter agent
-    self.adapter_agent.update_device_pm_config(pm_config, init=True)
+    # Create the PM information in the core_proxy
+    self.core_proxy.update_device_pm_config(pm_config, init=True)
         
     # Start collecting stats from the device after a brief pause
     reactor.callLater(10, self.pm_metrics.start_collector)
@@ -80,7 +80,7 @@
         'heartbeat': self.heartbeat,
         'omci-cc': self.openomci.omci_cc
     }
-    self.pm_metrics = OnuPmMetrics(self.adapter_agent, self.device_id, self.logical_device_id,
+    self.pm_metrics = OnuPmMetrics(self.core_proxy, self.device_id, self.logical_device_id,
                                    grouped=True, freq_override=False,
                                    **kwargs)
                                    
@@ -90,8 +90,8 @@
     # Register the OMCI history intervals with OpenOMCI
     self.openomci.set_pm_config(self.pm_metrics.omci_pm.openomci_interval_pm)
     
-    # Create the PM information in the adapter agent
-    self.adapter_agent.update_device_pm_config(pm_config, init=True)
+    # Create the PM information in the core_proxy
+    self.core_proxy.update_device_pm_config(pm_config, init=True)
     
     # Start collecting stats from the device after a brief pause
     reactor.callLater(30, self.pm_metrics.start_collector)
diff --git a/pyvoltha/adapters/extensions/kpi/onu/onu_omci_pm.py b/pyvoltha/adapters/extensions/kpi/onu/onu_omci_pm.py
index 98c1129..5ef706c 100644
--- a/pyvoltha/adapters/extensions/kpi/onu/onu_omci_pm.py
+++ b/pyvoltha/adapters/extensions/kpi/onu/onu_omci_pm.py
@@ -41,12 +41,12 @@
     DEFAULT_UNI_STATUS_ENABLED = True
     DEFAULT_UNI_STATUS_FREQUENCY = (15 * 60 * 10)
 
-    def __init__(self, adapter_agent, device_id, logical_device_id,
+    def __init__(self, core_proxy, device_id, logical_device_id,
                  grouped=False, freq_override=False, **kwargs):
         """
         Initializer for shared ONU Device Adapter OMCI CC PM metrics
 
-        :param adapter_agent: (AdapterAgent) Adapter agent for the device
+        :param core_proxy: (CoreProxy) Core proxy for the device
         :param device_id: (str) Device ID
         :param logical_device_id: (str) VOLTHA Logical Device ID
         :param grouped: (bool) Flag indicating if statistics are managed as a group
@@ -60,7 +60,7 @@
                                          retrieval of OpenOMCI Communications channel statistics
                                          and retrieval of polled statistics.
         """
-        super(OnuOmciPmMetrics, self).__init__(adapter_agent, device_id, logical_device_id,
+        super(OnuOmciPmMetrics, self).__init__(core_proxy, device_id, logical_device_id,
                                                grouped=grouped, freq_override=freq_override,
                                                **kwargs)
 
@@ -108,7 +108,7 @@
         self.omci_uni_metrics_config = {m: PmConfig(name=m, type=t, enabled=True)
                                         for (m, t) in self.omci_uni_pm_names}
 
-        self.openomci_interval_pm = OnuPmIntervalMetrics(adapter_agent, device_id, logical_device_id)
+        self.openomci_interval_pm = OnuPmIntervalMetrics(core_proxy, device_id, logical_device_id)
 
     def update(self, pm_config):
         # TODO: Test frequency override capability for a particular group
diff --git a/pyvoltha/adapters/extensions/kpi/onu/onu_pm_interval_metrics.py b/pyvoltha/adapters/extensions/kpi/onu/onu_pm_interval_metrics.py
index 8b7bf79..5353f1b 100644
--- a/pyvoltha/adapters/extensions/kpi/onu/onu_pm_interval_metrics.py
+++ b/pyvoltha/adapters/extensions/kpi/onu/onu_pm_interval_metrics.py
@@ -13,6 +13,7 @@
 # limitations under the License.
 
 import arrow
+from twisted.internet.defer import inlineCallbacks, returnValue 
 from voltha_protos.device_pb2 import PmConfig, PmGroupConfig
 from voltha_protos.events_pb2 import KpiEvent2, MetricInformation, MetricMetaData, KpiEventType
 from pyvoltha.adapters.extensions.kpi.adapter_pm_metrics import AdapterPmMetrics
@@ -55,8 +56,8 @@
     XGPON_DOWNSTREAM_HISTORY = False
     XGPON_UPSTREAM_HISTORY = False
 
-    def __init__(self, adapter_agent, device_id, logical_device_id, **kwargs):
-        super(OnuPmIntervalMetrics, self).__init__(adapter_agent, device_id, logical_device_id,
+    def __init__(self, core_proxy, device_id, logical_device_id, **kwargs):
+        super(OnuPmIntervalMetrics, self).__init__(core_proxy, device_id, logical_device_id,
                                                    grouped=True, freq_override=False,
                                                    **kwargs)
         ethernet_bridge_history = {
@@ -324,6 +325,7 @@
 
         return pm_config
 
+    @inlineCallbacks
     def publish_metrics(self, interval_data):
         """
         Collect the metrics for this ONU PM Interval
@@ -377,7 +379,7 @@
                     kpi_event = KpiEvent2(type=KpiEventType.slice,
                                           ts=now.float_timestamp,
                                           slice_data=slice_data)
-                    self.adapter_agent.submit_kpis(kpi_event)
+                    yield 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/onu/onu_pm_metrics.py b/pyvoltha/adapters/extensions/kpi/onu/onu_pm_metrics.py
index 9402ae9..eaf0232 100644
--- a/pyvoltha/adapters/extensions/kpi/onu/onu_pm_metrics.py
+++ b/pyvoltha/adapters/extensions/kpi/onu/onu_pm_metrics.py
@@ -35,12 +35,12 @@
     # the KPI shared library supports individual collection.
     DEFAULT_ONU_COLLECTION_FREQUENCY = 60 * 10      # 1 minute
 
-    def __init__(self, adapter_agent, device_id, logical_device_id,
+    def __init__(self, core_proxy, device_id, logical_device_id,
                  grouped=False, freq_override=False, **kwargs):
         """
         Initializer for shared ONU Device Adapter PM metrics
 
-        :param adapter_agent: (AdapterAgent) Adapter agent for the device
+        :param core_proxy: (CoreProxy) Core proxy for the device
         :param device_id: (str) Device ID
         :param logical_device_id: (str) VOLTHA Logical Device ID
         :param grouped: (bool) Flag indicating if statistics are managed as a group
@@ -53,7 +53,7 @@
                               'heartbeat': Reference to the a class that provides an ONU heartbeat
                                            statistics.   TODO: This should be standardized across adapters
         """
-        super(OnuPmMetrics, self).__init__(adapter_agent, device_id, logical_device_id,
+        super(OnuPmMetrics, self).__init__(core_proxy, device_id, logical_device_id,
                                            grouped=grouped, freq_override=freq_override,
                                            **kwargs)
 
@@ -77,7 +77,7 @@
         self.health_metrics_config = {m: PmConfig(name=m, type=t, enabled=True)
                                       for (m, t) in self.health_pm_names}
 
-        self.omci_pm = OnuOmciPmMetrics(adapter_agent, device_id, logical_device_id,
+        self.omci_pm = OnuOmciPmMetrics(core_proxy, device_id, logical_device_id,
                                         grouped=grouped, freq_override=freq_override,
                                         **kwargs)