Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 1 | # |
Zsolt Haraszti | 3eb27a5 | 2017-01-03 21:56:48 -0800 | [diff] [blame] | 2 | # Copyright 2017 the original author or authors. |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | # |
| 16 | |
| 17 | """ |
| 18 | The gRPC client layer for the OpenFlow agent |
| 19 | """ |
Zsolt Haraszti | 2bdb6b3 | 2016-11-03 16:56:17 -0700 | [diff] [blame] | 20 | from Queue import Queue, Empty |
alshabib | 06b449c | 2017-01-15 17:33:16 -0600 | [diff] [blame] | 21 | import os |
Zsolt Haraszti | cd22adc | 2016-10-25 00:13:06 -0700 | [diff] [blame] | 22 | |
Zsolt Haraszti | 2bdb6b3 | 2016-11-03 16:56:17 -0700 | [diff] [blame] | 23 | from grpc import StatusCode |
| 24 | from grpc._channel import _Rendezvous |
Zsolt Haraszti | cd22adc | 2016-10-25 00:13:06 -0700 | [diff] [blame] | 25 | from structlog import get_logger |
| 26 | from twisted.internet import reactor |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 27 | from twisted.internet import threads |
Zsolt Haraszti | cd22adc | 2016-10-25 00:13:06 -0700 | [diff] [blame] | 28 | from twisted.internet.defer import inlineCallbacks, returnValue, DeferredQueue |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 29 | |
Scott Baker | d865fa2 | 2018-11-07 11:45:28 -0800 | [diff] [blame] | 30 | from protos.voltha_pb2 import ID, FlowTableUpdate, MeterModUpdate, \ |
Jonathan Hart | 398e407 | 2018-05-30 16:54:00 -0700 | [diff] [blame] | 31 | FlowGroupTableUpdate, PacketOut |
Scott Baker | d865fa2 | 2018-11-07 11:45:28 -0800 | [diff] [blame] | 32 | from protos.voltha_pb2_grpc import VolthaLocalServiceStub |
Jonathan Hart | 398e407 | 2018-05-30 16:54:00 -0700 | [diff] [blame] | 33 | from protos.logical_device_pb2 import LogicalPortId |
Zsolt Haraszti | 7eeb2b3 | 2016-11-06 14:04:55 -0800 | [diff] [blame] | 34 | from google.protobuf import empty_pb2 |
Zsolt Haraszti | cd22adc | 2016-10-25 00:13:06 -0700 | [diff] [blame] | 35 | |
| 36 | |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 37 | class GrpcClient(object): |
| 38 | |
Richard Jankowski | db9a86e | 2018-09-17 13:33:29 -0400 | [diff] [blame] | 39 | def __init__(self, connection_manager, channel, grpc_timeout): |
Zsolt Haraszti | cd22adc | 2016-10-25 00:13:06 -0700 | [diff] [blame] | 40 | |
Zack Williams | 18357ed | 2018-11-14 10:41:08 -0700 | [diff] [blame] | 41 | self.log = get_logger() |
| 42 | |
Zsolt Haraszti | cd22adc | 2016-10-25 00:13:06 -0700 | [diff] [blame] | 43 | self.connection_manager = connection_manager |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 44 | self.channel = channel |
Richard Jankowski | db9a86e | 2018-09-17 13:33:29 -0400 | [diff] [blame] | 45 | self.grpc_timeout = grpc_timeout |
Zsolt Haraszti | 6686203 | 2016-11-28 14:28:39 -0800 | [diff] [blame] | 46 | self.local_stub = VolthaLocalServiceStub(channel) |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 47 | |
Zsolt Haraszti | 2bdb6b3 | 2016-11-03 16:56:17 -0700 | [diff] [blame] | 48 | self.stopped = False |
| 49 | |
Zsolt Haraszti | cd22adc | 2016-10-25 00:13:06 -0700 | [diff] [blame] | 50 | self.packet_out_queue = Queue() # queue to send out PacketOut msgs |
| 51 | self.packet_in_queue = DeferredQueue() # queue to receive PacketIn |
Zsolt Haraszti | 217a12e | 2016-12-19 16:37:55 -0800 | [diff] [blame] | 52 | self.change_event_queue = DeferredQueue() # queue change events |
Zsolt Haraszti | 2bdb6b3 | 2016-11-03 16:56:17 -0700 | [diff] [blame] | 53 | |
Shad Ansari | 9109a28 | 2019-05-03 01:24:57 -0700 | [diff] [blame] | 54 | self.count_pkt_in = 0 |
| 55 | self.count_pkt_out = 0 |
| 56 | |
Zsolt Haraszti | 2bdb6b3 | 2016-11-03 16:56:17 -0700 | [diff] [blame] | 57 | def start(self): |
Zack Williams | 18357ed | 2018-11-14 10:41:08 -0700 | [diff] [blame] | 58 | self.log.debug('starting', grpc_timeout=self.grpc_timeout) |
Zsolt Haraszti | cd22adc | 2016-10-25 00:13:06 -0700 | [diff] [blame] | 59 | self.start_packet_out_stream() |
| 60 | self.start_packet_in_stream() |
Zsolt Haraszti | 217a12e | 2016-12-19 16:37:55 -0800 | [diff] [blame] | 61 | self.start_change_event_in_stream() |
Zsolt Haraszti | cd22adc | 2016-10-25 00:13:06 -0700 | [diff] [blame] | 62 | reactor.callLater(0, self.packet_in_forwarder_loop) |
Zsolt Haraszti | 217a12e | 2016-12-19 16:37:55 -0800 | [diff] [blame] | 63 | reactor.callLater(0, self.change_event_processing_loop) |
Zack Williams | 18357ed | 2018-11-14 10:41:08 -0700 | [diff] [blame] | 64 | self.log.info('started') |
Zsolt Haraszti | 2bdb6b3 | 2016-11-03 16:56:17 -0700 | [diff] [blame] | 65 | return self |
| 66 | |
| 67 | def stop(self): |
Zack Williams | 18357ed | 2018-11-14 10:41:08 -0700 | [diff] [blame] | 68 | self.log.debug('stopping') |
Zsolt Haraszti | 2bdb6b3 | 2016-11-03 16:56:17 -0700 | [diff] [blame] | 69 | self.stopped = True |
Zack Williams | 18357ed | 2018-11-14 10:41:08 -0700 | [diff] [blame] | 70 | self.log.info('stopped') |
Zsolt Haraszti | cd22adc | 2016-10-25 00:13:06 -0700 | [diff] [blame] | 71 | |
| 72 | def start_packet_out_stream(self): |
| 73 | |
| 74 | def packet_generator(): |
| 75 | while 1: |
Zsolt Haraszti | 2bdb6b3 | 2016-11-03 16:56:17 -0700 | [diff] [blame] | 76 | try: |
| 77 | packet = self.packet_out_queue.get(block=True, timeout=1.0) |
| 78 | except Empty: |
| 79 | if self.stopped: |
| 80 | return |
| 81 | else: |
Shad Ansari | 9109a28 | 2019-05-03 01:24:57 -0700 | [diff] [blame] | 82 | self.count_pkt_out += 1 |
| 83 | self.log.debug('counters grpc_client OUT - {}'.format(self.count_pkt_out)) |
Zsolt Haraszti | 2bdb6b3 | 2016-11-03 16:56:17 -0700 | [diff] [blame] | 84 | yield packet |
Zsolt Haraszti | cd22adc | 2016-10-25 00:13:06 -0700 | [diff] [blame] | 85 | |
| 86 | def stream_packets_out(): |
| 87 | generator = packet_generator() |
alshabib | 06b449c | 2017-01-15 17:33:16 -0600 | [diff] [blame] | 88 | try: |
| 89 | self.local_stub.StreamPacketsOut(generator) |
| 90 | except _Rendezvous, e: |
Zack Williams | 18357ed | 2018-11-14 10:41:08 -0700 | [diff] [blame] | 91 | self.log.error('grpc-exception', status=e.code()) |
alshabib | 06b449c | 2017-01-15 17:33:16 -0600 | [diff] [blame] | 92 | if e.code() == StatusCode.UNAVAILABLE: |
| 93 | os.system("kill -15 {}".format(os.getpid())) |
Zsolt Haraszti | cd22adc | 2016-10-25 00:13:06 -0700 | [diff] [blame] | 94 | |
| 95 | reactor.callInThread(stream_packets_out) |
| 96 | |
| 97 | def start_packet_in_stream(self): |
| 98 | |
| 99 | def receive_packet_in_stream(): |
Zsolt Haraszti | 6686203 | 2016-11-28 14:28:39 -0800 | [diff] [blame] | 100 | streaming_rpc_method = self.local_stub.ReceivePacketsIn |
Zsolt Haraszti | 9ed5429 | 2017-01-09 18:28:32 -0800 | [diff] [blame] | 101 | iterator = streaming_rpc_method(empty_pb2.Empty()) |
alshabib | 06b449c | 2017-01-15 17:33:16 -0600 | [diff] [blame] | 102 | try: |
| 103 | for packet_in in iterator: |
| 104 | reactor.callFromThread(self.packet_in_queue.put, |
| 105 | packet_in) |
Zack Williams | 18357ed | 2018-11-14 10:41:08 -0700 | [diff] [blame] | 106 | self.log.debug('enqued-packet-in', |
alshabib | 06b449c | 2017-01-15 17:33:16 -0600 | [diff] [blame] | 107 | packet_in=packet_in, |
| 108 | queue_len=len(self.packet_in_queue.pending)) |
Shad Ansari | 9109a28 | 2019-05-03 01:24:57 -0700 | [diff] [blame] | 109 | self.count_pkt_in += 1 |
| 110 | self.log.debug('counters grpc_client IN - {}'.format(self.count_pkt_in)) |
alshabib | 06b449c | 2017-01-15 17:33:16 -0600 | [diff] [blame] | 111 | except _Rendezvous, e: |
Zack Williams | 18357ed | 2018-11-14 10:41:08 -0700 | [diff] [blame] | 112 | self.log.error('grpc-exception', status=e.code()) |
alshabib | 06b449c | 2017-01-15 17:33:16 -0600 | [diff] [blame] | 113 | if e.code() == StatusCode.UNAVAILABLE: |
| 114 | os.system("kill -15 {}".format(os.getpid())) |
Zsolt Haraszti | cd22adc | 2016-10-25 00:13:06 -0700 | [diff] [blame] | 115 | |
| 116 | reactor.callInThread(receive_packet_in_stream) |
| 117 | |
Zsolt Haraszti | 217a12e | 2016-12-19 16:37:55 -0800 | [diff] [blame] | 118 | def start_change_event_in_stream(self): |
| 119 | |
| 120 | def receive_change_events(): |
| 121 | streaming_rpc_method = self.local_stub.ReceiveChangeEvents |
Zsolt Haraszti | 9ed5429 | 2017-01-09 18:28:32 -0800 | [diff] [blame] | 122 | iterator = streaming_rpc_method(empty_pb2.Empty()) |
alshabib | 06b449c | 2017-01-15 17:33:16 -0600 | [diff] [blame] | 123 | try: |
| 124 | for event in iterator: |
| 125 | reactor.callFromThread(self.change_event_queue.put, event) |
Zack Williams | 18357ed | 2018-11-14 10:41:08 -0700 | [diff] [blame] | 126 | self.log.debug('enqued-change-event', |
alshabib | 06b449c | 2017-01-15 17:33:16 -0600 | [diff] [blame] | 127 | change_event=event, |
| 128 | queue_len=len(self.change_event_queue.pending)) |
| 129 | except _Rendezvous, e: |
Zack Williams | 18357ed | 2018-11-14 10:41:08 -0700 | [diff] [blame] | 130 | self.log.error('grpc-exception', status=e.code()) |
alshabib | 06b449c | 2017-01-15 17:33:16 -0600 | [diff] [blame] | 131 | if e.code() == StatusCode.UNAVAILABLE: |
| 132 | os.system("kill -15 {}".format(os.getpid())) |
Zsolt Haraszti | 217a12e | 2016-12-19 16:37:55 -0800 | [diff] [blame] | 133 | |
| 134 | reactor.callInThread(receive_change_events) |
| 135 | |
| 136 | @inlineCallbacks |
| 137 | def change_event_processing_loop(self): |
| 138 | while True: |
| 139 | try: |
| 140 | event = yield self.change_event_queue.get() |
| 141 | device_id = event.id |
| 142 | self.connection_manager.forward_change_event(device_id, event) |
| 143 | except Exception, e: |
Zack Williams | 18357ed | 2018-11-14 10:41:08 -0700 | [diff] [blame] | 144 | self.log.exception('failed-in-packet-in-handler', e=e) |
Zsolt Haraszti | 217a12e | 2016-12-19 16:37:55 -0800 | [diff] [blame] | 145 | if self.stopped: |
| 146 | break |
| 147 | |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 148 | @inlineCallbacks |
Zsolt Haraszti | cd22adc | 2016-10-25 00:13:06 -0700 | [diff] [blame] | 149 | def packet_in_forwarder_loop(self): |
| 150 | while True: |
| 151 | packet_in = yield self.packet_in_queue.get() |
| 152 | device_id = packet_in.id |
| 153 | ofp_packet_in = packet_in.packet_in |
Saurav Das | aa9247f | 2019-06-07 11:36:55 -0700 | [diff] [blame] | 154 | self.log.debug('grpc client to send packet-in') |
Zsolt Haraszti | cd22adc | 2016-10-25 00:13:06 -0700 | [diff] [blame] | 155 | self.connection_manager.forward_packet_in(device_id, ofp_packet_in) |
Zsolt Haraszti | 2bdb6b3 | 2016-11-03 16:56:17 -0700 | [diff] [blame] | 156 | if self.stopped: |
| 157 | break |
Zsolt Haraszti | cd22adc | 2016-10-25 00:13:06 -0700 | [diff] [blame] | 158 | |
| 159 | def send_packet_out(self, device_id, packet_out): |
Saurav Das | aa9247f | 2019-06-07 11:36:55 -0700 | [diff] [blame] | 160 | self.log.debug('grpc client to send packet-out') |
Zsolt Haraszti | cd22adc | 2016-10-25 00:13:06 -0700 | [diff] [blame] | 161 | packet_out = PacketOut(id=device_id, packet_out=packet_out) |
| 162 | self.packet_out_queue.put(packet_out) |
| 163 | |
| 164 | @inlineCallbacks |
Jonathan Hart | 8d21c32 | 2018-04-17 07:42:02 -0700 | [diff] [blame] | 165 | def get_port(self, device_id, port_id): |
| 166 | req = LogicalPortId(id=device_id, port_id=port_id) |
| 167 | res = yield threads.deferToThread( |
Richard Jankowski | db9a86e | 2018-09-17 13:33:29 -0400 | [diff] [blame] | 168 | self.local_stub.GetLogicalDevicePort, req, timeout=self.grpc_timeout) |
Jonathan Hart | 8d21c32 | 2018-04-17 07:42:02 -0700 | [diff] [blame] | 169 | returnValue(res) |
| 170 | |
| 171 | @inlineCallbacks |
Zsolt Haraszti | cd22adc | 2016-10-25 00:13:06 -0700 | [diff] [blame] | 172 | def get_port_list(self, device_id): |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 173 | req = ID(id=device_id) |
| 174 | res = yield threads.deferToThread( |
Richard Jankowski | db9a86e | 2018-09-17 13:33:29 -0400 | [diff] [blame] | 175 | self.local_stub.ListLogicalDevicePorts, req, timeout=self.grpc_timeout) |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 176 | returnValue(res.items) |
| 177 | |
| 178 | @inlineCallbacks |
Jonathan Hart | 8d21c32 | 2018-04-17 07:42:02 -0700 | [diff] [blame] | 179 | def enable_port(self, device_id, port_id): |
| 180 | req = LogicalPortId( |
| 181 | id=device_id, |
| 182 | port_id=port_id |
| 183 | ) |
| 184 | res = yield threads.deferToThread( |
Richard Jankowski | db9a86e | 2018-09-17 13:33:29 -0400 | [diff] [blame] | 185 | self.local_stub.EnableLogicalDevicePort, req, timeout=self.grpc_timeout) |
Jonathan Hart | 8d21c32 | 2018-04-17 07:42:02 -0700 | [diff] [blame] | 186 | returnValue(res) |
| 187 | |
| 188 | @inlineCallbacks |
| 189 | def disable_port(self, device_id, port_id): |
| 190 | req = LogicalPortId( |
| 191 | id=device_id, |
| 192 | port_id=port_id |
| 193 | ) |
| 194 | res = yield threads.deferToThread( |
Richard Jankowski | db9a86e | 2018-09-17 13:33:29 -0400 | [diff] [blame] | 195 | self.local_stub.DisableLogicalDevicePort, req, timeout=self.grpc_timeout) |
Jonathan Hart | 8d21c32 | 2018-04-17 07:42:02 -0700 | [diff] [blame] | 196 | returnValue(res) |
| 197 | |
| 198 | @inlineCallbacks |
Zsolt Haraszti | cd22adc | 2016-10-25 00:13:06 -0700 | [diff] [blame] | 199 | def get_device_info(self, device_id): |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 200 | req = ID(id=device_id) |
| 201 | res = yield threads.deferToThread( |
Richard Jankowski | db9a86e | 2018-09-17 13:33:29 -0400 | [diff] [blame] | 202 | self.local_stub.GetLogicalDevice, req, timeout=self.grpc_timeout) |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 203 | returnValue(res) |
| 204 | |
| 205 | @inlineCallbacks |
Zsolt Haraszti | cd22adc | 2016-10-25 00:13:06 -0700 | [diff] [blame] | 206 | def update_flow_table(self, device_id, flow_mod): |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 207 | req = FlowTableUpdate( |
| 208 | id=device_id, |
| 209 | flow_mod=flow_mod |
| 210 | ) |
| 211 | res = yield threads.deferToThread( |
Richard Jankowski | db9a86e | 2018-09-17 13:33:29 -0400 | [diff] [blame] | 212 | self.local_stub.UpdateLogicalDeviceFlowTable, req, timeout=self.grpc_timeout) |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 213 | returnValue(res) |
| 214 | |
| 215 | @inlineCallbacks |
Koray Kokten | 8592a23 | 2018-08-27 07:41:14 +0000 | [diff] [blame] | 216 | def update_meter_mod_table(self, device_id, meter_mod): |
| 217 | req = MeterModUpdate( |
| 218 | id=device_id, |
| 219 | meter_mod=meter_mod |
| 220 | ) |
| 221 | res = yield threads.deferToThread( |
Gamze Abaka | 53cc0a2 | 2019-01-31 12:06:11 +0000 | [diff] [blame] | 222 | self.local_stub.UpdateLogicalDeviceMeterTable, req, timeout=self.grpc_timeout) |
Koray Kokten | 8592a23 | 2018-08-27 07:41:14 +0000 | [diff] [blame] | 223 | returnValue(res) |
| 224 | |
| 225 | @inlineCallbacks |
Zsolt Haraszti | cd22adc | 2016-10-25 00:13:06 -0700 | [diff] [blame] | 226 | def update_group_table(self, device_id, group_mod): |
Zsolt Haraszti | 6686203 | 2016-11-28 14:28:39 -0800 | [diff] [blame] | 227 | req = FlowGroupTableUpdate( |
Zsolt Haraszti | 8a77438 | 2016-10-24 18:25:54 -0700 | [diff] [blame] | 228 | id=device_id, |
| 229 | group_mod=group_mod |
| 230 | ) |
| 231 | res = yield threads.deferToThread( |
Richard Jankowski | db9a86e | 2018-09-17 13:33:29 -0400 | [diff] [blame] | 232 | self.local_stub.UpdateLogicalDeviceFlowGroupTable, req, timeout=self.grpc_timeout) |
Zsolt Haraszti | 8a77438 | 2016-10-24 18:25:54 -0700 | [diff] [blame] | 233 | returnValue(res) |
| 234 | |
| 235 | @inlineCallbacks |
Zsolt Haraszti | cd22adc | 2016-10-25 00:13:06 -0700 | [diff] [blame] | 236 | def list_flows(self, device_id): |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 237 | req = ID(id=device_id) |
| 238 | res = yield threads.deferToThread( |
Richard Jankowski | db9a86e | 2018-09-17 13:33:29 -0400 | [diff] [blame] | 239 | self.local_stub.ListLogicalDeviceFlows, req, timeout=self.grpc_timeout) |
Zsolt Haraszti | 023ea7c | 2016-10-16 19:30:34 -0700 | [diff] [blame] | 240 | returnValue(res.items) |
Zsolt Haraszti | 8a77438 | 2016-10-24 18:25:54 -0700 | [diff] [blame] | 241 | |
| 242 | @inlineCallbacks |
Zsolt Haraszti | cd22adc | 2016-10-25 00:13:06 -0700 | [diff] [blame] | 243 | def list_groups(self, device_id): |
Zsolt Haraszti | 8a77438 | 2016-10-24 18:25:54 -0700 | [diff] [blame] | 244 | req = ID(id=device_id) |
| 245 | res = yield threads.deferToThread( |
Richard Jankowski | db9a86e | 2018-09-17 13:33:29 -0400 | [diff] [blame] | 246 | self.local_stub.ListLogicalDeviceFlowGroups, req, timeout=self.grpc_timeout) |
Zsolt Haraszti | 8a77438 | 2016-10-24 18:25:54 -0700 | [diff] [blame] | 247 | returnValue(res.items) |
Nicolas Palpacuer | fd7b8b1 | 2018-06-15 13:58:06 -0400 | [diff] [blame] | 248 | |
| 249 | @inlineCallbacks |
Gamze Abaka | 53cc0a2 | 2019-01-31 12:06:11 +0000 | [diff] [blame] | 250 | def list_meters(self, device_id): |
| 251 | req = ID(id=device_id) |
| 252 | res = yield threads.deferToThread( |
| 253 | self.local_stub.ListLogicalDeviceMeters, req, timeout=self.grpc_timeout) |
| 254 | returnValue(res.items) |
| 255 | |
| 256 | @inlineCallbacks |
Nicolas Palpacuer | fd7b8b1 | 2018-06-15 13:58:06 -0400 | [diff] [blame] | 257 | def list_ports(self, device_id): |
| 258 | req = ID(id=device_id) |
| 259 | res = yield threads.deferToThread( |
Richard Jankowski | db9a86e | 2018-09-17 13:33:29 -0400 | [diff] [blame] | 260 | self.local_stub.ListLogicalDevicePorts, req, timeout=self.grpc_timeout) |
| 261 | returnValue(res.items) |
| 262 | |
| 263 | @inlineCallbacks |
| 264 | def list_logical_devices(self): |
| 265 | res = yield threads.deferToThread( |
| 266 | self.local_stub.ListLogicalDevices, empty_pb2.Empty(), timeout=self.grpc_timeout) |
| 267 | returnValue(res.items) |
| 268 | |
| 269 | @inlineCallbacks |
Nicolas Palpacuer | 75ba77f | 2018-08-27 17:26:57 -0400 | [diff] [blame] | 270 | def list_reachable_logical_devices(self): |
| 271 | res = yield threads.deferToThread( |
| 272 | self.local_stub.ListReachableLogicalDevices, empty_pb2.Empty(), |
| 273 | timeout=self.grpc_timeout) |
| 274 | returnValue(res.items) |
| 275 | |
| 276 | @inlineCallbacks |
Richard Jankowski | db9a86e | 2018-09-17 13:33:29 -0400 | [diff] [blame] | 277 | def subscribe(self, subscriber): |
| 278 | res = yield threads.deferToThread( |
| 279 | self.local_stub.Subscribe, subscriber, timeout=self.grpc_timeout) |
| 280 | returnValue(res) |