blob: 6416804ae421c75a4bf473594fec8d8d4b68c216 [file] [log] [blame]
Shad Ansari0d83c942017-07-05 21:30:38 -07001#
2# Copyright 2017 the original author or authors.
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
Rajeswara Raob2b369a2017-09-08 11:44:15 +053017from twisted.internet.defer import inlineCallbacks, returnValue
Shad Ansari1831fcc2017-08-11 16:41:44 -070018from voltha.adapters.asfvolt16_olt.protos import bal_pb2, \
rshettye4bd2ed2017-07-19 16:38:11 +053019 bal_model_types_pb2, bal_model_ids_pb2
Shad Ansari0d83c942017-07-05 21:30:38 -070020from voltha.adapters.asfvolt16_olt.grpc_client import GrpcClient
rshetty1cc73982017-09-02 03:31:12 +053021from common.utils.nethelpers import get_my_primary_local_ipv4
Rajeswara Rao8af144c2017-08-18 14:01:06 +053022import os
Shad Ansari0d83c942017-07-05 21:30:38 -070023
Rajeswara Rao8af144c2017-08-18 14:01:06 +053024"""
25ASFVOLT Adapter port is 60001
26"""
27ADAPTER_PORT = 60001
rshettyc26a3c32017-07-27 11:06:38 +053028
rshetty1cc73982017-09-02 03:31:12 +053029
Shad Ansari0d83c942017-07-05 21:30:38 -070030class Bal(object):
rshettye4bd2ed2017-07-19 16:38:11 +053031 def __init__(self, olt, log):
Shad Ansari0d83c942017-07-05 21:30:38 -070032 self.log = log
33 self.grpc_client = GrpcClient(self.log)
rshettye4bd2ed2017-07-19 16:38:11 +053034 self.stub = None
35 self.device_id = None
36 self.olt = olt
Shad Ansari0d83c942017-07-05 21:30:38 -070037
38 @inlineCallbacks
rshettye4bd2ed2017-07-19 16:38:11 +053039 def connect_olt(self, host_and_port, device_id):
rshettye4bd2ed2017-07-19 16:38:11 +053040 self.device_id = device_id
Shad Ansari0d83c942017-07-05 21:30:38 -070041 self.grpc_client.connect(host_and_port)
42 self.stub = bal_pb2.BalStub(self.grpc_client.channel)
43 init = bal_pb2.BalInit()
Rajeswara Rao8af144c2017-08-18 14:01:06 +053044 try:
45 os.environ["SERVICE_HOST_IP"]
46 adapter_ip = os.environ["SERVICE_HOST_IP"]
47 except Exception as e:
48 self.log.info('voltha is running in non docker container environment')
49 adapter_ip = get_my_primary_local_ipv4()
50
51 ip_port = []
52 ip_port.append(str(adapter_ip))
rshettyf4bf19e2017-09-19 01:28:27 +053053 #ip_port.append("192.168.140.34")
Rajeswara Rao8af144c2017-08-18 14:01:06 +053054 ip_port.append(":")
55 ip_port.append(str(ADAPTER_PORT))
56 init.voltha_adapter_ip_port ="".join(ip_port)
57 self.log.info('Adapter port Ip', init.voltha_adapter_ip_port)
58
Shad Ansari0d83c942017-07-05 21:30:38 -070059 '''
60 TODO: Need to determine out what information
61 needs to be sent to the OLT at this stage.
62 '''
rshetty1cc73982017-09-02 03:31:12 +053063 self.log.info('connecting-olt', host_and_port=host_and_port,
64 init_details=init)
Shad Ansari0d83c942017-07-05 21:30:38 -070065 yield self.stub.BalApiInit(init)
66
rshettye4bd2ed2017-07-19 16:38:11 +053067 def activate_olt(self):
Shad Ansari0d83c942017-07-05 21:30:38 -070068 self.log.info('activating-olt')
rshettye4bd2ed2017-07-19 16:38:11 +053069 self.set_access_terminal_admin_state(bal_model_types_pb2.BAL_STATE_UP)
Shad Ansari0d83c942017-07-05 21:30:38 -070070
71 @inlineCallbacks
rshettye4bd2ed2017-07-19 16:38:11 +053072 def set_access_terminal_admin_state(self, admin_state):
rshettye4bd2ed2017-07-19 16:38:11 +053073 obj = bal_pb2.BalCfg()
74 obj.device_id = self.device_id.encode('ascii', 'ignore')
75 obj.hdr.obj_type = bal_model_ids_pb2.BAL_OBJ_ID_ACCESS_TERMINAL
76 obj.cfg.key.access_term_id = 0
77 obj.cfg.data.admin_state = admin_state
rshetty1cc73982017-09-02 03:31:12 +053078 self.log.info('Activating-Access-Terminal-Device',
79 admin_state=admin_state, device_id=self.device_id,
80 access_terminal_details=obj)
rshettyc26a3c32017-07-27 11:06:38 +053081 yield self.stub.BalCfgSet(obj)
rshettye4bd2ed2017-07-19 16:38:11 +053082
83 @inlineCallbacks
84 def activate_pon_port(self, olt_no, pon_port):
rshettye4bd2ed2017-07-19 16:38:11 +053085 try:
86 obj = bal_pb2.BalCfg()
rshettyc26a3c32017-07-27 11:06:38 +053087 # Fill Header details
rshettye4bd2ed2017-07-19 16:38:11 +053088 obj.device_id = self.device_id.encode('ascii', 'ignore')
89 obj.hdr.obj_type = bal_model_ids_pb2.BAL_OBJ_ID_INTERFACE
rshettyc26a3c32017-07-27 11:06:38 +053090 # Fill Access Terminal Details
rshettye4bd2ed2017-07-19 16:38:11 +053091 obj.interface.key.intf_id = pon_port
92 obj.interface.key.intf_type = bal_model_types_pb2.BAL_INTF_TYPE_PON
93 obj.interface.data.admin_state = bal_model_types_pb2.BAL_STATE_UP
Suhas Raoeba61c22017-08-10 11:42:32 -070094 obj.interface.data.transceiver_type = \
95 bal_model_types_pb2.BAL_TRX_TYPE_XGPON_LTH_7226_PC
rshetty1cc73982017-09-02 03:31:12 +053096 self.log.info('activating-pon-port-in-olt',
97 olt=olt_no, pon_port=pon_port,
98 pon_port_details=obj)
rshettyc26a3c32017-07-27 11:06:38 +053099 yield self.stub.BalCfgSet(obj)
rshettye4bd2ed2017-07-19 16:38:11 +0530100 except Exception as e:
101 self.log.info('activating-pon-port in olt-exception', exc=str(e))
102 return
Suhas Raoc926fc12017-07-28 11:17:49 +0530103
104 @inlineCallbacks
105 def send_omci_request_message(self, proxy_address, msg):
Suhas Raoc926fc12017-07-28 11:17:49 +0530106 try:
107 obj = bal_pb2.BalCfg()
rshettyc26a3c32017-07-27 11:06:38 +0530108 # Fill Header details
Suhas Raoc926fc12017-07-28 11:17:49 +0530109 obj.device_id = self.device_id.encode('ascii', 'ignore')
110 obj.hdr.obj_type = bal_model_ids_pb2.BAL_OBJ_ID_PACKET
rshettyc26a3c32017-07-27 11:06:38 +0530111 # Fill packet Details
112 obj.packet.key.packet_send_dest.type = \
113 bal_model_types_pb2.BAL_DEST_TYPE_ITU_OMCI_CHANNEL
114 obj.packet.key.packet_send_dest.itu_omci_channel.sub_term_id = \
Suhas Raoeba61c22017-08-10 11:42:32 -0700115 proxy_address.onu_id
Rajeswara Raocd7d8dd2017-08-14 11:51:22 +0530116 obj.packet.key.packet_send_dest.itu_omci_channel.intf_id = \
rshettyc26a3c32017-07-27 11:06:38 +0530117 proxy_address.channel_id
Suhas Raoc926fc12017-07-28 11:17:49 +0530118 obj.packet.data.pkt = msg
rshetty1cc73982017-09-02 03:31:12 +0530119 self.log.info('send_omci_request_message',
120 proxy_address=proxy_address.channel_id,
121 omci_msg_details=obj)
rshettyc26a3c32017-07-27 11:06:38 +0530122 yield self.stub.BalCfgSet(obj)
Suhas Raoc926fc12017-07-28 11:17:49 +0530123 except Exception as e:
124 self.log.info('send-proxied_message-exception', exc=str(e))
125 return
rshettyc26a3c32017-07-27 11:06:38 +0530126
127 @inlineCallbacks
128 def activate_onu(self, onu_info):
rshettyc26a3c32017-07-27 11:06:38 +0530129 try:
130 obj = bal_pb2.BalCfg()
131 # Fill Header details
132 obj.device_id = self.device_id.encode('ascii', 'ignore')
133 obj.hdr.obj_type = bal_model_ids_pb2.BAL_OBJ_ID_SUBSCRIBER_TERMINAL
134 # Fill Access Terminal Details
135 obj.terminal.key.intf_id = onu_info['pon_id']
136 obj.terminal.key.sub_term_id = onu_info['onu_id']
137 obj.terminal.data.admin_state = bal_model_types_pb2.BAL_STATE_UP
138 obj.terminal.data.serial_number.vendor_id = onu_info['vendor']
139 obj.terminal.data.serial_number.vendor_specific = \
140 onu_info['vendor_specific']
141 obj.terminal.data.registration_id = \
142 '202020202020202020202020202020202020202020202020202020202020202020202020'
rshetty1cc73982017-09-02 03:31:12 +0530143 self.log.info('activating-ONU-in-olt',
144 onu_details=obj)
rshettyc26a3c32017-07-27 11:06:38 +0530145 yield self.stub.BalCfgSet(obj)
146 except Exception as e:
147 self.log.info('activating-ONU-exception',
148 onu_info['onu_id'], exc=str(e))
149 return
Shad Ansari1831fcc2017-08-11 16:41:44 -0700150
151 @inlineCallbacks
rshettyf4bf19e2017-09-19 01:28:27 +0530152 def packet_out(self, pkt, pkt_info):
Shad Ansari1831fcc2017-08-11 16:41:44 -0700153 obj = bal_pb2.BalCfg()
rshettyf4bf19e2017-09-19 01:28:27 +0530154 obj.device_id = self.device_id.encode('ascii', 'ignore')
155 obj.hdr.obj_type = bal_model_ids_pb2.BAL_OBJ_ID_PACKET
156 if pkt_info['dest_type'] == 'onu':
157 # Set the destination ONU info
158 obj.packet.key.packet_send_dest.type = bal_model_types_pb2.BAL_DEST_TYPE_SUB_TERM
159 obj.packet.key.packet_send_dest.sub_term.sub_term_id = pkt_info['onu_id']
160 # TODO: Need to provide correct values for sub_term_uni and int_id
161 #obj.packet.key.packet_send_dest.sub_term.sub_term_uni = egress_port
162 obj.packet.key.packet_send_dest.sub_term.intf_id = pkt_info['intf_id']
163 obj.packet.data.intf_type = bal_model_types_pb2.BAL_INTF_TYPE_PON
164 elif pkt_info['dest_type'] == 'gem_port':
165 obj.packet.key.packet_send_dest.type = bal_model_types_pb2.BAL_DEST_TYPE_SVC_PORT
166 obj.packet.key.packet_send_dest.svc_port.svc_port_id = pkt_info['gem_port']
167 obj.packet.key.packet_send_dest.svc_port.intf_id = pkt_info['intf_id']
168 obj.packet.data.intf_type = bal_model_types_pb2.BAL_INTF_TYPE_PON
169 elif pkt_info['dest_type'] == 'nni':
170 obj.packet.key.packet_send_dest.type = bal_model_types_pb2.BAL_DEST_TYPE_NNI
171 obj.packet.key.packet_send_dest.nni.intf_id = pkt_info['intf_id']
172 else:
173 self.log.error('unsupported-dest-type', dest_type=pkt_info['dest_type'])
Shad Ansari1831fcc2017-08-11 16:41:44 -0700174
175 # Set the Packet-out info
Shad Ansari1831fcc2017-08-11 16:41:44 -0700176 # TODO: Need to provide correct value for intf_id
Shad Ansari1831fcc2017-08-11 16:41:44 -0700177 obj.packet.data.pkt = pkt
rshettyf4bf19e2017-09-19 01:28:27 +0530178 self.log.info('sending-packet-out',
rshetty1cc73982017-09-02 03:31:12 +0530179 packet_out_details=obj)
Shad Ansari1831fcc2017-08-11 16:41:44 -0700180 yield self.stub.BalCfgSet(obj)
rshetty1cc73982017-09-02 03:31:12 +0530181
182 @inlineCallbacks
183 def add_flow(self, onu_id, intf_id, flow_id, gem_port,
184 classifier_info, is_downstream,
185 action_info=None, sched_id=None):
186 try:
187 obj = bal_pb2.BalCfg()
188 # Fill Header details
189 obj.device_id = self.device_id.encode('ascii', 'ignore')
190 obj.hdr.obj_type = bal_model_ids_pb2.BAL_OBJ_ID_FLOW
191 # Fill Access Terminal Details
192 # To-DO flow ID need to be retrieved from flow details
193 obj.flow.key.flow_id = flow_id
194 if is_downstream is False:
195 obj.flow.key.flow_type = \
196 bal_model_types_pb2.BAL_FLOW_TYPE_UPSTREAM
197 obj.flow.data.dba_tm_sched_id = sched_id
198 else:
199 obj.flow.key.flow_type = \
200 bal_model_types_pb2.BAL_FLOW_TYPE_DOWNSTREAM
201
202 obj.flow.data.admin_state = bal_model_types_pb2.BAL_STATE_UP
203 obj.flow.data.access_int_id = intf_id
204 #obj.flow.data.network_int_id = intf_id
205 obj.flow.data.sub_term_id = onu_id
206 obj.flow.data.svc_port_id = gem_port
207 obj.flow.data.classifier.presence_mask = 0
208 if 'eth_type' in classifier_info:
209 obj.flow.data.classifier.ether_type = \
210 classifier_info['eth_type']
211 obj.flow.data.classifier.presence_mask |= \
212 bal_model_types_pb2.BAL_CLASSIFIER_ID_ETHER_TYPE
213 if 'ip_proto' in classifier_info:
214 obj.flow.data.classifier.ip_proto = \
215 classifier_info['ip_proto']
216 obj.flow.data.classifier.presence_mask |= \
217 bal_model_types_pb2.BAL_CLASSIFIER_ID_IP_PROTO
218 if 'vlan_vid' in classifier_info:
219 obj.flow.data.classifier.o_vid = \
220 classifier_info['vlan_vid']
221 obj.flow.data.classifier.presence_mask |= \
222 bal_model_types_pb2.BAL_CLASSIFIER_ID_O_VID
223 if 'vlan_pcp' in classifier_info:
224 obj.flow.data.classifier.o_pbits = \
225 classifier_info['vlan_pcp']
226 obj.flow.data.classifier.presence_mask |= \
227 bal_model_types_pb2.BAL_CLASSIFIER_ID_O_PBITS
228 if 'udp_src' in classifier_info:
229 obj.flow.data.classifier.src_port = \
230 classifier_info['udp_src']
231 obj.flow.data.classifier.presence_mask |= \
232 bal_model_types_pb2.BAL_CLASSIFIER_ID_SRC_PORT
233 if 'udp_dst' in classifier_info:
234 obj.flow.data.classifier.dst_port = \
235 classifier_info['udp_dst']
236 obj.flow.data.classifier.presence_mask |= \
237 bal_model_types_pb2.BAL_CLASSIFIER_ID_DST_PORT
238 if 'ipv4_dst' in classifier_info:
239 obj.flow.data.classifier.dst_ip = \
240 classifier_info['ipv4_dst']
241 obj.flow.data.classifier.presence_mask |= \
242 bal_model_types_pb2.BAL_CLASSIFIER_ID_DST_IP
243 if 'ipv4_src' in classifier_info:
244 obj.flow.data.classifier.src_ip = \
245 classifier_info['ipv4_src']
246 obj.flow.data.classifier.presence_mask |= \
247 bal_model_types_pb2.BAL_CLASSIFIER_ID_SRC_IP
248 if 'metadata' in classifier_info:
249 obj.flow.data.classifier.i_vid = \
250 classifier_info['metadata']
251 obj.flow.data.classifier.presence_mask |= \
252 bal_model_types_pb2.BAL_CLASSIFIER_ID_I_VID
253 if 'pkt_tag_type' in classifier_info:
254 if classifier_info['pkt_tag_type'] == 'single_tag':
255 obj.flow.data.classifier.pkt_tag_type = \
256 bal_model_types_pb2.BAL_PKT_TAG_TYPE_SINGLE_TAG
257 elif classifier_info['pkt_tag_type'] == 'double_tag':
258 obj.flow.data.classifier.pkt_tag_type = \
259 bal_model_types_pb2.BAL_PKT_TAG_TYPE_DOUBLE_TAG
260 elif classifier_info['pkt_tag_type'] == 'untagged':
261 obj.flow.data.classifier.pkt_tag_type = \
262 bal_model_types_pb2.BAL_PKT_TAG_TYPE_UNTAGGED
263 else:
264 obj.flow.data.classifier.pkt_tag_type = \
265 bal_model_types_pb2.BAL_PKT_TAG_TYPE_NONE
266 obj.flow.data.classifier.presence_mask |= \
267 bal_model_types_pb2.BAL_CLASSIFIER_ID_PKT_TAG_TYPE
268
269 if action_info is not None:
270 obj.flow.data.action.presence_mask = 0
271 obj.flow.data.action.cmds_bitmask = 0
272 if 'pop_vlan' in action_info:
273 obj.flow.data.action.o_vid = action_info['vlan_vid']
274 obj.flow.data.action.cmds_bitmask |= \
275 bal_model_types_pb2.BAL_ACTION_CMD_ID_REMOVE_OUTER_TAG
276 obj.flow.data.action.presence_mask |= \
277 bal_model_types_pb2.BAL_ACTION_ID_CMDS_BITMASK
278 obj.flow.data.action.presence_mask |= \
279 bal_model_types_pb2.BAL_ACTION_ID_O_VID
280 elif 'push_vlan' in action_info:
281 obj.flow.data.action.o_vid = action_info['vlan_vid']
282 obj.flow.data.action.cmds_bitmask |= \
283 bal_model_types_pb2.BAL_ACTION_CMD_ID_ADD_OUTER_TAG
284 obj.flow.data.action.presence_mask |= \
285 bal_model_types_pb2.BAL_ACTION_ID_CMDS_BITMASK
286 obj.flow.data.action.presence_mask |= \
287 bal_model_types_pb2.BAL_ACTION_ID_O_VID
288 elif 'trap_to_host' in action_info:
289 obj.flow.data.action.cmds_bitmask |= \
290 bal_model_types_pb2.BAL_ACTION_CMD_ID_TRAP_TO_HOST
291 obj.flow.data.action.presence_mask |= \
292 bal_model_types_pb2.BAL_ACTION_ID_CMDS_BITMASK
293 else:
294 self.log.info('Invalid-action-field')
295 return
296 self.log.info('adding-flow-to-OLT-Device',
297 flow_details=obj)
298 yield self.stub.BalCfgSet(obj)
299 except Exception as e:
300 self.log.info('add_flow-exception',
301 flow_id, onu_id, exc=str(e))
302 return
303
304 @inlineCallbacks
rshettyf4bf19e2017-09-19 01:28:27 +0530305 def delete_flow(self, onu_id, intf_id, flow_id, is_downstream):
306 try:
307 obj = bal_pb2.BalCfg()
308 # Fill Header details
309 obj.device_id = self.device_id.encode('ascii', 'ignore')
310 obj.hdr.obj_type = bal_model_ids_pb2.BAL_OBJ_ID_FLOW
311 # Fill Access Terminal Details
312 # To-DO flow ID need to be retrieved from flow details
313 obj.flow.key.flow_id = flow_id
314 if is_downstream is False:
315 obj.flow.key.flow_type = \
316 bal_model_types_pb2.BAL_FLOW_TYPE_UPSTREAM
317 else:
318 obj.flow.key.flow_type = \
319 bal_model_types_pb2.BAL_FLOW_TYPE_DOWNSTREAM
320
321 obj.flow.data.admin_state = bal_model_types_pb2.BAL_STATE_DOWN
322 obj.flow.data.access_int_id = intf_id
323 #obj.flow.data.network_int_id = intf_id
324 obj.flow.data.sub_term_id = onu_id
325 self.log.info('deleting-flows-from-OLT-Device',
326 flow_details=obj)
327 yield self.stub.BalCfgSet(obj)
328 except Exception as e:
329 self.log.info('delete_flow-exception',
330 flow_id, onu_id, exc=str(e))
331 return
332
333
334 @inlineCallbacks
rshetty1cc73982017-09-02 03:31:12 +0530335 def create_scheduler(self, id, direction, owner_info, num_priority):
336 try:
337 obj = bal_pb2.BalCfg()
338 # Fill Header details
339 obj.device_id = self.device_id.encode('ascii', 'ignore')
340 obj.hdr.obj_type = bal_model_ids_pb2.BAL_OBJ_ID_TM_SCHED
341 # Fill Access Terminal Details
342 if direction == 'downstream':
343 obj.tm_sched_cfg.key.dir =\
344 bal_model_types_pb2.BAL_TM_SCHED_DIR_DS
345 else:
346 obj.tm_sched_cfg.key.dir = \
347 bal_model_types_pb2.BAL_TM_SCHED_DIR_US
348 obj.tm_sched_cfg.key.id = id
349
350 if owner_info['type'] == 'agg_port':
351 obj.tm_sched_cfg.data.owner.type = \
352 bal_model_types_pb2.BAL_TM_SCHED_OWNER_TYPE_AGG_PORT
353 obj.tm_sched_cfg.data.owner.agg_port.presence_mask = 0
354 obj.tm_sched_cfg.data.owner.agg_port.intf_id =\
355 owner_info['intf_id']
356 obj.tm_sched_cfg.data.owner.agg_port.presence_mask |= \
357 bal_model_types_pb2.BAL_TM_SCHED_OWNER_AGG_PORT_ID_INTF_ID
358 obj.tm_sched_cfg.data.owner.agg_port.sub_term_id = \
359 owner_info['onu_id']
360 obj.tm_sched_cfg.data.owner.agg_port.presence_mask |= \
361 bal_model_types_pb2.BAL_TM_SCHED_OWNER_AGG_PORT_ID_SUB_TERM_ID
362 obj.tm_sched_cfg.data.owner.agg_port.agg_port_id = \
363 owner_info['alloc_id']
364 obj.tm_sched_cfg.data.owner.agg_port.presence_mask |= \
365 bal_model_types_pb2.BAL_TM_SCHED_OWNER_AGG_PORT_ID_AGG_PORT_ID
366 else:
367 self.log.error('Not supported scheduling type',
368 sched_type=owner_info['type'])
369 return
370 obj.tm_sched_cfg.data.sched_type = \
371 bal_model_types_pb2.BAL_TM_SCHED_TYPE_SP_WFQ
372 obj.tm_sched_cfg.data.num_priorities = num_priority
373 self.log.info('Creating Scheduler',
374 scheduler_details=obj)
375 yield self.stub.BalCfgSet(obj)
376 except Exception as e:
377 self.log.info('creat-scheduler-exception',
378 olt=self.olt.olt_id,
379 sched_id=id,
380 direction=direction,
381 owner=owner_info,
382 exc=str(e))
383 return
Rajeswara Raob2b369a2017-09-08 11:44:15 +0530384
385 @inlineCallbacks
Rajeswara Rao48a62352017-10-26 10:27:27 +0530386 def get_bal_interface_stats(self, intf_id, interface_type):
Rajeswara Raob2b369a2017-09-08 11:44:15 +0530387 self.log.info('Fetching Statistics')
388 try:
389 obj = bal_model_types_pb2.BalInterfaceKey()
Rajeswara Rao48a62352017-10-26 10:27:27 +0530390 obj.intf_id = intf_id
391 obj.intf_type = interface_type
Rajeswara Raob2b369a2017-09-08 11:44:15 +0530392 stats = yield self.stub.BalCfgStatGet(obj)
393 self.log.info('Fetching statistics success', stats_data = stats.data)
Rajeswara Rao48a62352017-10-26 10:27:27 +0530394 returnValue(stats)
Rajeswara Raob2b369a2017-09-08 11:44:15 +0530395 except Exception as e:
396 self.log.info('Fetching statistics failed', exc=str(e))
397
398 @inlineCallbacks
399 def set_bal_reboot(self, device_id):
400 self.log.info('Set Reboot')
401 try:
402 obj = bal_pb2.BalReboot()
403 obj.device_id = device_id
404 err = yield self.stub.BalApiReboot(obj)
405 self.log.info('OLT Reboot Success', reboot_err= err)
406 returnValue(err)
407 except Exception as e:
408 self.log.info('OLT Reboot failed', exc=str(e))
409
410 @inlineCallbacks
411 def get_bal_heartbeat(self, device_id):
412 self.log.info('Get HeartBeat')
413 try:
414 obj = bal_pb2.BalHeartbeat()
415 obj.device_id = device_id
Rajeswara Raoa78ddcd2017-10-10 18:13:27 +0530416 rebootStatus = yield self.stub.BalApiHeartbeat(obj)
417 self.log.info('OLT HeartBeat Response Received from', device=device_id, rebootStatus=rebootStatus)
418 returnValue(rebootStatus)
Rajeswara Raob2b369a2017-09-08 11:44:15 +0530419 except Exception as e:
420 self.log.info('OLT HeartBeat failed', exc=str(e))