Exemplo n.º 1
0
    def onu_discovery_indication(self, onu_disc_indication):
        intf_id = onu_disc_indication.intf_id
        serial_number = onu_disc_indication.serial_number
        serial_number_str = OpenoltUtils.stringify_serial_number(serial_number)

        self.log.debug("onu discovery indication",
                       intf_id=intf_id,
                       serial_number=serial_number_str)

        # Post ONU Discover alarm  20180809_0805
        try:
            OnuDiscoveryAlarm(self.alarm_mgr.alarms,
                              pon_id=intf_id,
                              serial_number=serial_number_str).raise_alarm()
        except Exception as disc_alarm_error:
            self.log.exception("onu-discovery-alarm-error",
                               errmsg=disc_alarm_error.message)
            # continue for now.

        try:
            onu_id = self.data_model.onu_id(serial_number=serial_number_str)
        except ValueError:
            # FIXME - resource_mgr.get_onu_id() should raise exception
            onu_id = self.resource_mgr.get_onu_id(intf_id)
            if onu_id is None:
                raise Exception("onu-id-unavailable")

        self.data_model.onu_create(intf_id, onu_id, serial_number_str)

        self.activate_onu(intf_id, onu_id, serial_number, serial_number_str)
Exemplo n.º 2
0
    def onu_discovery_indication(self, onu_disc_indication):
        intf_id = onu_disc_indication.intf_id
        serial_number = onu_disc_indication.serial_number

        serial_number_str = self.stringify_serial_number(serial_number)

        self.log.debug("onu discovery indication",
                       intf_id=intf_id,
                       serial_number=serial_number_str)

        # Post ONU Discover alarm  20180809_0805
        try:
            OnuDiscoveryAlarm(self.alarm_mgr.alarms,
                              pon_id=intf_id,
                              serial_number=serial_number_str).raise_alarm()
        except Exception as disc_alarm_error:
            self.log.exception("onu-discovery-alarm-error",
                               errmsg=disc_alarm_error.message)
            # continue for now.

        onu_device = self.adapter_agent.get_child_device(
            self.device_id, serial_number=serial_number_str)

        if onu_device is None:
            onu_id = self.new_onu_id(intf_id)
            try:
                self.add_onu_device(
                    intf_id,
                    self.platform.intf_id_to_port_no(intf_id, Port.PON_OLT),
                    onu_id, serial_number)
                self.activate_onu(intf_id, onu_id, serial_number,
                                  serial_number_str)
            except Exception as e:
                self.log.exception('onu-activation-failed', e=e)

        else:
            if onu_device.connect_status != ConnectStatus.REACHABLE:
                onu_device.connect_status = ConnectStatus.REACHABLE
                self.adapter_agent.update_device(onu_device)

            onu_id = onu_device.proxy_address.onu_id
            if onu_device.oper_status == OperStatus.DISCOVERED \
               or onu_device.oper_status == OperStatus.ACTIVATING:
                self.log.debug("ignore onu discovery indication, \
                               the onu has been discovered and should be \
                               activating shorlty",
                               intf_id=intf_id,
                               onu_id=onu_id,
                               state=onu_device.oper_status)
            elif onu_device.oper_status == OperStatus.ACTIVE:
                self.log.warn("onu discovery indication whereas onu is \
                              supposed to be active",
                              intf_id=intf_id,
                              onu_id=onu_id,
                              state=onu_device.oper_status)
            elif onu_device.oper_status == OperStatus.UNKNOWN:
                self.log.info("onu in unknown state, recovering from olt \
                              reboot probably, activate onu",
                              intf_id=intf_id,
                              onu_id=onu_id,
                              serial_number=serial_number_str)

                onu_device.oper_status = OperStatus.DISCOVERED
                self.adapter_agent.update_device(onu_device)
                try:
                    self.activate_onu(intf_id, onu_id, serial_number,
                                      serial_number_str)
                except Exception as e:
                    self.log.error('onu-activation-error',
                                   serial_number=serial_number_str,
                                   error=e)
            else:
                self.log.warn('unexpected state',
                              onu_id=onu_id,
                              onu_device_oper_state=onu_device.oper_status)
Exemplo n.º 3
0
    def onu_discovery_indication(self, onu_disc_indication):
        intf_id = onu_disc_indication.intf_id
        serial_number = onu_disc_indication.serial_number

        serial_number_str = self.stringify_serial_number(serial_number)

        self.log.debug("onu discovery indication",
                       intf_id=intf_id,
                       serial_number=serial_number_str)

        # Post ONU Discover alarm  20180809_0805
        try:
            OnuDiscoveryAlarm(self.alarm_mgr.alarms,
                              pon_id=intf_id,
                              serial_number=serial_number_str).raise_alarm()
        except Exception as disc_alarm_error:
            self.log.exception("onu-discovery-alarm-error",
                               errmsg=disc_alarm_error.message)
            # continue for now.

        onu_device = self.adapter_agent.get_child_device(
            self.device_id, serial_number=serial_number_str)

        if onu_device is None:
            try:
                onu_id = yield self.resource_manager.get_resource_id(
                    intf_id, PONResourceManager.ONU_ID)
                if onu_id is None:
                    raise Exception("onu-id-unavailable")

                pon_intf_onu_id = (intf_id, onu_id)
                self.resource_manager.init_resource_store(pon_intf_onu_id)

                alloc_id = yield self.resource_manager.get_alloc_id(
                    pon_intf_onu_id)
                if alloc_id is None:
                    # Free up other PON resources if are unable to
                    # proceed ahead
                    self.resource_manager.free_resource_id(
                        intf_id, PONResourceManager.ONU_ID, onu_id)
                    raise Exception("alloc-id-unavailable")

                self.add_onu_device(
                    intf_id,
                    platform.intf_id_to_port_no(intf_id, Port.PON_OLT), onu_id,
                    serial_number)
                # Use sched_id same as alloc_id for the ONU.
                self.activate_onu(intf_id, onu_id, serial_number,
                                  serial_number_str, alloc_id, alloc_id)
            except Exception as e:
                self.log.exception('onu-activation-failed', e=e)

        else:
            if onu_device.connect_status != ConnectStatus.REACHABLE:
                onu_device.connect_status = ConnectStatus.REACHABLE
                self.adapter_agent.update_device(onu_device)

            onu_id = onu_device.proxy_address.onu_id
            if onu_device.oper_status == OperStatus.DISCOVERED \
               or onu_device.oper_status == OperStatus.ACTIVATING:
                self.log.debug("ignore onu discovery indication, \
                               the onu has been discovered and should be \
                               activating shorlty",
                               intf_id=intf_id,
                               onu_id=onu_id,
                               state=onu_device.oper_status)
            elif onu_device.oper_status == OperStatus.ACTIVE:
                self.log.warn("onu discovery indication whereas onu is \
                              supposed to be active",
                              intf_id=intf_id,
                              onu_id=onu_id,
                              state=onu_device.oper_status)
            elif onu_device.oper_status == OperStatus.UNKNOWN:
                self.log.info("onu in unknown state, recovering from olt \
                              reboot probably, activate onu",
                              intf_id=intf_id,
                              onu_id=onu_id,
                              serial_number=serial_number_str)

                onu_device.oper_status = OperStatus.DISCOVERED
                self.adapter_agent.update_device(onu_device)
                try:
                    pon_intf_onu_id = (intf_id, onu_id)
                    alloc_id = yield self.resource_manager.get_alloc_id(
                        pon_intf_onu_id)
                    # Use sched_id same as alloc_id for the ONU.
                    self.activate_onu(intf_id, onu_id, serial_number,
                                      serial_number_str, alloc_id, alloc_id)
                except Exception as e:
                    self.log.error('onu-activation-error',
                                   serial_number=serial_number_str,
                                   error=e)
            else:
                self.log.warn('unexpected state',
                              onu_id=onu_id,
                              onu_device_oper_state=onu_device.oper_status)
Exemplo n.º 4
0
    def add_onu(self, serial_number_64, status):
        serial_number = Onu.serial_number_to_string(serial_number_64)
        self.log.info('add-onu',
                      serial_number=serial_number,
                      serial_number_64=serial_number_64,
                      status=status)
        onu_info = self._get_onu_info(serial_number)

        if onu_info is None:
            self.log.info('onu-lookup-failure',
                          serial_number=serial_number,
                          serial_number_64=serial_number_64)
            OnuDiscoveryAlarm(self.olt.alarms, self.pon_id,
                              serial_number).raise_alarm()
            returnValue('new-onu')

        if serial_number_64 not in status.onus or onu_info[
                'onu-id'] in self._active_los_alarms:
            onu = None
            onu_id = onu_info['onu-id']

            if serial_number_64 in self._onus and onu_id in self._onu_by_id:
                # Handles fast entry into this task before FPGA can set/clear results
                returnValue('sticky-onu')

            elif (serial_number_64 in self._onus and onu_id not in self._onu_by_id) or \
                    (serial_number_64 not in self._onus and onu_id in self._onu_by_id):
                # May be here due to unmanaged power-cycle on OLT or fiber bounced for a
                # previously activated ONU. Drop it and add back on next discovery cycle
                self.delete_onu(onu_id)

            elif len(self._onus) >= self.MAX_ONUS_SUPPORTED:
                self.log.warning('max-onus-provisioned', count=len(self._onus))
                returnValue('max-onus-reached')

            else:
                # TODO: Make use of upstream_channel_speed variable
                onu = Onu(onu_info)
                self._onus[serial_number_64] = onu
                self._onu_by_id[onu.onu_id] = onu

            if onu is not None:
                try:
                    tconts = onu_info['t-conts']
                    gem_ports = onu_info['gem-ports']

                    # Add Multicast to PON on a per-ONU basis until xPON multicast support is ready
                    # In xPON/BBF, mcast gems tie back to the channel-pair
                    # MCAST VLAN IDs stored as a negative value

                    for id_or_vid, gem_port in gem_ports.iteritems(
                    ):  # TODO: Deprecate this when BBF ready
                        try:
                            if gem_port.multicast:
                                self.log.debug('id-or-vid',
                                               id_or_vid=id_or_vid)
                                vid = self.olt.multicast_vlans[0] if len(
                                    self.olt.multicast_vlans) else None
                                if vid is not None:
                                    self.add_mcast_gem_port(gem_port, vid)
                        except Exception as e:
                            self.log.exception('id-or-vid', e=e)

                    yield onu.create(tconts, gem_ports)

                except Exception as e:
                    self.log.exception('add-onu',
                                       serial_number=serial_number_64,
                                       e=e)
                    del self._onus[serial_number_64]
                    del self._onu_by_id[onu.onu_id]
Exemplo n.º 5
0
    def simulate_alarm(self, alarm):
        if alarm.indicator == "los":
            alarm_obj = OltLosAlarm(self.adapter_alarms,
                                    intf_id=alarm.intf_id,
                                    port_type_name=alarm.port_type_name)
        elif alarm.indicator == "dying_gasp":
            alarm_obj = OnuDyingGaspAlarm(self.adapter_alarms,
                                          onu_id=alarm.onu_device_id,
                                          intf_id=alarm.intf_id)
        elif alarm.indicator == "onu_los":
            alarm_obj = OnuLosAlarm(self.adapter_alarms,
                                    onu_id=alarm.onu_device_id,
                                    intf_id=alarm.intf_id)
        elif alarm.indicator == "onu_lopc_miss":
            alarm_obj = OnuLopcMissAlarm(self.adapter_alarms,
                                         onu_id=alarm.onu_device_id,
                                         intf_id=alarm.intf_id)
        elif alarm.indicator == "onu_lopc_mic":
            alarm_obj = OnuLopcMicErrorAlarm(self.adapter_alarms,
                                             onu_id=alarm.onu_device_id,
                                             intf_id=alarm.intf_id)
        elif alarm.indicator == "onu_lob":
            alarm_obj = OnuLobAlarm(self.adapter_alarms,
                                    onu_id=alarm.onu_device_id,
                                    intf_id=alarm.intf_id)
        elif alarm.indicator == "onu_startup":
            alarm_obj = OnuStartupAlarm(self.adapter_alarms,
                                        intf_id=alarm.intf_id,
                                        onu_id=alarm.onu_device_id)
        elif alarm.indicator == "onu_signal_degrade":
            alarm_obj = OnuSignalDegradeAlarm(
                self.adapter_alarms,
                intf_id=alarm.intf_id,
                onu_id=alarm.onu_device_id,
                inverse_bit_error_rate=alarm.inverse_bit_error_rate)
        elif alarm.indicator == "onu_drift_of_window":
            alarm_obj = OnuWindowDriftAlarm(self.adapter_alarms,
                                            intf_id=alarm.intf_id,
                                            onu_id=alarm.onu_device_id,
                                            drift=alarm.drift,
                                            new_eqd=alarm.new_eqd)
        elif alarm.indicator == "onu_signal_fail":
            alarm_obj = OnuSignalFailAlarm(
                self.adapter_alarms,
                intf_id=alarm.intf_id,
                onu_id=alarm.onu_device_id,
                inverse_bit_error_rate=alarm.inverse_bit_error_rate)
        elif alarm.indicator == "onu_activation":
            alarm_obj = OnuActivationFailAlarm(self.adapter_alarms,
                                               intf_id=alarm.intf_id,
                                               onu_id=alarm.onu_device_id)
        elif alarm.indicator == "onu_discovery":
            alarm_obj = OnuDiscoveryAlarm(
                self.adapter_alarms,
                pon_id=alarm.intf_id,
                serial_number=alarm.onu_serial_number)
        else:
            raise Exception("Unknown alarm indicator %s" % alarm.indicator)

        if alarm.operation == alarm.RAISE:
            alarm_obj.raise_alarm()
        elif alarm.operation == alarm.CLEAR:
            alarm_obj.clear_alarm()
        else:
            # This shouldn't happen
            raise Exception("Unknown alarm operation")
Exemplo n.º 6
0
    def add_onu(self, serial_number_64, status):
        """
        Add an ONU to the PON

        :param serial_number_64: (str) base-64 encoded serial number
        :param status: (dict) OLT PON status. Used to detect if ONU is already provisioned
        """
        serial_number = Onu.serial_number_to_string(serial_number_64)
        self.log.info('add-onu',
                      serial_number=serial_number,
                      serial_number_64=serial_number_64,
                      status=status)

        # It takes a little while for a new ONU to be removed from the discovery
        # list. Return early here so extra ONU IDs are not allocated
        if serial_number_64 in self._onus:
            returnValue('wait-for-fpga')

        onu_info, activate_onu = self._get_onu_info(serial_number)

        if activate_onu:
            alarm = OnuDiscoveryAlarm(self.olt.alarms, self.pon_id,
                                      serial_number)
            reactor.callLater(0, alarm.raise_alarm)

        if serial_number_64 not in status.onus:  # or onu_info['onu-id'] not in self._active_los_alarms:
            onu = None
            onu_id = onu_info['onu-id']

            # At our limit?   TODO: Retrieve from device resource manager if available
            if len(self._onus) >= self.MAX_ONUS_SUPPORTED:
                self.log.warning('max-onus-provisioned', count=len(self._onus))
                returnValue('max-onus-reached')

            else:
                # TODO: Make use of upstream_channel_speed variable
                onu = Onu(onu_info)
                self._onus[serial_number_64] = onu
                self._onu_by_id[onu.onu_id] = onu

            if onu is not None:
                tconts = onu_info.pop('t-conts')
                gem_ports = onu_info.pop('gem-ports')

                if activate_onu:
                    _onu_device = self._parent.add_onu_device(
                        self.pon_id,  # PON ID
                        onu.onu_id,  # ONU ID
                        serial_number,
                        tconts,
                        gem_ports)
                try:
                    # Add Multicast to PON on a per-ONU basis until xPON multicast support
                    # is ready
                    # In xPON/BBF, mcast gems tie back to the channel-pair
                    # MCAST VLAN IDs stored as a negative value

                    # for id_or_vid, gem_port in gem_ports.iteritems():  # TODO: Deprecate this when BBF ready
                    #     try:
                    #         if gem_port.multicast:
                    #             self.log.debug('id-or-vid', id_or_vid=id_or_vid)
                    #             vid = self.olt.multicast_vlans[0] if len(self.olt.multicast_vlans) else None
                    #             if vid is not None:
                    #                 self.add_mcast_gem_port(gem_port, vid)
                    #
                    #     except Exception as e:
                    #         self.log.exception('id-or-vid', e=e)

                    # TODO: Need to clean up TCont and GEM-Port on ONU delete in non-xPON mode
                    _results = yield onu.create(tconts, gem_ports)

                except Exception as e:
                    self.log.exception('add-onu',
                                       serial_number=serial_number_64,
                                       e=e)
Exemplo n.º 7
0
    def add_onu(self, serial_number_64, status):
        """
        Add an ONU to the PON

        TODO:  This needs major refactoring after xPON is deprecated to be more maintainable
        """
        serial_number = Onu.serial_number_to_string(serial_number_64)
        self.log.info('add-onu',
                      serial_number=serial_number,
                      serial_number_64=serial_number_64,
                      status=status)

        # It takes a little while for a new ONU to be removed from the discovery
        # list. Return early here so extra ONU IDs are not allocated
        if serial_number_64 in self._onus:
            returnValue('wait-for-fpga')

        onu_info, activate_onu = self._get_onu_info(serial_number)

        if activate_onu:
            alarm = OnuDiscoveryAlarm(self.olt.alarms, self.pon_id,
                                      serial_number)
            reactor.callLater(0, alarm.raise_alarm)

        if serial_number_64 not in status.onus or onu_info[
                'onu-id'] in self._active_los_alarms:
            onu = None
            onu_id = onu_info['onu-id']

            if serial_number_64 in self._onus and onu_id in self._onu_by_id:
                # Handles fast entry into this task before FPGA can set/clear results
                returnValue('sticky-onu')

            elif (serial_number_64 in self._onus and onu_id not in self._onu_by_id) or \
                    (serial_number_64 not in self._onus and onu_id in self._onu_by_id):
                # May be here due to unmanaged power-cycle on OLT or fiber bounced for a
                # previously activated ONU.
                #
                # TODO: Track when the ONU was discovered, and if > some maximum amount
                #       place the ONU (with serial number & ONU ID) on a wait list and
                #       use that to recover the ONU ID should it show up within a
                #       reasonable amount of time.  Periodically groom the wait list and
                #       delete state ONUs so we can reclaim the ONU ID.
                #
                returnValue('waiting-for-fpga')  # non-XPON mode will not

            elif len(self._onus) >= self.MAX_ONUS_SUPPORTED:
                self.log.warning('max-onus-provisioned', count=len(self._onus))
                returnValue('max-onus-reached')

            else:
                # TODO: Make use of upstream_channel_speed variable
                onu = Onu(onu_info)
                self._onus[serial_number_64] = onu
                self._onu_by_id[onu.onu_id] = onu

            if onu is not None:
                tconts = onu_info.pop('t-conts')
                gem_ports = onu_info.pop('gem-ports')

                if activate_onu:
                    _onu_device = self._parent.add_onu_device(
                        self._port_no,  # PON ID
                        onu.onu_id,  # ONU ID
                        serial_number,
                        tconts,
                        gem_ports)
                try:
                    # Add Multicast to PON on a per-ONU basis until xPON multicast support
                    # is ready
                    # In xPON/BBF, mcast gems tie back to the channel-pair
                    # MCAST VLAN IDs stored as a negative value

                    # for id_or_vid, gem_port in gem_ports.iteritems():  # TODO: Deprecate this when BBF ready
                    #     try:
                    #         if gem_port.multicast:
                    #             self.log.debug('id-or-vid', id_or_vid=id_or_vid)
                    #             vid = self.olt.multicast_vlans[0] if len(self.olt.multicast_vlans) else None
                    #             if vid is not None:
                    #                 self.add_mcast_gem_port(gem_port, vid)
                    #
                    #     except Exception as e:
                    #         self.log.exception('id-or-vid', e=e)

                    # TODO: Need to clean up TCont and GEM-Port on ONU delete in non-xPON mode
                    _results = yield onu.create(tconts, gem_ports)

                except Exception as e:
                    self.log.exception('add-onu',
                                       serial_number=serial_number_64,
                                       e=e)
Exemplo n.º 8
0
    def add_onu(self, serial_number_64, status):
        """
        Add an ONU to the PON

        :param serial_number_64: (str) base-64 encoded serial number
        :param status: (dict) OLT PON status. Used to detect if ONU is already provisioned
        """
        serial_number = Onu.serial_number_to_string(serial_number_64)
        self.log.info('add-onu', serial_number=serial_number,
                      serial_number_64=serial_number_64, status=status)

        # It takes a little while for a new ONU to be removed from the discovery
        # list. Return early here so extra ONU IDs are not allocated
        if serial_number_64 in self._onus:
            returnValue('wait-for-fpga')

        if serial_number_64 in status.onus:
            # Handles fast entry into this task before FPGA can clear results of ONU delete
            returnValue('sticky-onu')

        # At our limit?   TODO: Retrieve from device resource manager if available
        if len(self._onus) >= self.MAX_ONUS_SUPPORTED:
            self.log.warning('max-onus-provisioned', count=len(self._onus))
            returnValue('max-onus-reached')

        onu_info = self._get_onu_info(serial_number)
        onu_id = onu_info['onu-id']

        if onu_id is None:
            self.log.warning('no-onu-ids-available', serial_number=serial_number,
                             serial_number_64=serial_number_64)
            returnValue('no-ids-available')

        # TODO: Is the best before or after creation in parent device?
        alarm = OnuDiscoveryAlarm(self.olt.alarms, self.pon_id, serial_number)
        reactor.callLater(0, alarm.raise_alarm)

        # Have the core create the ONU device
        self._parent.add_onu_device(self.pon_id, onu_id, serial_number)

        try:
            onu = Onu(onu_info)
            self._onus[serial_number_64] = onu
            self._onu_by_id[onu.onu_id] = onu

            # Add Multicast to PON on a per-ONU basis
            #
            # for id_or_vid, gem_port in gem_ports.iteritems():
            #     try:
            #         if gem_port.multicast:
            #             self.log.debug('id-or-vid', id_or_vid=id_or_vid)
            #             vid = self.olt.multicast_vlans[0] if len(self.olt.multicast_vlans) else None
            #             if vid is not None:
            #                 self.add_mcast_gem_port(gem_port, vid)
            #
            #     except Exception as e:
            #         self.log.exception('id-or-vid', e=e)

            _results = yield onu.create()

        except Exception as e:
            self.log.warning('add-onu', serial_number=serial_number_64, e=e)