Fixes an issue where flow_stats reply in ofagent fails.

When there is no metadata, i.e. it is zero, the write-metadata field
in the of flow_stats_reply should adjust accordingly. Also added some
debug logs for packet-in/out on both sides of grpc channel between
ofagent and core.

Change-Id: I8ad2955ec707947b4c7e0af138bcc0238cf3c4c2
diff --git a/ofagent/converter.py b/ofagent/converter.py
index 1bebc4f..78b48b5 100644
--- a/ofagent/converter.py
+++ b/ofagent/converter.py
@@ -208,8 +208,11 @@
                 actions=[make_loxi_action(a)
                          for a in inst['actions']['actions']])
         elif type == pb2.OFPIT_WRITE_METADATA:
-            return of13.instruction.write_metadata(
-                metadata=inst['write_metadata']['metadata'])
+            if 'metadata' in inst['write_metadata']:
+                return of13.instruction.write_metadata(
+                        metadata=inst['write_metadata']['metadata'])
+            else:
+                return of13.instruction.write_metadata(0)
         elif type == pb2.OFPIT_METER:
             return of13.instruction.meter(
                 meter_id=inst['meter']['meter_id'])