733: Insert the description of the change.Need to support Error Checking for consistency – if Meter Reference made then need Meter to exist first before reference.

If Flow Table ID does not resolve to a Technology Profile in KV Store generate an error – initial approach to simplify implementation - the Technology for the Profile will not be used to qualify the lookup.

Initially just do OF agent checks which do not need knowledge available in the adapter i.e. Meter Band Reference requires Meter Band definition first. Any Forward References need error checks (OF Error messages).

OF Agent needs to pass through the Meter/Meter Band programming and the Flow Table ID used to reference the Technology Profile.

The VOLTHA core needs to be able to receive meters from the OFAgent and store them in the appropriate logical device. A new northbound API needs to be added to the core to support this.

Change-Id: Ide776dbcbc04232c1d929a85707fec09e3dedf6f
diff --git a/ofagent/grpc_client.py b/ofagent/grpc_client.py
index ab9417b..f4fc6df 100644
--- a/ofagent/grpc_client.py
+++ b/ofagent/grpc_client.py
@@ -27,7 +27,7 @@
 from twisted.internet import threads
 from twisted.internet.defer import inlineCallbacks, returnValue, DeferredQueue
 
-from protos.voltha_pb2 import ID, VolthaLocalServiceStub, FlowTableUpdate, \
+from protos.voltha_pb2 import ID, VolthaLocalServiceStub, FlowTableUpdate, MeterModUpdate, \
     FlowGroupTableUpdate, PacketOut
 from protos.logical_device_pb2 import LogicalPortId
 from google.protobuf import empty_pb2
@@ -204,6 +204,16 @@
         returnValue(res)
 
     @inlineCallbacks
+    def update_meter_mod_table(self, device_id, meter_mod):
+        req = MeterModUpdate(
+            id=device_id,
+            meter_mod=meter_mod
+        )
+        res = yield threads.deferToThread(
+            self.local_stub.UpdateLogicalDeviceMeterTable, req)
+        returnValue(res)
+
+    @inlineCallbacks
     def update_group_table(self, device_id, group_mod):
         req = FlowGroupTableUpdate(
             id=device_id,
@@ -252,3 +262,11 @@
         res = yield threads.deferToThread(
             self.local_stub.Subscribe, subscriber, timeout=self.grpc_timeout)
         returnValue(res)
+
+
+    @inlineCallbacks
+    def get_meter_stats(self, device_id):
+        req = ID(id=device_id)
+        res = yield threads.deferToThread(
+            self.local_stub.GetMeterStatsOfLogicalDevice, req)
+        returnValue(res.items)