Chip Boling | 8e042f6 | 2019-02-12 16:14:34 -0600 | [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 | from voltha.extensions.omci.state_machines.mib_sync import MibSynchronizer |
| 17 | |
| 18 | |
| 19 | class AdtnMibSynchronizer(MibSynchronizer): |
| 20 | """ |
| 21 | OpenOMCI MIB Synchronizer state machine for Adtran ONUs |
| 22 | """ |
| 23 | ADTN_RESYNC_DELAY = 120 # Periodically force a resync (lower for debugging) |
| 24 | ADTN_AUDIT_DELAY = 60 |
| 25 | |
| 26 | def __init__(self, agent, device_id, mib_sync_tasks, db, advertise_events=False): |
| 27 | """ |
| 28 | Class initialization |
| 29 | |
| 30 | :param agent: (OpenOmciAgent) Agent |
| 31 | :param device_id: (str) ONU Device ID |
| 32 | :param db: (MibDbVolatileDict) MIB Database |
| 33 | :param mib_sync_tasks: (dict) Tasks to run |
| 34 | :param advertise_events: (bool) Advertise events on OpenOMCI Event Bus |
| 35 | """ |
| 36 | super(AdtnMibSynchronizer, self).__init__(agent, device_id, mib_sync_tasks, db, |
| 37 | advertise_events=advertise_events, |
| 38 | audit_delay=AdtnMibSynchronizer.ADTN_AUDIT_DELAY, |
| 39 | resync_delay=AdtnMibSynchronizer.ADTN_RESYNC_DELAY) |
| 40 | self._first_in_sync = True |
| 41 | self._omci_managed = False # TODO: Look up model number/check handler |
| 42 | |
| 43 | def increment_mib_data_sync(self): |
| 44 | if self._omci_managed: |
| 45 | super(AdtnMibSynchronizer, self).increment_mib_data_sync() |
| 46 | |
| 47 | # IBONT 602 does not support MDS |
| 48 | self._mib_data_sync = 0 |
| 49 | |
| 50 | def on_enter_in_sync(self): |
| 51 | """ Early first sync """ |
| 52 | if not self._omci_managed: |
| 53 | # IBONT 602 does not support MDS, accelerate first forced resync |
| 54 | # after a MIB reset occurs or on first startup |
| 55 | if self._first_in_sync: |
| 56 | self._first_in_sync = False |
| 57 | # self._audit_delay = 10 # Re-enable after BBWF |
| 58 | # self._resync_delay = 10 |
| 59 | else: |
| 60 | self._audit_delay = MibSynchronizer.DEFAULT_AUDIT_DELAY |
| 61 | self._resync_delay = AdtnMibSynchronizer.ADTN_RESYNC_DELAY |
| 62 | |
| 63 | super(AdtnMibSynchronizer, self).on_enter_in_sync() |
| 64 | |
| 65 | def on_enter_auditing(self): |
| 66 | """ |
| 67 | Perform a MIB Audit. If our last MIB resync was too long in the |
| 68 | past, perform a resynchronization anyway |
| 69 | """ |
| 70 | # Is this a model that supports full OMCI management. If so, use standard |
| 71 | # forced resync delay |
| 72 | |
| 73 | if not self._omci_managed and self._check_if_mib_data_sync_supported(): |
| 74 | self._omci_managed = True |
| 75 | # Revert to standard timeouts |
| 76 | self._resync_delay = MibSynchronizer.DEFAULT_RESYNC_DELAY |
| 77 | |
| 78 | super(AdtnMibSynchronizer, self).on_enter_auditing() |
| 79 | |
| 80 | def _check_if_mib_data_sync_supported(self): |
| 81 | return False # TODO: Look up to see if we are/check handler |
| 82 | |
| 83 | def on_mib_reset_response(self, topic, msg): |
| 84 | self._first_in_sync = True |
| 85 | super(AdtnMibSynchronizer, self).on_mib_reset_response(topic, msg) |