Spawn subprocess for openolt_grpc
Change-Id: I8e10abbad3496e3d20d2d738755aa1fcfaf58419
diff --git a/voltha/adapters/openolt/openolt_device.py b/voltha/adapters/openolt/openolt_device.py
index 9755e8f..5aab531 100644
--- a/voltha/adapters/openolt/openolt_device.py
+++ b/voltha/adapters/openolt/openolt_device.py
@@ -13,18 +13,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+
import binascii
import structlog
import time
+import subprocess
import grpc
from scapy.layers.l2 import Ether, Dot1Q
from transitions import Machine
from twisted.internet import reactor
+from voltha.registry import registry
from voltha.protos.device_pb2 import Port
from voltha.adapters.openolt.protos import openolt_pb2, openolt_pb2_grpc
from voltha.adapters.openolt.openolt_utils import OpenoltUtils
-from voltha.adapters.openolt.openolt_grpc import OpenoltGrpc
from voltha.adapters.openolt.openolt_indications import OpenoltIndications
from voltha.adapters.openolt.openolt_packet import OpenoltPacket
from voltha.adapters.openolt.openolt_kafka_admin import KAdmin
@@ -111,6 +113,7 @@
self._kadmin.delete_topics([
'openolt.ind-{}'.format(self.host_and_port.split(':')[0])])
+ self.broker = registry('openolt_kafka_proxy').kafka_endpoint
channel = grpc.insecure_channel(self.host_and_port)
self.stub = openolt_pb2_grpc.OpenoltStub(channel)
@@ -128,8 +131,6 @@
# FIXME
time.sleep(10)
- self._grpc = OpenoltGrpc(self.host_and_port, self)
-
reactor.callInThread(self.get_device_info)
def do_state_connected(self, event):
@@ -164,7 +165,13 @@
self.data_model)
def post_connected(self, event):
- self._grpc.start()
+ # FIXME - better way that avoids absolute paths?
+ self._grpc = subprocess.Popen(
+ ['python',
+ 'voltha/voltha/adapters/openolt/openolt_grpc.py',
+ self.broker,
+ self.host_and_port],
+ env={'PYTHONPATH': '/voltha:/voltha/voltha/protos/third_party'})
def do_state_up(self, event):
self.log.debug("do_state_up")
diff --git a/voltha/adapters/openolt/openolt_grpc.py b/voltha/adapters/openolt/openolt_grpc.py
index a5c3a92..7a4acf4 100644
--- a/voltha/adapters/openolt/openolt_grpc.py
+++ b/voltha/adapters/openolt/openolt_grpc.py
@@ -69,7 +69,7 @@
kafka_send_pb(topic, ind)
break
else:
- log.debug("openolt grpc rx indication", indication=ind)
+ # log.debug("openolt grpc rx indication", indication=ind)
kafka_send_pb(topic, ind)
diff --git a/voltha/adapters/openolt/openolt_packet.py b/voltha/adapters/openolt/openolt_packet.py
index a3ac84b..1bc77e0 100644
--- a/voltha/adapters/openolt/openolt_packet.py
+++ b/voltha/adapters/openolt/openolt_packet.py
@@ -115,7 +115,7 @@
port_no=egress_port,
pkt=send_pkt)
- self.device._grpc.stub.OnuPacketOut(onu_pkt)
+ self.device.stub.OnuPacketOut(onu_pkt)
elif egress_port_type == Port.ETHERNET_NNI:
self.log.debug('sending-packet-to-uplink', egress_port=egress_port,
@@ -128,7 +128,7 @@
egress_port),
pkt=send_pkt)
- self.device._grpc.stub.UplinkPacketOut(uplink_pkt)
+ self.device.stub.UplinkPacketOut(uplink_pkt)
else:
self.log.warn('Packet-out-to-this-interface-type-not-implemented',