Exemple #1
0
    def add_onu(self, serial_number, status):
        log.info('Add ONU: {}'.format(serial_number))

        if serial_number not in status.onus:
            # Newly found and not enabled ONU, enable it now if not at max

            if len(self.onus) < self.MAX_ONUS_SUPPORTED:
                # TODO: For now, always allow any ONU

                if serial_number not in self.onus:
                    onu = Onu(serial_number, self)

                    try:
                        yield onu.create(True)

                        self.on_new_onu_discovered(onu)
                        self.onus[serial_number] = onu

                    except Exception as e:
                        log.exception('Exception during add_onu, pon: {}, onu: {}'.
                                      format(self.pon_id, onu.onu_id), e=e)
                else:
                    log.info('TODO: Code this')

            else:
                log.warning('Maximum number of ONUs already provisioned on PON {}'.
                            format(self.pon_id))
        else:
            # ONU has been enabled
            pass
Exemple #2
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:
            from alarms.onu_discovery_alarm import OnuDiscoveryAlarm
            self.log.info('onu-lookup-failure', serial_number=serial_number_64)
            OnuDiscoveryAlarm(self.olt, self.pon_id, serial_number).raise_alarm()
            return

        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 or 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 bac 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))

            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)

                    # If autoactivate (demo) mode and not reflow, activate the ONU
                    if self.olt.autoactivate:
                        self.activate_onu(onu)

                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]
Exemple #3
0
    def add_onu(self, serial_number, status):
        self.log.info('add-ONU', serial_number=serial_number)

        if serial_number not in status.onus:
            # Newly found and not enabled ONU, enable it now if not at max

            if len(self._onus) >= self.MAX_ONUS_SUPPORTED:
                self.log.warning('max-onus-provisioned')
            else:
                onu_info = self._get_onu_info(
                    Onu.serial_number_to_string(serial_number))

                if onu_info is None:
                    self.log.info('lookup-failure',
                                  serial_number=serial_number)

                elif serial_number in self._onus or onu_info[
                        'onu-id'] in self._onu_by_id:
                    self.log.warning('onu-already-added',
                                     serial_number=serial_number)

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

                    try:
                        tconts = onu_info['t-conts']
                        gem_ports = onu_info['gem-ports']
                        yield onu.create(tconts, gem_ports)
                        self.activate_onu(onu)

                        if len(self._pon_evc_map) > 0:
                            # Add gem-id's to maps
                            dl = []
                            for evc_map in self._pon_evc_map.itervalues():
                                dl = evc_map.add_onu(onu)

                            yield defer.gatherResults(dl)

                    except Exception as e:
                        del self._onus[serial_number]
                        del self._onu_by_id[onu.onu_id]
                        self.log.exception('add_onu',
                                           serial_number=serial_number,
                                           e=e)
Exemple #4
0
    def add_onu(self, serial_number, status):
        self.log.info('add-onu', serial_number=serial_number, status=status)

        if serial_number not in status.onus:
            # Newly found and not enabled ONU, enable it now if not at max

            if len(self._onus) >= self.MAX_ONUS_SUPPORTED:
                self.log.warning('max-onus-provisioned')
            else:
                onu_info = self._get_onu_info(Onu.serial_number_to_string(serial_number))

                if onu_info is None:
                    self.log.info('lookup-failure', serial_number=serial_number)

                elif serial_number in self._onus or onu_info['onu-id'] in self._onu_by_id:
                    self.log.warning('onu-already-added', serial_number=serial_number)

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

                    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
                            if gem_port.multicast:
                                self.add_mcast_gem_port(gem_port, -id_or_vid)

                        yield onu.create(tconts, gem_ports)
                        self.activate_onu(onu)

                    except Exception as e:
                        del self._onus[serial_number]
                        del self._onu_by_id[onu.onu_id]
                        self.log.exception('add-onu', serial_number=serial_number, e=e)
Exemple #5
0
    def add_onu(self, serial_number, status):
        self.log.info('add-ONU', serial_number=serial_number)

        if serial_number not in status.onus:
            # Newly found and not enabled ONU, enable it now if not at max

            if len(self._onus) >= self.MAX_ONUS_SUPPORTED:
                self.log.warning('max-onus-provisioned')
            else:
                onu_info = self._get_onu_info(
                    Onu.serial_number_to_string(serial_number))

                if onu_info is None:
                    self.log.info('lookup-failure',
                                  serial_number=serial_number)

                elif serial_number in self._onus or onu_info[
                        'onu-id'] in self._onu_by_id:
                    self.log.warning('onu-already-added',
                                     serial_number=serial_number)

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

                    try:
                        yield onu.create(onu_info)
                        self.activate_onu(onu)

                    except Exception as e:
                        del self._onus[serial_number]
                        del self._onu_by_id[onu.onu_id]
                        self.log.exception('add_onu',
                                           serial_number=serial_number,
                                           e=e)
Exemple #6
0
    def add_onu(self, serial_number, status):
        self.log.info('add-onu', serial_number=serial_number, status=status)

        onu_info = self._get_onu_info(Onu.serial_number_to_string(serial_number))

        if onu_info is None:
            self.log.info('lookup-failure', serial_number=serial_number)

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

            if onu_info['onu-id'] in self._active_los_alarms:
                try:
                    yield self._remove_from_hardware(onu_info['onu-id'])

                except Exception as e:
                    self.log.exception('los-cleanup', e=e)

            if serial_number in self._onus or onu_info['onu-id'] in self._onu_by_id:
                # May be here due to unmanaged power-cycle on OLT

                self.log.info('onu-already-added', serial_number=serial_number)

                assert serial_number in self._onus and\
                       onu_info['onu-id'] in self._onu_by_id, \
                    'ONU not in both lists'

                # Recover ONU information and attempt to reflow TCONT/GEM-PORT
                # information as well

                onu = self._onus[serial_number]
                reflow = True

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

            else:
                # TODO: Make use of upstream_channel_speed variable
                onu = Onu(onu_info)
                reflow = False
                self._onus[serial_number] = 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)
                                self.add_mcast_gem_port(gem_port, -id_or_vid)
                        except Exception as e:
                            self.log.exception('id-or-vid', e=e)

                    yield onu.create(tconts, gem_ports, reflow=reflow)

                    # If autoactivate (demo) mode and not reflow, activate the ONU
                    if self.olt.autoactivate and not reflow:
                        self.activate_onu(onu)

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

                    if not reflow:
                        del self._onus[serial_number]
                        del self._onu_by_id[onu.onu_id]
Exemple #7
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]
Exemple #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')

        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)
Exemple #9
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)
Exemple #10
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)