Major rework of gRPC handling (do not merge yet)

Includes the following chages:

* Refactored proto files
  - separation of logical devices vs devices
  - common flow related message types moved to openflow_13
  - most RPC is defined in voltha.proto now
* Expanded RPC definitions to cover now most of what we
  need (a few device provisioning RPCs are still missing)
* Reworked RPC handlers to work with new config tree
* Implemented test cases for all existing RPCs, tested via
  chameleon's REST service
* Did away wih the OrderedDict internal representation
  in the config nodes (3x performance boost on bulk
  add, and negligible penalty in other ops)
* Refactored transacton merge handling to align with
  new structures

Change-Id: I3740ec13b8296943b307782e86e6b596af78140e
diff --git a/protoc_plugins/gw_gen.py b/protoc_plugins/gw_gen.py
index 4596bef..c5a8875 100755
--- a/protoc_plugins/gw_gen.py
+++ b/protoc_plugins/gw_gen.py
@@ -32,7 +32,9 @@
 
 from simplejson import dumps, load
 from structlog import get_logger
-from protobuf_to_dict import protobuf_to_dict, dict_to_protobuf
+from protobuf_to_dict import dict_to_protobuf
+from google.protobuf.json_format import MessageToDict
+from twisted.internet.defer import inlineCallbacks, returnValue
 
 {% set package = file_name.replace('.proto', '') %}
 
@@ -54,6 +56,7 @@
     {% set method_name = method['service'].rpartition('.')[2] + '_' + method['method'] %}
     {% set path = method['path'].replace('{', '<string:').replace('}', '>') %}
     @app.route('{{ path }}', methods=['{{ method['verb'].upper() }}'])
+    @inlineCallbacks
     def {{ method_name }}(server, request, **kw):
         log.debug('{{ method_name }}', request=request, server=server, **kw)
         {% if method['body'] == '*' %}
@@ -69,11 +72,11 @@
         except Exception, e:
             log.error('cannot-convert-to-protobuf', e=e, data=data)
             raise
-        res = grpc_client.invoke(
+        res = yield grpc_client.invoke(
             {{ type_map[method['service']] }}Stub,
             '{{ method['method'] }}', req)
         try:
-            out_data = protobuf_to_dict(res, use_enum_labels=True)
+            out_data = MessageToDict(res, True, True)
         except AttributeError, e:
             filename = '/tmp/chameleon_failed_to_convert_data.pbd'
             with file(filename, 'w') as f:
@@ -82,7 +85,7 @@
             raise
         request.setHeader('Content-Type', 'application/json')
         log.debug('{{ method_name }}', **out_data)
-        return dumps(out_data)
+        returnValue(dumps(out_data))
 
     {% endfor %}