Example #1
0
    def perform_lock(self):
        """
        Perform the lock/unlock
        """
        self.log.info('setting-uni-lock-state', lock=self._lock)

        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.strobe_watchdog()

            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():
                msg = PptpEthernetUniFrame(
                    key, attributes=dict(administrative_state=state))
                frame = msg.set()
                self.log.debug('openomci-msg', msg=msg)
                results = yield self._device.omci_cc.send(frame)
                self.strobe_watchdog()

                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-uni',
                                   uni=key,
                                   value=value,
                                   lock=self._lock)
                else:
                    self.log.warn('cannot-set-lock-uni',
                                  uni=key,
                                  value=value,
                                  lock=self._lock)

            self.deferred.callback(self)

        except Exception as e:
            self.log.exception('setting-uni-lock-state', e=e)
            self.deferred.errback(failure.Failure(e))
Example #2
0
    def first_in_sync_event(self):
        """
        This event is called on the first MIB synchronization event after
        OpenOMCI has been started. It is responsible for starting any
        other state machine and to initiate an ONU Capabilities report
        """
        if self._first_in_sync:
            self._first_in_sync = False

            # Start up the ONU Capabilities task
            self._configuration.reset()

            # Insure that the ONU-G Administrative lock is disabled
            def failure(reason):
                self.log.error('disable-admin-state-lock', reason=reason)

            frame = OntGFrame(attributes={'administrative_state': 0}).set()
            task = OmciModifyRequest(self._omci_agent, self.device_id, frame)
            self.task_runner.queue_task(task).addErrback(failure)

            # Start up any other remaining OpenOMCI state machines
            def start_state_machines(machines):
                for sm in machines:
                    self._state_machines.append(sm)
                    reactor.callLater(0, sm.start)

            self._deferred = reactor.callLater(0, start_state_machines,
                                               self._on_sync_state_machines)

            # if an ongoing upgrading is not accomplished, restart it
            if self._img_deferred is not None:
                self._image_agent.onu_bootup()
Example #3
0
    def perform_sync_time(self):
        """
        Sync the time
        """
        self.log.debug('perform-sync-time')

        try:
            device = self.omci_agent.get_device(self.device_id)

            #########################################
            # ONT-G (ME #256)
            dt = datetime.utcnow() if self._use_utc else datetime.now()

            results = yield device.omci_cc.send(OntGFrame().synchronize_time(dt))

            omci_msg = results.fields['omci_message'].fields
            status = omci_msg['success_code']
            self.log.debug('sync-time', status=status)

            if status == RC.Success:
                self.log.info('sync-time', success_info=omci_msg['success_info'] & 0x0f)

            assert status == RC.Success, 'Unexpected Response Status: {}'.format(status)

            # Successful if here
            self.deferred.callback(results)

        except TimeoutError as e:
            self.log.warn('sync-time-timeout', e=e)
            self.deferred.errback(failure.Failure(e))

        except Exception as e:
            self.log.exception('sync-time', e=e)
            self.deferred.errback(failure.Failure(e))
Example #4
0
    def send_reboot(self, timeout=DEFAULT_OMCI_TIMEOUT):
        """
        Send an ONU Device reboot request (ONU-G ME).
        """
        self.log.debug('send-mib-reboot')

        frame = OntGFrame().reboot()
        return self.send(frame, timeout)
Example #5
0
    def check_pulse(self):
        if self.enabled:
            try:
                self._defer = self._handler.omci.send(OntGFrame(self.check_item).get())
                self._defer.addCallbacks(self._heartbeat_success, self._heartbeat_fail)

            except Exception as e:
                self._defer = reactor.callLater(5, self._heartbeat_fail, e)
Example #6
0
    def send_reboot(self, timeout=DEFAULT_OMCI_TIMEOUT):
        """
        Send an ONU Device reboot request (ONU-G ME).

        NOTICE: This method is being deprecated and replaced with a tasks to preform this function
        """
        self.log.debug('send-mib-reboot')

        frame = OntGFrame().reboot()
        return self.send(frame, timeout)
Example #7
0
    def perform_reboot(self):
        """
        Perform the reboot requests

        Depending on the ONU implementation, a response may not be returned. For this
        reason, a timeout is considered successful.
        """
        self.log.info('perform-reboot')

        try:
            frame = OntGFrame().reboot(reboot_code=self._flags)
            self.strobe_watchdog()
            results = yield self._device.omci_cc.send(frame,
                                                      timeout=self._timeout)

            status = results.fields['omci_message'].fields['success_code']
            self.log.debug('reboot-status', status=status)

            # Did it fail
            if status != RC.Success.value:
                if self._flags != RebootFlags.Reboot_Unconditionally and\
                        status == RC.DeviceBusy.value:
                    raise DeviceBusy('ONU is busy, try again later')
                else:
                    msg = 'Reboot request failed with status {}'.format(status)
                    raise RebootException(msg)

            self.log.info('reboot-success')
            self.deferred.callback(self)

        except TimeoutError:
            self.log.info('timeout',
                          msg='Request timeout is not considered an error')
            self.deferred.callback(None)

        except DeviceBusy as e:
            self.log.warn('perform-reboot', msg=e)
            self.deferred.errback(failure.Failure(e))

        except Exception as e:
            self.log.exception('perform-reboot', e=e)
            self.deferred.errback(failure.Failure(e))