SEBA-345: Upgrade to current gRPC and Protobuf libs
Change-Id: I7167a0a490e38cb40b8bd37da81bf78a8e3a86ea
diff --git a/alarm-generator/main.py b/alarm-generator/main.py
index ce0f703..bb3fa69 100644
--- a/alarm-generator/main.py
+++ b/alarm-generator/main.py
@@ -46,7 +46,7 @@
from google.protobuf.empty_pb2 import Empty
from voltha.protos import third_party
-from voltha.protos import voltha_pb2, common_pb2
+from voltha.protos import voltha_pb2, voltha_pb2_grpc, common_pb2
defs = dict(
# config=os.environ.get('CONFIG', './cli.yml'),
@@ -90,9 +90,9 @@
def get_stub(self):
if self.stub is None:
self.stub = \
- voltha_pb2.VolthaGlobalServiceStub(self.get_channel()) \
+ voltha_pb2_grpc.VolthaGlobalServiceStub(self.get_channel()) \
if self.global_request else \
- voltha_pb2.VolthaLocalServiceStub(self.get_channel())
+ voltha_pb2_grpc.VolthaLocalServiceStub(self.get_channel())
return self.stub
def get_first_olt_device_id(self):
diff --git a/cli/main.py b/cli/main.py
index 6ca318a..fa3b1d4 100755
--- a/cli/main.py
+++ b/cli/main.py
@@ -36,7 +36,7 @@
from cli.table import print_pb_list_as_table
from voltha.core.flow_decomposer import *
from voltha.protos import third_party
-from voltha.protos import voltha_pb2
+from voltha.protos import voltha_pb2, voltha_pb2_grpc, health_pb2_grpc
from voltha.protos.openflow_13_pb2 import FlowTableUpdate, FlowGroupTableUpdate
_ = third_party
@@ -143,9 +143,9 @@
def get_stub(self):
if self.stub is None:
self.stub = \
- voltha_pb2.VolthaGlobalServiceStub(self.get_channel()) \
+ voltha_pb2_grpc.VolthaGlobalServiceStub(self.get_channel()) \
if self.global_request else \
- voltha_pb2.VolthaLocalServiceStub(self.get_channel())
+ voltha_pb2_grpc.VolthaLocalServiceStub(self.get_channel())
return self.stub
# ~~~~~~~~~~~~~~~~~ ACTUAL COMMAND IMPLEMENTATIONS ~~~~~~~~~~~~~~~~~~~~~~~~
@@ -303,7 +303,7 @@
def do_health(self, line):
"""Show connectivity status to Voltha status"""
- stub = voltha_pb2.HealthServiceStub(self.get_channel())
+ stub = health_pb2_grpc.HealthServiceStub(self.get_channel())
res = stub.GetHealthStatus(Empty())
self.poutput(dumps(pb2dict(res), indent=4))
diff --git a/cli/xpon.py b/cli/xpon.py
index ea16a4a..438d5d5 100644
--- a/cli/xpon.py
+++ b/cli/xpon.py
@@ -40,7 +40,7 @@
from voltha.protos.bbf_fiber_gemport_body_pb2 import GemportsConfigData
_ = third_party
-from voltha.protos import voltha_pb2, bbf_fiber_types_pb2, \
+from voltha.protos import voltha_pb2, voltha_pb2_grpc, bbf_fiber_types_pb2, \
ietf_interfaces_pb2, bbf_fiber_traffic_descriptor_profile_body_pb2
import sys
from google.protobuf.json_format import MessageToDict
@@ -103,7 +103,7 @@
return interface_list
def get_interface_based_on_device(self):
- stub = voltha_pb2.VolthaGlobalServiceStub(self.get_channel())
+ stub = voltha_pb2_grpc.VolthaGlobalServiceStub(self.get_channel())
try:
channel_terminations = stub.GetAllChannelterminationConfig(
voltha_pb2.ID(id=self.device_id)).channeltermination_config
@@ -152,7 +152,7 @@
def do_show(self, line):
"""Show detailed information of each interface based on device ID
or all interfaces"""
- stub = voltha_pb2.VolthaGlobalServiceStub(self.get_channel())
+ stub = voltha_pb2_grpc.VolthaGlobalServiceStub(self.get_channel())
device_id = self.device_id
if line.strip():
self.device_id = line.strip()
@@ -292,7 +292,7 @@
'bold') + ' is not recognized')
return
- stub = voltha_pb2.VolthaGlobalServiceStub(self.get_channel())
+ stub = voltha_pb2_grpc.VolthaGlobalServiceStub(self.get_channel())
if line.strip() == "get":
if self.device_id:
@@ -447,7 +447,7 @@
'bold') + ' is not recognized')
return
- stub = voltha_pb2.VolthaGlobalServiceStub(self.get_channel())
+ stub = voltha_pb2_grpc.VolthaGlobalServiceStub(self.get_channel())
if line.strip() == "get":
if self.device_id:
@@ -628,7 +628,7 @@
'bold') + ' is not recognized')
return
- stub = voltha_pb2.VolthaGlobalServiceStub(self.get_channel())
+ stub = voltha_pb2_grpc.VolthaGlobalServiceStub(self.get_channel())
if line.strip() == "get":
if self.device_id:
@@ -816,7 +816,7 @@
'bold') + ' is not recognized')
return
- stub = voltha_pb2.VolthaGlobalServiceStub(self.get_channel())
+ stub = voltha_pb2_grpc.VolthaGlobalServiceStub(self.get_channel())
if line.strip() == "get":
if self.device_id:
@@ -1007,7 +1007,7 @@
'bold') + ' is not recognized')
return
- stub = voltha_pb2.VolthaGlobalServiceStub(self.get_channel())
+ stub = voltha_pb2_grpc.VolthaGlobalServiceStub(self.get_channel())
if line.strip() == "get":
if self.device_id:
@@ -1143,7 +1143,7 @@
'bold') + ' is not recognized')
return
- stub = voltha_pb2.VolthaGlobalServiceStub(self.get_channel())
+ stub = voltha_pb2_grpc.VolthaGlobalServiceStub(self.get_channel())
if line.strip() == "get":
if self.device_id:
@@ -1278,7 +1278,7 @@
'bold') + ' is not recognized')
return
- stub = voltha_pb2.VolthaGlobalServiceStub(self.get_channel())
+ stub = voltha_pb2_grpc.VolthaGlobalServiceStub(self.get_channel())
if line.strip() == "get":
if self.device_id:
@@ -1420,7 +1420,7 @@
'bold') + ' is not recognized')
return
- stub = voltha_pb2.VolthaGlobalServiceStub(self.get_channel())
+ stub = voltha_pb2_grpc.VolthaGlobalServiceStub(self.get_channel())
if line.strip() == "get":
if self.device_id:
@@ -1528,7 +1528,7 @@
'bold') + ' is not recognized')
return
- stub = voltha_pb2.VolthaGlobalServiceStub(self.get_channel())
+ stub = voltha_pb2_grpc.VolthaGlobalServiceStub(self.get_channel())
if line.strip() == "get":
if self.device_id:
@@ -1630,7 +1630,7 @@
'bold') + ' is not recognized')
return
- stub = voltha_pb2.VolthaGlobalServiceStub(self.get_channel())
+ stub = voltha_pb2_grpc.VolthaGlobalServiceStub(self.get_channel())
if line.strip() == "get":
if self.device_id:
diff --git a/docker/Dockerfile.protoc b/docker/Dockerfile.protoc
index eef6f54..9607ecf 100644
--- a/docker/Dockerfile.protoc
+++ b/docker/Dockerfile.protoc
@@ -31,7 +31,7 @@
ENV PROTOC_DOWNLOAD_URI=${PROTOC_DOWNLOAD_PREFIX}/v${PROTOC_VERSION}/${PROTOC_TARBALL}
RUN apt-get update -y && apt-get install -y wget build-essential python-dev python-pip
-RUN pip install grpcio-tools==1.3.5
+RUN pip install grpcio-tools==1.16.0
WORKDIR /build
RUN wget -q --no-check-certificate ${PROTOC_DOWNLOAD_URI}
RUN tar --strip-components=1 -zxf ${PROTOC_TARBALL}
diff --git a/netconf/grpc_client/grpc_client.py b/netconf/grpc_client/grpc_client.py
index bcfb972..45d3347 100644
--- a/netconf/grpc_client/grpc_client.py
+++ b/netconf/grpc_client/grpc_client.py
@@ -33,7 +33,7 @@
from common.utils.asleep import asleep
from netconf.protos import third_party
-from netconf.protos.schema_pb2 import SchemaServiceStub
+from netconf.protos.schema_pb2_grpc import SchemaServiceStub
from google.protobuf.empty_pb2 import Empty
from common.utils.consulhelpers import get_endpoint_from_consul
# from netconf.protos.voltha_pb2 import VolthaLocalServiceStub, \
diff --git a/ofagent/grpc_client.py b/ofagent/grpc_client.py
index f4fc6df..a1678c5 100644
--- a/ofagent/grpc_client.py
+++ b/ofagent/grpc_client.py
@@ -27,8 +27,9 @@
from twisted.internet import threads
from twisted.internet.defer import inlineCallbacks, returnValue, DeferredQueue
-from protos.voltha_pb2 import ID, VolthaLocalServiceStub, FlowTableUpdate, MeterModUpdate, \
+from protos.voltha_pb2 import ID, FlowTableUpdate, MeterModUpdate, \
FlowGroupTableUpdate, PacketOut
+from protos.voltha_pb2_grpc import VolthaLocalServiceStub
from protos.logical_device_pb2 import LogicalPortId
from google.protobuf import empty_pb2
diff --git a/ponsim/bal_servicer.py b/ponsim/bal_servicer.py
index f036d67..1b7c4d4 100644
--- a/ponsim/bal_servicer.py
+++ b/ponsim/bal_servicer.py
@@ -18,7 +18,8 @@
from voltha.protos import third_party
from voltha.protos.ponsim_pb2 import PonSimDeviceInfo
from google.protobuf.empty_pb2 import Empty
-from voltha.adapters.asfvolt16_olt.protos.bal_pb2 import BalServicer, BalErr
+from voltha.adapters.asfvolt16_olt.protos.bal_pb2_grpc import BalServicer
+from voltha.adapters.asfvolt16_olt.protos.bal_pb2 BalErr
from voltha.adapters.asfvolt16_olt.protos.bal_errno_pb2 import BAL_ERR_OK
_ = third_party
diff --git a/ponsim/grpc_server.py b/ponsim/grpc_server.py
index 9165433..3185c9e 100644
--- a/ponsim/grpc_server.py
+++ b/ponsim/grpc_server.py
@@ -19,9 +19,9 @@
from concurrent import futures
from voltha.protos import third_party
-from voltha.protos.ponsim_pb2 import add_PonSimServicer_to_server
-from voltha.protos.ponsim_pb2 import add_XPonSimServicer_to_server
-from voltha.adapters.asfvolt16_olt.protos.bal_pb2 import add_BalServicer_to_server
+from voltha.protos.ponsim_pb2_grpc import add_PonSimServicer_to_server
+from voltha.protos.ponsim_pb2_grpc import add_XPonSimServicer_to_server
+from voltha.adapters.asfvolt16_olt.protos.bal_pb2_grpc import add_BalServicer_to_server
from ponsim_servicer import FlowUpdateHandler, XPonHandler
from bal_servicer import BalHandler
diff --git a/ponsim/ponsim_servicer.py b/ponsim/ponsim_servicer.py
index ccfec38..6c3243d 100644
--- a/ponsim/ponsim_servicer.py
+++ b/ponsim/ponsim_servicer.py
@@ -16,9 +16,9 @@
import structlog
from common.utils.grpc_utils import twisted_async
from voltha.protos import third_party
-from voltha.protos.ponsim_pb2 import PonSimServicer, PonSimDeviceInfo
+from voltha.protos.ponsim_pb2_grpc import PonSimServicer, XPonSimServicer
+from voltha.protos.ponsim_pb2 import PonSimDeviceInfo
from google.protobuf.empty_pb2 import Empty
-from voltha.protos.ponsim_pb2 import XPonSimServicer
_ = third_party
diff --git a/requirements.txt b/requirements.txt
index a56f479..0f147b9 100755
--- a/requirements.txt
+++ b/requirements.txt
@@ -9,8 +9,8 @@
docker-py==1.10.6
fluent-logger==0.6.0
grpc==0.3.post19
-grpcio==1.3.5
-grpcio-tools==1.3.5
+grpcio==1.16.0
+grpcio-tools==1.16.0
hash_ring==1.3.1
hexdump==3.3
jinja2==2.8
@@ -29,7 +29,7 @@
pcapy==0.11.1
pep8==1.7.1
pep8-naming>=0.3.3
-protobuf==3.3.0
+protobuf==3.6.1
protobuf-to-dict==0.1.0
pyflakes==1.6.0
pylint==1.7.6
diff --git a/tests/itests/voltha/test_dispatcher.py b/tests/itests/voltha/test_dispatcher.py
index 52a417e..f7ade38 100644
--- a/tests/itests/voltha/test_dispatcher.py
+++ b/tests/itests/voltha/test_dispatcher.py
@@ -28,7 +28,7 @@
from google.protobuf.empty_pb2 import Empty
import grpc
from voltha.protos import third_party
-from voltha.protos import voltha_pb2
+from voltha.protos import voltha_pb2, voltha_pb2_grpc
from voltha.core.flow_decomposer import *
from voltha.protos.openflow_13_pb2 import FlowTableUpdate
from voltha.protos import bbf_fiber_base_pb2 as fb
@@ -215,19 +215,19 @@
sleep(20) # A small wait for the system to settle down
voltha_instances = orch.get_all_instances_of_service(vcore_svc_name[orch_env], port_name='grpc')
self.assertEqual(len(voltha_instances), 3)
- self.ponsim_voltha_stub_local = voltha_pb2.VolthaLocalServiceStub(
+ self.ponsim_voltha_stub_local = voltha_pb2_grpc.VolthaLocalServiceStub(
self.get_channel(self._get_grpc_address(voltha_instances[2])))
- self.ponsim_voltha_stub_global = voltha_pb2.VolthaGlobalServiceStub(
+ self.ponsim_voltha_stub_global = voltha_pb2_grpc.VolthaGlobalServiceStub(
self.get_channel(self._get_grpc_address(voltha_instances[2])))
- self.simulated_voltha_stub_local = voltha_pb2.VolthaLocalServiceStub(
+ self.simulated_voltha_stub_local = voltha_pb2_grpc.VolthaLocalServiceStub(
self.get_channel(self._get_grpc_address(voltha_instances[1])))
- self.simulated_voltha_stub_global = voltha_pb2.VolthaGlobalServiceStub(
+ self.simulated_voltha_stub_global = voltha_pb2_grpc.VolthaGlobalServiceStub(
self.get_channel(self._get_grpc_address(voltha_instances[1])))
- self.empty_voltha_stub_local = voltha_pb2.VolthaLocalServiceStub(
+ self.empty_voltha_stub_local = voltha_pb2_grpc.VolthaLocalServiceStub(
self.get_channel(self._get_grpc_address(voltha_instances[0])))
- self.empty_voltha_stub_global = voltha_pb2.VolthaGlobalServiceStub(
+ self.empty_voltha_stub_global = voltha_pb2_grpc.VolthaGlobalServiceStub(
self.get_channel(self._get_grpc_address(voltha_instances[0])))
if orch_env == ENV_DOCKER_COMPOSE:
diff --git a/voltha/adapters/asfvolt16_olt/asfvolt16_rx_handler.py b/voltha/adapters/asfvolt16_olt/asfvolt16_rx_handler.py
index 2ef2eb6..d646982 100644
--- a/voltha/adapters/asfvolt16_olt/asfvolt16_rx_handler.py
+++ b/voltha/adapters/asfvolt16_olt/asfvolt16_rx_handler.py
@@ -19,7 +19,7 @@
"""
from twisted.internet import reactor
from common.utils.grpc_utils import twisted_async
-from voltha.adapters.asfvolt16_olt.protos import bal_indications_pb2
+from voltha.adapters.asfvolt16_olt.protos import bal_indications_pb2, bal_indications_pb2_grpc
from voltha.adapters.asfvolt16_olt.protos import bal_model_types_pb2, \
bal_errno_pb2, bal_pb2
from voltha.adapters.asfvolt16_olt.grpc_server import GrpcServer
@@ -40,7 +40,7 @@
def start(self):
self.grpc_server = GrpcServer(self.grpc_server_port, self, self.log)
self.grpc_server.start(
- bal_indications_pb2.add_BalIndServicer_to_server, self)
+ bal_indications_pb2_grpc.add_BalIndServicer_to_server, self)
def stop(self):
self.grpc_server.stop()
diff --git a/voltha/adapters/asfvolt16_olt/bal.py b/voltha/adapters/asfvolt16_olt/bal.py
index 17403b9..012a150 100644
--- a/voltha/adapters/asfvolt16_olt/bal.py
+++ b/voltha/adapters/asfvolt16_olt/bal.py
@@ -17,8 +17,10 @@
from twisted.internet.defer import inlineCallbacks, returnValue
from twisted.internet import reactor
-from voltha.adapters.asfvolt16_olt.protos import bal_pb2, \
- bal_model_types_pb2, bal_model_ids_pb2, bal_indications_pb2, asfvolt_pb2
+from voltha.adapters.asfvolt16_olt.protos import bal_pb2, bal_pb2_grpc, \
+ bal_model_types_pb2, bal_model_ids_pb2, \
+ bal_indications_pb2, bal_indications_pb2_grpc, \
+ asfvolt_pb2, asfvolt_pb2_grpc
from voltha.adapters.asfvolt16_olt.grpc_client import GrpcClient
from voltha.adapters.asfvolt16_olt.asfvolt16_ind_handler \
import Asfvolt16IndHandler
@@ -54,9 +56,9 @@
def connect_olt(self, host_and_port, device_id, is_init=True):
self.device_id = device_id
self.grpc_client.connect(host_and_port)
- self.stub = bal_pb2.BalStub(self.grpc_client.channel)
- self.ind_stub = bal_indications_pb2.BalGetIndStub(self.grpc_client.channel)
- self.asfvolt_stub = asfvolt_pb2.AsfvoltStub(self.grpc_client.channel)
+ self.stub = bal_pb2_grpc.BalStub(self.grpc_client.channel)
+ self.ind_stub = bal_indications_pb2_grpc.BalGetIndStub(self.grpc_client.channel)
+ self.asfvolt_stub = asfvolt_pb2_grpc.AsfvoltStub(self.grpc_client.channel)
self.olt.running = True
# Right now Bi-Directional GRPC support is not there in grpc-c.
diff --git a/voltha/adapters/asfvolt16_olt/sim.py b/voltha/adapters/asfvolt16_olt/sim.py
index 9df3669..84f6e19 100755
--- a/voltha/adapters/asfvolt16_olt/sim.py
+++ b/voltha/adapters/asfvolt16_olt/sim.py
@@ -21,7 +21,8 @@
from concurrent import futures
import grpc
-from voltha.adapters.asfvolt16_olt.protos.bal_pb2 import BalServicer, add_BalServicer_to_server, BalErr
+from voltha.adapters.asfvolt16_olt.protos.bal_pb2_grpc import BalServicer, add_BalServicer_to_server
+from voltha.adapters.asfvolt16_olt.protos.bal_pb2 import BalErr
from voltha.adapters.asfvolt16_olt.protos.bal_errno_pb2 import BAL_ERR_OK
log = structlog.get_logger()
diff --git a/voltha/adapters/ponsim_olt/ponsim_olt.py b/voltha/adapters/ponsim_olt/ponsim_olt.py
index 29aa0bb..9f4ba89 100644
--- a/voltha/adapters/ponsim_olt/ponsim_olt.py
+++ b/voltha/adapters/ponsim_olt/ponsim_olt.py
@@ -38,7 +38,7 @@
from voltha.core.logical_device_agent import mac_str_to_tuple
from voltha.protos import third_party
from voltha.protos import openflow_13_pb2 as ofp
-from voltha.protos import ponsim_pb2
+from voltha.protos import ponsim_pb2, ponsim_pb2_grpc
from voltha.protos.common_pb2 import OperStatus, ConnectStatus, AdminState
from voltha.protos.common_pb2 import OperationResp
from voltha.protos.device_pb2 import Port, Device, PmConfig, PmConfigs
@@ -131,7 +131,7 @@
def collect_port_metrics(self, channel):
rtrn_port_metrics = dict()
- stub = ponsim_pb2.PonSimStub(channel)
+ stub = ponsim_pb2_grpc.PonSimStub(channel)
stats = stub.GetStats(ponsim_pb2.PonSimMetricsRequest(port=0))
rtrn_port_metrics['pon'] = self.extract_pon_metrics(stats)
rtrn_port_metrics['nni'] = self.extract_nni_metrics(stats)
@@ -414,7 +414,7 @@
self.adapter_agent.update_device(device)
return
- stub = ponsim_pb2.PonSimStub(self.get_channel())
+ stub = ponsim_pb2_grpc.PonSimStub(self.get_channel())
info = stub.GetDeviceInfo(Empty())
log.info('got-info', info=info)
@@ -544,7 +544,7 @@
return
try:
- stub = ponsim_pb2.PonSimStub(self.get_channel())
+ stub = ponsim_pb2_grpc.PonSimStub(self.get_channel())
info = stub.GetDeviceInfo(Empty())
log.info('got-info', info=info)
# TODO: Verify we are connected to the same device we are
@@ -625,7 +625,7 @@
"""
This call establishes a GRPC stream to receive frames.
"""
- stub = ponsim_pb2.PonSimStub(self.get_channel())
+ stub = ponsim_pb2_grpc.PonSimStub(self.get_channel())
# Attempt to establish a grpc stream with the remote ponsim service
self.frames = stub.ReceiveFrames(Empty())
@@ -653,7 +653,7 @@
# We'll go through the flows and change the output port of flows that we
# know to be trap flows to the OF CONTROLLER port.
def update_flow_table(self, flows):
- stub = ponsim_pb2.PonSimStub(self.get_channel())
+ stub = ponsim_pb2_grpc.PonSimStub(self.get_channel())
self.log.info('pushing-olt-flow-table')
for flow in flows:
classifier_info = {}
@@ -702,12 +702,12 @@
def send_proxied_message(self, proxy_address, msg):
self.log.info('sending-proxied-message')
if isinstance(msg, FlowTable):
- stub = ponsim_pb2.PonSimStub(self.get_channel())
+ stub = ponsim_pb2_grpc.PonSimStub(self.get_channel())
self.log.info('pushing-onu-flow-table', port=msg.port)
res = stub.UpdateFlowTable(msg)
self.adapter_agent.receive_proxied_message(proxy_address, res)
elif isinstance(msg, PonSimMetricsRequest):
- stub = ponsim_pb2.PonSimStub(self.get_channel())
+ stub = ponsim_pb2_grpc.PonSimStub(self.get_channel())
self.log.info('proxying onu stats request', port=msg.port)
res = stub.GetStats(msg)
self.adapter_agent.receive_proxied_message(proxy_address, res)
@@ -730,7 +730,7 @@
if self.ponsim_comm == 'grpc':
# send over grpc stream
- stub = ponsim_pb2.PonSimStub(self.get_channel())
+ stub = ponsim_pb2_grpc.PonSimStub(self.get_channel())
frame = PonSimFrame(id=self.device_id, payload=str(out_pkt), out_port=out_port)
stub.SendFrame(frame)
else:
@@ -839,7 +839,7 @@
# Set the ofp_port_no and nni_port in case we bypassed the reconcile
# process if the device was in DISABLED state on voltha restart
if not self.ofp_port_no and not self.nni_port:
- stub = ponsim_pb2.PonSimStub(self.get_channel())
+ stub = ponsim_pb2_grpc.PonSimStub(self.get_channel())
info = stub.GetDeviceInfo(Empty())
log.info('got-info', info=info)
self.ofp_port_no = info.nni_port
@@ -1012,7 +1012,7 @@
'forwarding-{}-request-to-olt-for-interface-type'
.format(self.xpon_ponsim_olt_itfs[method_name]['log']),
interface_type=type(data))
- stub = ponsim_pb2.XPonSimStub(self.get_channel())
+ stub = ponsim_pb2_grpc.XPonSimStub(self.get_channel())
_method = getattr(
stub, self.xpon_ponsim_olt_itfs[method_name]['method_name'])
if isinstance(data, TcontsConfigData):
diff --git a/voltha/core/dispatcher.py b/voltha/core/dispatcher.py
index 1457124..06f707e 100644
--- a/voltha/core/dispatcher.py
+++ b/voltha/core/dispatcher.py
@@ -21,7 +21,7 @@
"""
import structlog
from twisted.internet.defer import inlineCallbacks, returnValue
-from voltha.protos.voltha_pb2 import VolthaLocalServiceStub
+from voltha.protos.voltha_pb2_grpc import VolthaLocalServiceStub
from voltha.registry import registry
from twisted.internet import reactor
import grpc
diff --git a/voltha/core/global_handler.py b/voltha/core/global_handler.py
index 27ccd41..a80c6a4 100644
--- a/voltha/core/global_handler.py
+++ b/voltha/core/global_handler.py
@@ -25,11 +25,13 @@
from voltha.protos.device_pb2 import PmConfigs, Images, \
ImageDownload, ImageDownloads
from voltha.protos.common_pb2 import OperationResp
-from voltha.protos.voltha_pb2 import \
+from voltha.protos.voltha_pb2_grpc import \
add_VolthaGlobalServiceServicer_to_server, VolthaLocalServiceStub, \
- VolthaGlobalServiceServicer, Voltha, VolthaInstances, VolthaInstance, \
+ VolthaGlobalServiceServicer, VolthaGlobalServiceStub
+from voltha.protos.voltha_pb2 import \
+ Voltha, VolthaInstances, VolthaInstance, \
LogicalDevice, LogicalPort, Ports, Flows, FlowGroups, Device, SelfTestResponse, \
- VolthaGlobalServiceStub, Devices, DeviceType, DeviceTypes, DeviceGroup, \
+ Devices, DeviceType, DeviceTypes, DeviceGroup, \
AlarmFilter, AlarmFilters
from voltha.registry import registry
from google.protobuf.empty_pb2 import Empty
diff --git a/voltha/core/local_handler.py b/voltha/core/local_handler.py
index 5f73513..e8552b5 100644
--- a/voltha/core/local_handler.py
+++ b/voltha/core/local_handler.py
@@ -26,8 +26,9 @@
from voltha.core.config.config_root import ConfigRoot
from voltha.protos.openflow_13_pb2 import PacketIn, Flows, FlowGroups, \
ofp_port_status
+from voltha.protos.voltha_pb2_grpc import \
+ add_VolthaLocalServiceServicer_to_server, VolthaLocalServiceServicer
from voltha.protos.voltha_pb2 import \
- add_VolthaLocalServiceServicer_to_server, VolthaLocalServiceServicer, \
VolthaInstance, Adapters, LogicalDevices, LogicalDevice, Ports, \
LogicalPort, LogicalPorts, Devices, Device, DeviceType, \
DeviceTypes, DeviceGroups, DeviceGroup, AdminState, OperStatus, ChangeEvent, \
diff --git a/voltha/northbound/grpc/grpc_client.py b/voltha/northbound/grpc/grpc_client.py
index 3c98816..950d3f6 100644
--- a/voltha/northbound/grpc/grpc_client.py
+++ b/voltha/northbound/grpc/grpc_client.py
@@ -18,8 +18,9 @@
import grpc
-from voltha.protos import schema_pb2
-from voltha.protos import voltha_pb2
+from voltha.protos import schema_pb2, schema_pb2_grpc
+from voltha.protos import voltha_pb2, voltha_pb2_grpc
+from voltha.protos import health_pb2_grpc
from google.protobuf.empty_pb2 import Empty
@@ -28,7 +29,7 @@
channel = grpc.insecure_channel('localhost:50055')
# Test fetch the schema
- stub = schema_pb2.SchemaServiceStub(channel)
+ stub = schema_pb2_grpc.SchemaServiceStub(channel)
res = stub.GetSchema(Empty())
print '\nSchema:\n'
for key in res.protos:
@@ -39,12 +40,12 @@
print '%s -> descriptor of %d bytes' % (key, len(res.descriptors[key]))
# Ping health state as an example
- stub = voltha_pb2.HealthServiceStub(channel)
+ stub = health_pb2_grpc.HealthServiceStub(channel)
res = stub.GetHealthStatus(Empty())
print '\nHealth state:', res.state
# Try another API
- stub = voltha_pb2.ExampleServiceStub(channel)
+ stub = voltha_pb2_grpc.ExampleServiceStub(channel)
res = stub.ListAddresses(Empty())
print '\nExample objects returned:\n', res.addresses
diff --git a/voltha/northbound/grpc/grpc_server.py b/voltha/northbound/grpc/grpc_server.py
index 1c746d8..af75f86 100644
--- a/voltha/northbound/grpc/grpc_server.py
+++ b/voltha/northbound/grpc/grpc_server.py
@@ -29,7 +29,7 @@
from common.utils.grpc_utils import twisted_async
from voltha.core.logical_device_agent import LogicalDeviceAgent
-from voltha.protos import voltha_pb2, schema_pb2
+from voltha.protos import voltha_pb2, voltha_pb2_grpc, schema_pb2, schema_pb2_grpc, health_pb2_grpc
from google.protobuf.empty_pb2 import Empty
from voltha.registry import IComponent
@@ -37,7 +37,7 @@
log = get_logger()
-class SchemaService(schema_pb2.SchemaServiceServicer):
+class SchemaService(schema_pb2_grpc.SchemaServiceServicer):
def __init__(self, thread_pool):
self.thread_pool = thread_pool
@@ -87,7 +87,7 @@
return self.schemas
-class HealthService(voltha_pb2.HealthServiceServicer):
+class HealthService(health_pb2_grpc.HealthServiceServicer):
def __init__(self, thread_pool):
self.thread_pool = thread_pool
@@ -105,7 +105,7 @@
return res
'''
-class VolthaLogicalLayer(voltha_pb2.VolthaLogicalLayerServicer):
+class VolthaLogicalLayer(voltha_pb2_grpc.VolthaLogicalLayerServicer):
# TODO still a mock
def __init__(self, threadpool):
@@ -206,8 +206,8 @@
# add each service unit to the server and also to the list
for activator_func, service_class in (
- (schema_pb2.add_SchemaServiceServicer_to_server, SchemaService),
- (voltha_pb2.add_HealthServiceServicer_to_server, HealthService),
+ (schema_pb2_grpc.add_SchemaServiceServicer_to_server, SchemaService),
+ (health_pb2_grpc.add_HealthServiceServicer_to_server, HealthService),
):
service = service_class(self.thread_pool)
self.register(activator_func, service)