Shad Ansari | 2fc4864 | 2017-06-10 01:40:32 -0700 | [diff] [blame] | 1 | # |
| 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 | |
| 17 | """ |
| 18 | Asfvolt16 OLT adapter |
| 19 | """ |
| 20 | |
Shad Ansari | b32e31c | 2017-06-28 01:55:50 -0700 | [diff] [blame] | 21 | import structlog |
Shad Ansari | d1aa9e7 | 2017-06-23 21:34:25 -0700 | [diff] [blame] | 22 | from voltha.adapters.iadapter import OltAdapter |
Shad Ansari | d8194f8 | 2017-07-04 10:19:37 -0700 | [diff] [blame] | 23 | from voltha.adapters.asfvolt16_olt.asfvolt16_device_handler import Asfvolt16Handler |
rshetty | e4bd2ed | 2017-07-19 16:38:11 +0530 | [diff] [blame] | 24 | from voltha.adapters.asfvolt16_olt.asfvolt16_rx_handler import Asfvolt16RxHandler |
Shad Ansari | b32e31c | 2017-06-28 01:55:50 -0700 | [diff] [blame] | 25 | |
| 26 | log = structlog.get_logger() |
Shad Ansari | 2fc4864 | 2017-06-10 01:40:32 -0700 | [diff] [blame] | 27 | |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 28 | |
Shad Ansari | d1aa9e7 | 2017-06-23 21:34:25 -0700 | [diff] [blame] | 29 | class Asfvolt16Adapter(OltAdapter): |
Shad Ansari | 2fc4864 | 2017-06-10 01:40:32 -0700 | [diff] [blame] | 30 | def __init__(self, adapter_agent, config): |
Shad Ansari | 14bcd99 | 2017-06-13 14:27:20 -0700 | [diff] [blame] | 31 | super(Asfvolt16Adapter, self).__init__(adapter_agent=adapter_agent, |
| 32 | config=config, |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 33 | device_handler_class=Asfvolt16Handler, |
Shad Ansari | 14bcd99 | 2017-06-13 14:27:20 -0700 | [diff] [blame] | 34 | name='asfvolt16_olt', |
| 35 | vendor='Edgecore', |
sathishg | f33c616 | 2017-11-27 10:15:14 +0530 | [diff] [blame] | 36 | version='0.94', |
Nikolay Titov | 89004ec | 2017-06-19 18:22:42 -0400 | [diff] [blame] | 37 | device_type='asfvolt16_olt') |
Shad Ansari | 2fc4864 | 2017-06-10 01:40:32 -0700 | [diff] [blame] | 38 | # register for adapter messages |
rshetty | e4bd2ed | 2017-07-19 16:38:11 +0530 | [diff] [blame] | 39 | self.port = 60001 |
| 40 | self.rx_handler = Asfvolt16RxHandler(self, self.port, log) |
| 41 | self.rx_handler.start() |
Shad Ansari | 2fc4864 | 2017-06-10 01:40:32 -0700 | [diff] [blame] | 42 | self.adapter_agent.register_for_inter_adapter_messages() |
rshetty | e4bd2ed | 2017-07-19 16:38:11 +0530 | [diff] [blame] | 43 | |
| 44 | def stop(self): |
| 45 | self.rx_handler.stop() |
rshetty | 1cc7398 | 2017-09-02 03:31:12 +0530 | [diff] [blame] | 46 | |
| 47 | def create_tcont(self, device, tcont_data, traffic_descriptor_data): |
| 48 | log.info('create-tcont', device_id=device.id) |
| 49 | if device.id in self.devices_handlers: |
| 50 | handler = self.devices_handlers[device.id] |
| 51 | if handler is not None: |
| 52 | handler.create_tcont(tcont_data, traffic_descriptor_data) |
| 53 | |
| 54 | def update_tcont(self, device, tcont_data, traffic_descriptor_data): |
| 55 | log.info('update-tcont', device_id=device.id) |
| 56 | if device.id in self.devices_handlers: |
| 57 | handler = self.devices_handlers[device.id] |
| 58 | if handler is not None: |
| 59 | handler.update_tcont(tcont_data, traffic_descriptor_data) |
| 60 | |
| 61 | def remove_tcont(self, device, tcont_data, traffic_descriptor_data): |
| 62 | log.info('remove-tcont', device_id=device.id) |
| 63 | if device.id in self.devices_handlers: |
| 64 | handler = self.devices_handlers[device.id] |
| 65 | if handler is not None: |
| 66 | handler.remove_tcont(tcont_data, traffic_descriptor_data) |
| 67 | |
| 68 | def create_gemport(self, device, data): |
| 69 | log.info('create-gemport', device_id=device.id) |
| 70 | if device.id in self.devices_handlers: |
| 71 | handler = self.devices_handlers[device.id] |
| 72 | if handler is not None: |
| 73 | handler.create_gemport(data) |
| 74 | |
| 75 | def update_gemport(self, device, data): |
| 76 | log.info('update-gemport', device_id=device.id) |
| 77 | if device.id in self.devices_handlers: |
| 78 | handler = self.devices_handlers[device.id] |
| 79 | if handler is not None: |
| 80 | handler.update_gemport(data) |
| 81 | |
| 82 | def remove_gemport(self, device, data): |
| 83 | log.info('remove-gemport', device_id=device.id) |
| 84 | if device.id in self.devices_handlers: |
| 85 | handler = self.devices_handlers[device.id] |
| 86 | if handler is not None: |
| 87 | handler.remove_gemport(data) |