blob: eaee13055d3d11f423150dfda7a6f0737fed88fa [file] [log] [blame]
Chip Boling27275992017-09-22 15:17:04 -05001# Copyright 2017-present Adtran, Inc.
Chip Boling3e3b1a92017-05-16 11:51:18 -05002#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
Chip Boling252c7772017-08-16 10:13:17 -05007# http://www.apache.org/licenses/LICENSE-2.0
Chip Boling3e3b1a92017-05-16 11:51:18 -05008#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
Chip Boling3e3b1a92017-05-16 11:51:18 -050014
15"""
16Adtran 1-U OLT adapter.
17"""
18import structlog
Chip Bolingfd1fd372017-12-20 13:34:12 -060019from twisted.internet import reactor, defer
Chip Boling3e3b1a92017-05-16 11:51:18 -050020from zope.interface import implementer
21
22from adtran_olt_handler import AdtranOltHandler
23from voltha.adapters.interface import IAdapterInterface
24from voltha.protos import third_party
25from voltha.protos.adapter_pb2 import Adapter
26from voltha.protos.adapter_pb2 import AdapterConfig
27from voltha.protos.common_pb2 import LogLevel
28from voltha.protos.device_pb2 import DeviceType, DeviceTypes
29from voltha.protos.health_pb2 import HealthStatus
30from voltha.registry import registry
31
32_ = third_party
33log = structlog.get_logger()
34
35
36@implementer(IAdapterInterface)
37class AdtranOltAdapter(object):
38 name = 'adtran_olt'
39
40 supported_device_types = [
41 DeviceType(
42 id=name,
43 adapter=name,
Chip Bolingbffef5e2018-08-07 14:53:12 -050044 accepts_bulk_flow_update=True,
45 accepts_add_remove_flow_updates=False # TODO: Support flow-mods
Chip Boling3e3b1a92017-05-16 11:51:18 -050046 )
47 ]
48
49 def __init__(self, adapter_agent, config):
50 self.adapter_agent = adapter_agent
51 self.config = config
52 self.descriptor = Adapter(
53 id=self.name,
Chip Bolingbffef5e2018-08-07 14:53:12 -050054 vendor='Adtran Inc.',
Chip Boling3810e132018-10-12 13:03:47 -050055 version='1.24',
Chip Boling3e3b1a92017-05-16 11:51:18 -050056 config=AdapterConfig(log_level=LogLevel.INFO)
57 )
58 log.debug('adtran_olt.__init__', adapter_agent=adapter_agent)
59 self.devices_handlers = dict() # device_id -> AdtranOltHandler()
60 self.interface = registry('main').get_args().interface
Chip Boling252c7772017-08-16 10:13:17 -050061 self.logical_device_id_to_root_device_id = dict()
Chip Boling3e3b1a92017-05-16 11:51:18 -050062
63 def start(self):
64 """
65 Called once after adapter instance is loaded. Can be used to async
66 initialization.
67
68 :return: (None or Deferred)
69 """
Chip Boling3e3b1a92017-05-16 11:51:18 -050070 log.info('started', interface=self.interface)
71
72 def stop(self):
73 """
74 Called once before adapter is unloaded. It can be used to perform
75 any cleanup after the adapter.
76
77 :return: (None or Deferred)
78 """
Chip Boling3e3b1a92017-05-16 11:51:18 -050079 log.info('stopped', interface=self.interface)
80
81 def adapter_descriptor(self):
82 """
83 Return the adapter descriptor object for this adapter.
84
85 :return: voltha.Adapter grpc object (see voltha/protos/adapter.proto),
86 with adapter-specific information and config extensions.
87 """
88 log.debug('get descriptor', interface=self.interface)
89 return self.descriptor
90
91 def device_types(self):
92 """
93 Return list of device types supported by the adapter.
94
95 :return: voltha.DeviceTypes protobuf object, with optional type
96 specific extensions.
97 """
98 log.debug('get device_types', interface=self.interface, items=self.supported_device_types)
99 return DeviceTypes(items=self.supported_device_types)
100
101 def health(self):
102 """
103 Return a 3-state health status using the voltha.HealthStatus message.
104
105 :return: Deferred or direct return with voltha.HealthStatus message
106 """
107 log.debug('get health', interface=self.interface)
108 return HealthStatus(state=HealthStatus.HealthState.HEALTHY)
109
110 def change_master_state(self, master):
111 """
112 Called to indicate if plugin shall assume or lose master role. The
113 master role can be used to perform functions that must be performed
114 from a single point in the cluster. In single-node deployments of
115 Voltha, the plugins are always in master role.
116
117 :param master: (bool) True to indicate the mastership needs to be
118 assumed; False to indicate that mastership needs to be abandoned.
119 :return: (Deferred) which is fired by the adapter when mastership is
120 assumed/dropped, respectively.
121 """
122 log.debug('change_master_state', interface=self.interface, master=master)
123 raise NotImplementedError()
124
125 def adopt_device(self, device):
126 """
127 Make sure the adapter looks after given device. Called when a device
128 is provisioned top-down and needs to be activated by the adapter.
129
130 :param device: A voltha.Device object, with possible device-type
131 specific extensions. Such extensions shall be described as part of
132 the device type specification returned by device_types().
133 :return: (Deferred) Shall be fired to acknowledge device ownership.
134 """
135 log.info('adopt-device', device=device)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600136 kwargs = {
137 'adapter': self,
138 'device-id': device.id
139 }
140 self.devices_handlers[device.id] = AdtranOltHandler(**kwargs)
141 d = defer.Deferred()
Chip Bolingce5bfc02018-08-09 13:57:49 -0500142 reactor.callLater(0, self.devices_handlers[device.id].activate, d, False)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600143 return d
Chip Boling3e3b1a92017-05-16 11:51:18 -0500144
khenaidooce681042017-06-12 11:25:34 -0400145 def reconcile_device(self, device):
146 """
Chip Boling7294b252017-06-15 16:16:55 -0500147 Make sure the adapter looks after given device. Called when this device has
148 changed ownership from another Voltha instance to this one (typically, this
149 occurs when the previous voltha instance went down).
khenaidooce681042017-06-12 11:25:34 -0400150
Chip Boling7294b252017-06-15 16:16:55 -0500151 :param device: A voltha.Device object, with possible device-type specific
152 extensions. Such extensions shall be described as part of
153 the device type specification returned by device_types().
154 :return: (Deferred) Shall be fired to acknowledge device ownership.
155 """
156 log.info('reconcile-device', device=device)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600157 kwargs = {
158 'adapter': self,
159 'device-id': device.id
160 }
161 self.devices_handlers[device.id] = AdtranOltHandler(**kwargs)
162 d = defer.Deferred()
Chip Bolingce5bfc02018-08-09 13:57:49 -0500163 reactor.callLater(0, self.devices_handlers[device.id].activate, d, True)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600164 return d
khenaidooce681042017-06-12 11:25:34 -0400165
Chip Boling3e3b1a92017-05-16 11:51:18 -0500166 def abandon_device(self, device):
167 """
168 Make sure the adapter no longer looks after device. This is called
169 if device ownership is taken over by another Voltha instance.
170
171 :param device: A Voltha.Device object.
172 :return: (Deferred) Shall be fired to acknowledge abandonment.
173 """
174 log.info('abandon-device', device=device)
Chip Boling7294b252017-06-15 16:16:55 -0500175 raise NotImplementedError()
Chip Boling3e3b1a92017-05-16 11:51:18 -0500176
177 def disable_device(self, device):
178 """
179 This is called when a previously enabled device needs to be disabled
180 based on a NBI call.
181
182 :param device: A Voltha.Device object.
183 :return: (Deferred) Shall be fired to acknowledge disabling the device.
184 """
Chip Boling69fba862017-08-18 15:11:32 -0500185 log.info('disable-device', device=device)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600186 handler = self.devices_handlers.get(device.id)
187 if handler is not None:
188 reactor.callLater(0, handler.disable)
189 return device
Chip Boling3e3b1a92017-05-16 11:51:18 -0500190
191 def reenable_device(self, device):
192 """
193 This is called when a previously disabled device needs to be enabled
194 based on a NBI call.
195
196 :param device: A Voltha.Device object.
197 :return: (Deferred) Shall be fired to acknowledge re-enabling the device.
198 """
Chip Boling69fba862017-08-18 15:11:32 -0500199 log.info('reenable-device', device=device)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600200 handler = self.devices_handlers.get(device.id)
201 if handler is not None:
202 d = defer.Deferred()
203 reactor.callLater(0, handler.reenable, done_deferred=d)
204 return d
Chip Boling3e3b1a92017-05-16 11:51:18 -0500205
206 def reboot_device(self, device):
207 """
Chip Bolingfd1fd372017-12-20 13:34:12 -0600208 This is called to reboot a device based on a NBI call. The admin state of the device
209 will not change after the reboot
Chip Boling3e3b1a92017-05-16 11:51:18 -0500210
211 :param device: A Voltha.Device object.
212 :return: (Deferred) Shall be fired to acknowledge the reboot.
213 """
214 log.info('reboot_device', device=device)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600215 handler = self.devices_handlers.get(device.id)
216 if handler is not None:
217 reactor.callLater(0, handler.reboot)
218 return device
Chip Boling3e3b1a92017-05-16 11:51:18 -0500219
Lydia Fang01f2e852017-06-28 17:24:58 -0700220 def download_image(self, device, request):
Chip Bolingae298012017-08-28 08:55:17 -0500221 """
Chip Bolingfd1fd372017-12-20 13:34:12 -0600222 This is called to request downloading a specified image into the standby partition
223 of a device based on a NBI call.
224
Chip Bolingae298012017-08-28 08:55:17 -0500225 :param device: A Voltha.Device object.
Chip Bolingfd1fd372017-12-20 13:34:12 -0600226 :param request: A Voltha.ImageDownload object.
Chip Bolingae298012017-08-28 08:55:17 -0500227 :return: (Deferred) Shall be fired to acknowledge the download.
228 """
Lydia Fang01f2e852017-06-28 17:24:58 -0700229 log.info('image_download', device=device, request=request)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600230 handler = self.devices_handlers.get(device.id)
231 if handler is not None:
232 return handler.start_download(device, request, defer.Deferred())
Lydia Fang01f2e852017-06-28 17:24:58 -0700233
234 def get_image_download_status(self, device, request):
Chip Bolingae298012017-08-28 08:55:17 -0500235 """
Chip Bolingfd1fd372017-12-20 13:34:12 -0600236 This is called to inquire about a requested image download status based
237 on a NBI call. The adapter is expected to update the DownloadImage DB object
Chip Bolingae298012017-08-28 08:55:17 -0500238 with the query result
Chip Bolingfd1fd372017-12-20 13:34:12 -0600239
Chip Bolingae298012017-08-28 08:55:17 -0500240 :param device: A Voltha.Device object.
Chip Bolingfd1fd372017-12-20 13:34:12 -0600241 :param request: A Voltha.ImageDownload object.
Chip Bolingae298012017-08-28 08:55:17 -0500242 :return: (Deferred) Shall be fired to acknowledge
243 """
Lydia Fang01f2e852017-06-28 17:24:58 -0700244 log.info('get_image_download', device=device, request=request)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600245 handler = self.devices_handlers.get(device.id)
246 if handler is not None:
247 return handler.download_status(device, request, defer.Deferred())
Lydia Fang01f2e852017-06-28 17:24:58 -0700248
249 def cancel_image_download(self, device, request):
Chip Bolingae298012017-08-28 08:55:17 -0500250 """
251 This is called to cancel a requested image download
252 based on a NBI call. The admin state of the device will not
253 change after the download.
254 :param device: A Voltha.Device object.
Chip Bolingfd1fd372017-12-20 13:34:12 -0600255 :param request: A Voltha.ImageDownload object.
Chip Bolingae298012017-08-28 08:55:17 -0500256 :return: (Deferred) Shall be fired to acknowledge
257 """
Lydia Fang01f2e852017-06-28 17:24:58 -0700258 log.info('cancel_image_download', device=device)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600259 handler = self.devices_handlers.get(device.id)
260 if handler is not None:
261 return handler.cancel_download(device, request, defer.Deferred())
Lydia Fang01f2e852017-06-28 17:24:58 -0700262
263 def activate_image_update(self, device, request):
Chip Bolingae298012017-08-28 08:55:17 -0500264 """
265 This is called to activate a downloaded image from
266 a standby partition into active partition.
267 Depending on the device implementation, this call
268 may or may not cause device reboot.
269 If no reboot, then a reboot is required to make the
270 activated image running on device
271 This call is expected to be non-blocking.
272 :param device: A Voltha.Device object.
Chip Bolingfd1fd372017-12-20 13:34:12 -0600273 :param request: A Voltha.ImageDownload object.
Chip Bolingae298012017-08-28 08:55:17 -0500274 :return: (Deferred) OperationResponse object.
275 """
276 log.info('activate_image_update', device=device, request=request)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600277 handler = self.devices_handlers.get(device.id)
278 if handler is not None:
279 return handler.activate_image(device, request, defer.Deferred())
Lydia Fang01f2e852017-06-28 17:24:58 -0700280
281 def revert_image_update(self, device, request):
Chip Bolingae298012017-08-28 08:55:17 -0500282 """
283 This is called to deactivate the specified image at
284 active partition, and revert to previous image at
285 standby partition.
286 Depending on the device implementation, this call
287 may or may not cause device reboot.
288 If no reboot, then a reboot is required to make the
289 previous image running on device
290 This call is expected to be non-blocking.
291 :param device: A Voltha.Device object.
Chip Bolingfd1fd372017-12-20 13:34:12 -0600292 :param request: A Voltha.ImageDownload object.
Chip Bolingae298012017-08-28 08:55:17 -0500293 :return: (Deferred) OperationResponse object.
294 """
295 log.info('revert_image_update', device=device, request=request)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600296 handler = self.devices_handlers.get(device.id)
297 if handler is not None:
298 return handler.revert_image(device, request, defer.Deferred())
Lydia Fang01f2e852017-06-28 17:24:58 -0700299
sathishg5ae86222017-06-28 15:16:29 +0530300 def self_test_device(self, device):
301 """
302 This is called to Self a device based on a NBI call.
303 :param device: A Voltha.Device object.
304 :return: Will return result of self test
305 """
Chip Boling5561d552017-07-07 15:11:26 -0500306 from voltha.protos.voltha_pb2 import SelfTestResponse
sathishg5ae86222017-06-28 15:16:29 +0530307 log.info('self-test-device', device=device.id)
Chip Boling5561d552017-07-07 15:11:26 -0500308 # TODO: Support self test?
309 return SelfTestResponse(result=SelfTestResponse.NOT_SUPPORTED)
sathishg5ae86222017-06-28 15:16:29 +0530310
Chip Boling3e3b1a92017-05-16 11:51:18 -0500311 def delete_device(self, device):
312 """
313 This is called to delete a device from the PON based on a NBI call.
314 If the device is an OLT then the whole PON will be deleted.
315
316 :param device: A Voltha.Device object.
317 :return: (Deferred) Shall be fired to acknowledge the deletion.
318 """
Chip Boling69fba862017-08-18 15:11:32 -0500319 log.info('delete-device', device=device)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600320 handler = self.devices_handlers.get(device.id)
321 if handler is not None:
322 reactor.callLater(0, handler.delete)
Chip Boling7294b252017-06-15 16:16:55 -0500323 return device
Chip Boling3e3b1a92017-05-16 11:51:18 -0500324
325 def get_device_details(self, device):
326 """
327 This is called to get additional device details based on a NBI call.
328
329 :param device: A Voltha.Device object.
330 :return: (Deferred) Shall be fired to acknowledge the retrieval of
331 additional details.
332 """
333 log.debug('get_device_details', device=device)
334 raise NotImplementedError()
335
336 def update_flows_bulk(self, device, flows, groups):
337 """
338 Called after any flow table change, but only if the device supports
339 bulk mode, which is expressed by the 'accepts_bulk_flow_update'
340 capability attribute of the device type.
341
342 :param device: A Voltha.Device object.
343 :param flows: An openflow_v13.Flows object
344 :param groups: An openflow_v13.Flows object
345 :return: (Deferred or None)
346 """
Chip Bolingbb15b512018-06-01 11:39:58 -0500347 log.debug('bulk-flow-update', device_id=device.id, flows=flows,
348 groups=groups, num_flows=len(flows.items))
Chip Boling3e3b1a92017-05-16 11:51:18 -0500349 assert len(groups.items) == 0, "Cannot yet deal with groups"
Chip Boling7294b252017-06-15 16:16:55 -0500350
Chip Bolingfd1fd372017-12-20 13:34:12 -0600351 handler = self.devices_handlers.get(device.id)
352 if handler is not None:
353 return handler.update_flow_table(flows.items, device)
Chip Boling3e3b1a92017-05-16 11:51:18 -0500354
355 def update_flows_incrementally(self, device, flow_changes, group_changes):
356 """
357 [This mode is not supported yet.]
358
359 :param device: A Voltha.Device object.
360 :param flow_changes:
361 :param group_changes:
362 :return:
363 """
364 log.debug('update_flows_incrementally', device=device, flow_changes=flow_changes,
365 group_changes=group_changes)
366 raise NotImplementedError()
367
368 def update_pm_config(self, device, pm_configs):
369 """
370 Called every time a request is made to change pm collection behavior
371 :param device: A Voltha.Device object
372 :param pm_configs: A Pms
373 """
374 log.debug('update_pm_config', device=device, pm_configs=pm_configs)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600375 handler = self.devices_handlers.get(device.id)
376 if handler is not None:
377 handler.update_pm_config(device, pm_configs)
Chip Boling3e3b1a92017-05-16 11:51:18 -0500378
379 def send_proxied_message(self, proxy_address, msg):
380 """
381 Forward a msg to a child device of device, addressed by the given
382 proxy_address=Device.ProxyAddress().
383
384 :param proxy_address: Address info for the parent device
385 to route the message to the child device. This was given to the
386 child device by the parent device at the creation of the child
387 device.
388 :param msg: (str) The actual message to send.
389 :return: (Deferred(None) or None) The return of this method should
390 indicate that the message was successfully *sent*.
391 """
Chip Boling69fba862017-08-18 15:11:32 -0500392 log.debug('send-proxied-message', proxy_address=proxy_address, msg=msg)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600393 handler = self.devices_handlers.get(proxy_address.device_id)
394 if handler is not None:
395 handler.send_proxied_message(proxy_address, msg)
Chip Boling3e3b1a92017-05-16 11:51:18 -0500396
397 def receive_proxied_message(self, proxy_address, msg):
398 """
399 Pass an async message (arrived via a proxy) to this device.
400
401 :param proxy_address: Address info for the parent device
402 to route the message to the child device. This was given to the
403 child device by the parent device at the creation of the child
404 device. Note this is the proxy_address with which the adapter
405 had to register prior to receiving proxied messages.
406 :param msg: (str) The actual message received.
407 :return: None
408 """
409 log.debug('receive_proxied_message', proxy_address=proxy_address, msg=msg)
410 raise NotImplementedError()
411
412 def receive_packet_out(self, logical_device_id, egress_port_no, msg):
413 """
414 Pass a packet_out message content to adapter so that it can forward it
415 out to the device. This is only called on root devices.
416
417 :param logical_device_id:
418 :param egress_port_no: egress logical port number
419 :param msg: actual message
420 :return: None
421 """
Chip Boling69fba862017-08-18 15:11:32 -0500422 log.debug('packet-out', logical_device_id=logical_device_id,
423 egress_port_no=egress_port_no, msg_len=len(msg))
Chip Boling5561d552017-07-07 15:11:26 -0500424
425 def ldi_to_di(ldi):
426 di = self.logical_device_id_to_root_device_id.get(ldi)
427 if di is None:
428 logical_device = self.adapter_agent.get_logical_device(ldi)
429 di = logical_device.root_device_id
430 self.logical_device_id_to_root_device_id[ldi] = di
431 return di
432
433 device_id = ldi_to_di(logical_device_id)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600434 handler = self.devices_handlers.get(device_id)
435 if handler is not None:
436 handler.packet_out(egress_port_no, msg)
Chip Boling3e3b1a92017-05-16 11:51:18 -0500437
438 def receive_inter_adapter_message(self, msg):
439 """
Chip Boling252c7772017-08-16 10:13:17 -0500440 Called when the adapter receives a message that was sent to it directly
Chip Boling3e3b1a92017-05-16 11:51:18 -0500441 from another adapter. An adapter may register for these messages by calling
442 the register_for_inter_adapter_messages() method in the adapter agent.
443 Note that it is the responsibility of the sending and receiving
444 adapters to properly encode and decode the message.
445 :param msg: The message contents.
446 :return: None
447 """
448 log.info('rx_inter_adapter_msg')
449 raise NotImplementedError()
Chip Boling99004882017-05-19 15:36:19 -0500450
451 def suppress_alarm(self, filter):
Chip Boling5561d552017-07-07 15:11:26 -0500452 """
453 Inform an adapter that all incoming alarms should be suppressed
454 :param filter: A Voltha.AlarmFilter object.
455 :return: (Deferred) Shall be fired to acknowledge the suppression.
456 """
Chip Boling99004882017-05-19 15:36:19 -0500457 log.info('suppress_alarm', filter=filter)
458 raise NotImplementedError()
459
460 def unsuppress_alarm(self, filter):
Chip Boling5561d552017-07-07 15:11:26 -0500461 """
462 Inform an adapter that all incoming alarms should resume
463 :param filter: A Voltha.AlarmFilter object.
464 :return: (Deferred) Shall be fired to acknowledge the unsuppression.
465 """
Chip Boling99004882017-05-19 15:36:19 -0500466 log.info('unsuppress_alarm', filter=filter)
467 raise NotImplementedError()
Nikolay Titov89004ec2017-06-19 18:22:42 -0400468
Chip Boling5561d552017-07-07 15:11:26 -0500469 # PON Mgnt APIs #
Nikolay Titov89004ec2017-06-19 18:22:42 -0400470 def create_interface(self, device, data):
Chip Boling5561d552017-07-07 15:11:26 -0500471 """
472 API to create various interfaces (only some PON interfaces as of now)
473 in the devices
474 """
Chip Bolingfd1fd372017-12-20 13:34:12 -0600475 log.debug('create-interface', data=data)
476 handler = self.devices_handlers.get(device.id)
477 if handler is not None:
478 handler.xpon_create(data)
Nikolay Titov89004ec2017-06-19 18:22:42 -0400479
480 def update_interface(self, device, data):
Chip Boling5561d552017-07-07 15:11:26 -0500481 """
482 API to update various interfaces (only some PON interfaces as of now)
483 in the devices
484 """
Chip Bolingfd1fd372017-12-20 13:34:12 -0600485 log.debug('update-interface', data=data)
486 handler = self.devices_handlers.get(device.id)
487 if handler is not None:
488 handler.xpon_update(data)
Nikolay Titov89004ec2017-06-19 18:22:42 -0400489
490 def remove_interface(self, device, data):
Chip Boling5561d552017-07-07 15:11:26 -0500491 """
492 API to delete various interfaces (only some PON interfaces as of now)
493 in the devices
494 """
Chip Bolingfd1fd372017-12-20 13:34:12 -0600495 log.debug('remove-interface', data=data)
496 handler = self.devices_handlers.get(device.id)
497 if handler is not None:
498 handler.xpon_remove(data)
Nikolay Titov89004ec2017-06-19 18:22:42 -0400499
Chip Bolingae298012017-08-28 08:55:17 -0500500 def receive_onu_detect_state(self, proxy_address, state):
Chip Boling5561d552017-07-07 15:11:26 -0500501 """
502 Receive onu detect state in ONU adapter
503 :param proxy_address: ONU device address
504 :param state: ONU detect state (bool)
505 :return: None
506 """
Nikolay Titov89004ec2017-06-19 18:22:42 -0400507 raise NotImplementedError()
Nikolay Titov176f1db2017-08-10 12:38:43 -0400508
509 def create_tcont(self, device, tcont_data, traffic_descriptor_data):
Chip Bolingae298012017-08-28 08:55:17 -0500510 """
511 API to create tcont object in the devices
512 :param device: device id
Chip Bolingfd1fd372017-12-20 13:34:12 -0600513 :param tcont_data: tcont data object
514 :param traffic_descriptor_data: traffic descriptor data object
Chip Bolingae298012017-08-28 08:55:17 -0500515 :return: None
516 """
Chip Boling69fba862017-08-18 15:11:32 -0500517 log.info('create-tcont', tcont_data=tcont_data,
518 traffic_descriptor_data=traffic_descriptor_data)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600519 handler = self.devices_handlers.get(device.id)
520 if handler is not None:
521 handler.create_tcont(tcont_data, traffic_descriptor_data)
Nikolay Titov176f1db2017-08-10 12:38:43 -0400522
523 def update_tcont(self, device, tcont_data, traffic_descriptor_data):
Chip Bolingae298012017-08-28 08:55:17 -0500524 """
525 API to update tcont object in the devices
526 :param device: device id
Chip Bolingfd1fd372017-12-20 13:34:12 -0600527 :param tcont_data: tcont data object
528 :param traffic_descriptor_data: traffic descriptor data object
Chip Bolingae298012017-08-28 08:55:17 -0500529 :return: None
530 """
Chip Boling69fba862017-08-18 15:11:32 -0500531 log.info('update-tcont', tcont_data=tcont_data,
532 traffic_descriptor_data=traffic_descriptor_data)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600533 handler = self.devices_handlers.get(device.id)
534 if handler is not None:
535 handler.update_tcont(tcont_data, traffic_descriptor_data)
Nikolay Titov176f1db2017-08-10 12:38:43 -0400536
537 def remove_tcont(self, device, tcont_data, traffic_descriptor_data):
Chip Bolingae298012017-08-28 08:55:17 -0500538 """
539 API to delete tcont object in the devices
540 :param device: device id
Chip Bolingfd1fd372017-12-20 13:34:12 -0600541 :param tcont_data: tcont data object
542 :param traffic_descriptor_data: traffic descriptor data object
Chip Bolingae298012017-08-28 08:55:17 -0500543 :return: None
544 """
Chip Boling69fba862017-08-18 15:11:32 -0500545 log.info('remove-tcont', tcont_data=tcont_data,
546 traffic_descriptor_data=traffic_descriptor_data)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600547 handler = self.devices_handlers.get(device.id)
548 if handler is not None:
549 handler.remove_tcont(tcont_data, traffic_descriptor_data)
Nikolay Titov176f1db2017-08-10 12:38:43 -0400550
551 def create_gemport(self, device, data):
Chip Bolingae298012017-08-28 08:55:17 -0500552 """
553 API to create gemport object in the devices
554 :param device: device id
Chip Bolingfd1fd372017-12-20 13:34:12 -0600555 :param data: gemport data object
Chip Bolingae298012017-08-28 08:55:17 -0500556 :return: None
557 """
Chip Bolingbb15b512018-06-01 11:39:58 -0500558 log.debug('create-gemport', data=data)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600559 handler = self.devices_handlers.get(device.id)
560 if handler is not None:
561 handler.xpon_create(data)
Nikolay Titov176f1db2017-08-10 12:38:43 -0400562
563 def update_gemport(self, device, data):
Chip Bolingae298012017-08-28 08:55:17 -0500564 """
565 API to update gemport object in the devices
566 :param device: device id
Chip Bolingfd1fd372017-12-20 13:34:12 -0600567 :param data: gemport data object
Chip Bolingae298012017-08-28 08:55:17 -0500568 :return: None
569 """
Chip Boling69fba862017-08-18 15:11:32 -0500570 log.info('update-gemport', data=data)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600571 handler = self.devices_handlers.get(device.id)
572 if handler is not None:
573 handler.xpon_update(data)
Nikolay Titov176f1db2017-08-10 12:38:43 -0400574
575 def remove_gemport(self, device, data):
Chip Bolingae298012017-08-28 08:55:17 -0500576 """
577 API to delete gemport object in the devices
578 :param device: device id
579 :data: gemport data object
580 :return: None
581 """
Chip Boling69fba862017-08-18 15:11:32 -0500582 log.info('remove-gemport', data=data)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600583 handler = self.devices_handlers.get(device.id)
584 if handler is not None:
585 handler.xpon_remove(data)
Nikolay Titov176f1db2017-08-10 12:38:43 -0400586
587 def create_multicast_gemport(self, device, data):
Chip Bolingae298012017-08-28 08:55:17 -0500588 """
589 API to create multicast gemport object in the devices
590 :param device: device id
591 :data: multicast gemport data object
592 :return: None
593 """
Chip Boling69fba862017-08-18 15:11:32 -0500594 log.info('create-mcast-gemport', data=data)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600595 handler = self.devices_handlers.get(device.id)
596 if handler is not None:
597 handler.xpon_create(data)
Nikolay Titov176f1db2017-08-10 12:38:43 -0400598
599 def update_multicast_gemport(self, device, data):
Chip Bolingae298012017-08-28 08:55:17 -0500600 """
601 API to update multicast gemport object in the devices
602 :param device: device id
603 :data: multicast gemport data object
604 :return: None
605 """
Chip Boling69fba862017-08-18 15:11:32 -0500606 log.info('update-mcast-gemport', data=data)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600607 handler = self.devices_handlers.get(device.id)
608 if handler is not None:
609 handler.xpon_update(data)
Nikolay Titov176f1db2017-08-10 12:38:43 -0400610
611 def remove_multicast_gemport(self, device, data):
Chip Bolingae298012017-08-28 08:55:17 -0500612 """
613 API to delete multicast gemport object in the devices
614 :param device: device id
615 :data: multicast gemport data object
616 :return: None
617 """
Chip Boling69fba862017-08-18 15:11:32 -0500618 log.info('remove-mcast-gemport', data=data)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600619 handler = self.devices_handlers.get(device.id)
620 if handler is not None:
621 handler.xpon_remove(data)
Nikolay Titov176f1db2017-08-10 12:38:43 -0400622
623 def create_multicast_distribution_set(self, device, data):
Chip Bolingae298012017-08-28 08:55:17 -0500624 """
625 API to create multicast distribution rule to specify
626 the multicast VLANs that ride on the multicast gemport
627 :param device: device id
628 :data: multicast distribution data object
629 :return: None
630 """
Chip Boling69fba862017-08-18 15:11:32 -0500631 log.info('create-mcast-distribution-set', data=data)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600632 handler = self.devices_handlers.get(device.id)
633 if handler is not None:
634 handler.xpon_create(data)
Nikolay Titov176f1db2017-08-10 12:38:43 -0400635
636 def update_multicast_distribution_set(self, device, data):
Chip Bolingae298012017-08-28 08:55:17 -0500637 """
638 API to update multicast distribution rule to specify
639 the multicast VLANs that ride on the multicast gemport
640 :param device: device id
641 :data: multicast distribution data object
642 :return: None
643 """
Chip Boling69fba862017-08-18 15:11:32 -0500644 log.info('update-mcast-distribution-set', data=data)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600645 handler = self.devices_handlers.get(device.id)
646 if handler is not None:
647 handler.xpon_update(data)
Nikolay Titov176f1db2017-08-10 12:38:43 -0400648
649 def remove_multicast_distribution_set(self, device, data):
Chip Bolingae298012017-08-28 08:55:17 -0500650 """
651 API to delete multicast distribution rule to specify
652 the multicast VLANs that ride on the multicast gemport
653 :param device: device id
654 :data: multicast distribution data object
655 :return: None
656 """
Chip Boling69fba862017-08-18 15:11:32 -0500657 log.info('remove-mcast-distribution-set', data=data)
Chip Bolingfd1fd372017-12-20 13:34:12 -0600658 handler = self.devices_handlers.get(device.id)
659 if handler is not None:
660 handler.xpon_remove(data)