Matt Jeanneret | f1e9c5d | 2019-02-08 07:41:29 -0500 | [diff] [blame] | 1 | # |
| 2 | # Copyright 2018 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 | import structlog |
Matt Jeanneret | 72f96fc | 2019-02-11 10:53:05 -0500 | [diff] [blame] | 17 | from pyvoltha.adapters.extensions.omci.tasks.get_mds_task import GetMdsTask |
Matt Jeanneret | f1e9c5d | 2019-02-08 07:41:29 -0500 | [diff] [blame] | 18 | |
| 19 | |
| 20 | class BrcmGetMdsTask(GetMdsTask): |
| 21 | """ |
| 22 | OpenOMCI Get MIB Data Sync value task - Broadcom ONU |
| 23 | |
| 24 | On successful completion, this task will call the 'callback' method of the |
| 25 | deferred returned by the start method and return the value of the MIB |
| 26 | Data Sync attribute of the ONT Data ME |
| 27 | """ |
| 28 | name = "BRCM: Get MDS Task" |
| 29 | |
| 30 | def __init__(self, omci_agent, device_id): |
| 31 | """ |
| 32 | Class initialization |
| 33 | |
| 34 | :param omci_agent: (OmciAdapterAgent) OMCI Adapter agent |
| 35 | :param device_id: (str) ONU Device ID |
| 36 | """ |
| 37 | self.log = structlog.get_logger(device_id=device_id) |
| 38 | self.log.debug('function-entry') |
| 39 | |
| 40 | super(BrcmGetMdsTask, self).__init__(omci_agent, device_id) |
| 41 | |
| 42 | self.name = BrcmGetMdsTask.name |
| 43 | self._device = omci_agent.get_device(device_id) |
| 44 | self._omci_managed = False # TODO: Look up capabilities/model number/check handler |
| 45 | |
| 46 | def perform_get_mds(self): |
| 47 | """ |
| 48 | Get the 'mib_data_sync' attribute of the ONU |
| 49 | """ |
| 50 | self.log.debug('function-entry') |
| 51 | self.log.info('perform-get-mds') |
| 52 | |
| 53 | if self._omci_managed: |
| 54 | return super(BrcmGetMdsTask, self).perform_get_mds() |
| 55 | |
| 56 | # Non-OMCI managed BRCM ONUs always return 0 for MDS, use the MIB |
| 57 | # sync value and depend on an accelerated mib resync to do the |
| 58 | # proper comparison |
| 59 | |
| 60 | self.deferred.callback(self._device.mib_synchronizer.mib_data_sync) |
| 61 | |