VOL-1164 Check admin state on startup and enable or disable. This prevents reboots from bypassing admin down.
Change-Id: If8e67827e4b4f2930de6c7d380971c709222e1a9
diff --git a/voltha/adapters/brcm_openomci_onu/brcm_openomci_onu_handler.py b/voltha/adapters/brcm_openomci_onu/brcm_openomci_onu_handler.py
index b561feb..a9b7614 100644
--- a/voltha/adapters/brcm_openomci_onu/brcm_openomci_onu_handler.py
+++ b/voltha/adapters/brcm_openomci_onu/brcm_openomci_onu_handler.py
@@ -492,6 +492,8 @@
self.tx_id += 1
return self.tx_id
+ # TODO: Actually conform to or create a proper interface.
+ # this and the other functions called from the olt arent very clear.
def create_interface(self, data):
self.log.debug('function-entry', data=data)
self._onu_indication = data
@@ -625,6 +627,7 @@
self.disable_ports(device)
device.oper_status = OperStatus.UNKNOWN
device.connect_status = ConnectStatus.UNREACHABLE
+ device.reason = "openomci-admin-lock"
self.adapter_agent.update_device(device)
# lock all the unis
@@ -859,28 +862,30 @@
else:
self.log.info('device-info-already-loaded', in_sync=in_sync, already_loaded=self._dev_info_loaded)
- def success(_results):
- self.log.info('mib-download-success', _results=_results)
- device = self.adapter_agent.get_device(self.device_id)
- device.reason = 'initial-mib-downloaded'
- device.oper_status = OperStatus.ACTIVE
- device.connect_status = ConnectStatus.REACHABLE
- self.enable_ports(device)
- self.adapter_agent.update_device(device)
- self._mib_download_task = None
+ if device.admin_state == AdminState.ENABLED:
+ def success(_results):
+ self.log.info('mib-download-success', _results=_results)
+ device = self.adapter_agent.get_device(self.device_id)
+ device.reason = 'initial-mib-downloaded'
+ device.oper_status = OperStatus.ACTIVE
+ device.connect_status = ConnectStatus.REACHABLE
+ self.enable_ports(device)
+ self.adapter_agent.update_device(device)
+ self._mib_download_task = None
- def failure(_reason):
- self.log.info('mib-download-failure', _reason=_reason)
- # TODO: test this. also verify i can add this task this way
+ def failure(_reason):
+ self.log.info('mib-download-failure', _reason=_reason)
+ # TODO: test this. also verify i can add this task this way
+ self._mib_download_task = BrcmMibDownloadTask(self.omci_agent, self)
+ self._deferred = self._onu_omci_device.task_runner.queue_task(self._mib_download_task)
+
+ self.log.info('downloading-initial-mib-configuration')
self._mib_download_task = BrcmMibDownloadTask(self.omci_agent, self)
self._deferred = self._onu_omci_device.task_runner.queue_task(self._mib_download_task)
-
- self.log.info('downloading-initial-mib-configuration')
- self._mib_download_task = BrcmMibDownloadTask(self.omci_agent, self)
- self._deferred = self._onu_omci_device.task_runner.queue_task(self._mib_download_task)
- self._deferred.addCallbacks(success, failure)
-
-
+ self._deferred.addCallbacks(success, failure)
+ else:
+ self.log.info('admin-down-disabling')
+ self.disable(device)
def check_status_and_state(self, results, operation=''):
self.log.debug('function-entry')
diff --git a/voltha/adapters/brcm_openomci_onu/omci/brcm_uni_lock_task.py b/voltha/adapters/brcm_openomci_onu/omci/brcm_uni_lock_task.py
index 6866cba..2a12eda 100644
--- a/voltha/adapters/brcm_openomci_onu/omci/brcm_uni_lock_task.py
+++ b/voltha/adapters/brcm_openomci_onu/omci/brcm_uni_lock_task.py
@@ -17,6 +17,7 @@
from twisted.internet import reactor
from twisted.internet.defer import inlineCallbacks, failure, returnValue
from voltha.extensions.omci.omci_defs import ReasonCodes, EntityOperations
+from voltha.extensions.omci.omci_me import OntGFrame
from voltha.extensions.omci.omci_me import PptpEthernetUniFrame
RC = ReasonCodes
@@ -85,6 +86,22 @@
try:
state = 1 if self._lock else 0
+ # lock the whole ont and all the pptp. some onu dont causing odd behavior.
+ msg = OntGFrame(attributes={'administrative_state': state})
+ frame = msg.set()
+ self.log.debug('openomci-msg', msg=msg)
+ results = yield self._device.omci_cc.send(frame)
+ self.stop_if_not_running()
+
+ status = results.fields['omci_message'].fields['success_code']
+ self.log.info('response-status', status=status)
+
+ # Success?
+ if status in (RC.Success.value, RC.InstanceExists):
+ self.log.debug('set-lock-ontg', lock=self._lock)
+ else:
+ self.log.warn('cannot-set-lock-ontg', lock=self._lock)
+
pptp = self._config.pptp_entities
for key, value in pptp.iteritems():