Пример #1
0
 def remove_gemport(self, data):
     self.log.debug('remove-gemport', data=data)
     gem_port = GemportsConfigData()
     gem_port.CopyFrom(data)
     device = self.adapter_agent.get_device(self.device_id)
     if device.connect_status != ConnectStatus.REACHABLE:
         self.log.error('device-unreachable')
         return
Пример #2
0
def createGemPort(name, enet, tcont, id):

    gem_port_request = GemportsConfigData()
    log.debug("FOUNDRY-creating-gemport-config",
              config=gem_port_request,
              name=name,
              enet=enet,
              tcont=tcont,
              gemPortId=id)

    try:
        gem_port_request.name = name
        gem_port_request.itf_ref = enet
        gem_port_request.traffic_class = 2
        gem_port_request.aes_indicator = True
        gem_port_request.tcont_ref = tcont
        gem_port_request.gemport_id = id

        log.debug("FOUNDRY-gemport-config-prepared",
                  config=gem_port_request,
                  name=name,
                  enet=enet,
                  tcont=tcont,
                  gemPortId=id)
    except Exception as e:
        log.error("FOUNDRY-gemport-config-error",
                  exception=e,
                  config=gem_port_request,
                  name=name,
                  enet=enet,
                  tcont=tcont,
                  gemPortId=id)

    try:
        log.debug("FOUNDRY-gemport-grpc-call",
                  config=gem_port_request,
                  name=name,
                  enet=enet,
                  tcont=tcont,
                  gemPortId=id)
        stub.CreateGemportsConfigData(gem_port_request)
        log.info("FOUNDRY-autodetection-gemport-created",
                 config=gem_port_request,
                 name=name,
                 enet=enet,
                 tcont=tcont,
                 gemPortId=id)
    except Exception as e:
        log.error("FOUNDRY-gemport-config-grpc-call-error",
                  exception=e,
                  config=gem_port_request,
                  name=name,
                  enet=enet,
                  tcont=tcont,
                  gemPortId=id)
Пример #3
0
    def create_xpon_gem_port(self, onu_id, index, tcont):
        # gem port creation (this initial one is for untagged ONU data support / EAPOL)
        gem_port = GemportsConfigData()
        gem_port.gemport_id = platform.mk_gemport_id(self.pon_id,
                                                     onu_id,
                                                     idx=index)
        gem_port.name = 'gem-{}-{}-{}'.format(self.pon_id, onu_id,
                                              gem_port.gemport_id)

        gem_port.tcont_ref = tcont.name
        gp = {
            'name': gem_port.name,
            'gemport-id': gem_port.gemport_id,
            'tcont-ref': gem_port.tcont_ref,
            'encryption': False,
            'traffic-class': 0,
            'data': gem_port
        }
        return gem_port, gp
Пример #4
0
    def create_xpon_gem_port(self, onu_id, index, tcont):
        # gem port creation (this initial one is for untagged ONU data support / EAPOL)
        gem_port = GemportsConfigData()
        gem_port.name = 'gem-{}-{}-{}'.format(self.pon_id, onu_id,
                                              gem_port.gemport_id)
        pon_intf_onu_id = (self.pon_id, onu_id)
        gem_port.gemport_id = self._parent.resource_mgr.get_gemport_id(
            pon_intf_onu_id)
        # TODO: Add release of alloc_id on ONU delete and/or TCONT delete

        gem_port.tcont_ref = tcont.name
        gp = {
            'name': gem_port.name,
            'gemport-id': gem_port.gemport_id,
            'tcont-ref': gem_port.tcont_ref,
            'encryption': False,
            'traffic-class': 0,
            'data': gem_port
        }
        return gem_port, gp
Пример #5
0
    def create_gemport(self, data):
        self.log.debug('create-gemport', data=data)
        gem_portdata = GemportsConfigData()
        gem_portdata.CopyFrom(data)

        # TODO: fill in what i have.  This needs to be provided from the OLT
        # currently its hardcoded/static
        gemdict = dict()
        gemdict['gemport-id'] = gem_portdata.gemport_id
        gemdict['encryption'] = gem_portdata.aes_indicator
        gemdict['tcont-ref'] = int(gem_portdata.tcont_ref)
        gemdict['name'] = gem_portdata.gemport_id
        gemdict['traffic-class'] = gem_portdata.traffic_class
        gemdict['traffic-class'] = gem_portdata.traffic_class

        gem_port = OnuGemPort.create(self, gem_port=gemdict, entity_id=self._pon.next_gem_entity_id)

        self._pon.add_gem_port(gem_port)

        self.log.debug('pon-add-gemport', gem_port=gem_port)
Пример #6
0
    def onu_indication(self, onu_indication):
        self.log.debug("onu indication",
                       intf_id=onu_indication.intf_id,
                       onu_id=onu_indication.onu_id,
                       serial_number=onu_indication.serial_number,
                       oper_state=onu_indication.oper_state,
                       admin_state=onu_indication.admin_state)
        try:
            serial_number_str = self.stringify_serial_number(
                onu_indication.serial_number)
        except Exception as e:
            serial_number_str = None

        if serial_number_str is not None:
            onu_device = self.adapter_agent.get_child_device(
                self.device_id, serial_number=serial_number_str)
        else:
            onu_device = self.adapter_agent.get_child_device(
                self.device_id,
                parent_port_no=self.platform.intf_id_to_port_no(
                    onu_indication.intf_id, Port.PON_OLT),
                onu_id=onu_indication.onu_id)

        if onu_device is None:
            self.log.error('onu not found',
                           intf_id=onu_indication.intf_id,
                           onu_id=onu_indication.onu_id)
            return

        if self.platform.intf_id_from_pon_port_no(onu_device.parent_port_no) \
                != onu_indication.intf_id:
            self.log.warn(
                'ONU-is-on-a-different-intf-id-now',
                previous_intf_id=self.platform.intf_id_from_pon_port_no(
                    onu_device.parent_port_no),
                current_intf_id=onu_indication.intf_id)
            # FIXME - handle intf_id mismatch (ONU move?)

        if onu_device.proxy_address.onu_id != onu_indication.onu_id:
            # FIXME - handle onu id mismatch
            self.log.warn(
                'ONU-id-mismatch, can happen if both voltha and '
                'the olt rebooted',
                expected_onu_id=onu_device.proxy_address.onu_id,
                received_onu_id=onu_indication.onu_id)

        uni_no = self.platform.mk_uni_port_num(onu_indication.intf_id,
                                               onu_indication.onu_id)
        uni_name = self.port_name(uni_no,
                                  Port.ETHERNET_UNI,
                                  serial_number=onu_device.serial_number)

        self.log.debug('port-number-ready', uni_no=uni_no, uni_name=uni_name)

        # Admin state
        if onu_indication.admin_state == 'down':
            if onu_indication.oper_state != 'down':
                self.log.error('ONU-admin-state-down-and-oper-status-not-down',
                               oper_state=onu_indication.oper_state)
                # Forcing the oper state change code to execute
                onu_indication.oper_state = 'down'

            # Port and logical port update is taken care of by oper state block

        elif onu_indication.admin_state == 'up':
            pass

        else:
            self.log.warn('Invalid-or-not-implemented-admin-state',
                          received_admin_state=onu_indication.admin_state)

        self.log.debug('admin-state-dealt-with')

        onu_adapter_agent = \
            registry('adapter_loader').get_agent(onu_device.adapter)
        if onu_adapter_agent is None:
            self.log.error('onu_adapter_agent-could-not-be-retrieved',
                           onu_device=onu_device)
            return

        # Operating state
        if onu_indication.oper_state == 'down':

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

            # Move to discovered state
            self.log.debug('onu-oper-state-is-down')

            if onu_device.oper_status != OperStatus.DISCOVERED:
                onu_device.oper_status = OperStatus.DISCOVERED
                self.adapter_agent.update_device(onu_device)
            # Set port oper state to Discovered
            self.onu_ports_down(onu_device, uni_no, uni_name,
                                OperStatus.DISCOVERED)

            if onu_device.adapter == 'brcm_openomci_onu':
                self.log.debug('using-brcm_openomci_onu')
                onu_adapter_agent.update_interface(onu_device,
                                                   {'oper_state': 'down'})

        elif onu_indication.oper_state == 'up':

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

            if onu_device.oper_status != OperStatus.DISCOVERED:
                self.log.debug("ignore onu indication",
                               intf_id=onu_indication.intf_id,
                               onu_id=onu_indication.onu_id,
                               state=onu_device.oper_status,
                               msg_oper_state=onu_indication.oper_state)
                return

            # Device was in Discovered state, setting it to active

            # Prepare onu configuration
            # If we are using the old/current broadcom adapter otherwise
            # use the openomci adapter
            if onu_device.adapter == 'broadcom_onu':
                self.log.debug('using-broadcom_onu')

                # onu initialization, base configuration (bridge setup ...)
                def onu_initialization():

                    onu_adapter_agent.adapter.devices_handlers[onu_device.id] \
                                     .message_exchange()
                    self.log.debug('broadcom-message-exchange-started')

                # tcont creation (onu)
                tcont = TcontsConfigData()
                tcont.alloc_id = self.platform.mk_alloc_id(
                    onu_indication.intf_id, onu_indication.onu_id)

                # gem port creation
                gem_port = GemportsConfigData()
                gem_port.gemport_id = self.platform.mk_gemport_id(
                    onu_indication.intf_id, onu_indication.onu_id)

                # ports creation/update
                def port_config():

                    # "v_enet" creation (olt)

                    # add_port update port when it exists
                    self.adapter_agent.add_port(
                        self.device_id,
                        Port(port_no=uni_no,
                             label=uni_name,
                             type=Port.ETHERNET_UNI,
                             admin_state=AdminState.ENABLED,
                             oper_status=OperStatus.ACTIVE))

                    # v_enet creation (onu)

                    venet = VEnetConfig(name=uni_name)
                    venet.interface.name = uni_name
                    onu_adapter_agent.create_interface(onu_device, venet)

                # ONU device status update in the datastore
                def onu_update_oper_status():
                    onu_device.oper_status = OperStatus.ACTIVE
                    onu_device.connect_status = ConnectStatus.REACHABLE
                    self.adapter_agent.update_device(onu_device)

                # FIXME : the asynchronicity has to be taken care of properly
                onu_initialization()
                reactor.callLater(10,
                                  onu_adapter_agent.create_tcont,
                                  device=onu_device,
                                  tcont_data=tcont,
                                  traffic_descriptor_data=None)
                reactor.callLater(11, onu_adapter_agent.create_gemport,
                                  onu_device, gem_port)
                reactor.callLater(12, port_config)
                reactor.callLater(12, onu_update_oper_status)

            elif onu_device.adapter == 'brcm_openomci_onu':
                self.log.debug('using-brcm_openomci_onu')

                # tcont creation (onu)
                tcont = TcontsConfigData()
                tcont.alloc_id = self.platform.mk_alloc_id(
                    onu_indication.intf_id, onu_indication.onu_id)

                # gem port creation
                gem_port = GemportsConfigData()
                gem_port.gemport_id = self.platform.mk_gemport_id(
                    onu_indication.intf_id, onu_indication.onu_id)
                gem_port.tcont_ref = str(tcont.alloc_id)

                self.log.info('inject-tcont-gem-data-onu-handler',
                              onu_indication=onu_indication,
                              tcont=tcont,
                              gem_port=gem_port)

                onu_adapter_agent.create_tcont(onu_device,
                                               tcont,
                                               traffic_descriptor_data=None)
                onu_adapter_agent.create_gemport(onu_device, gem_port)
                onu_adapter_agent.create_interface(onu_device, onu_indication)

            else:
                self.log.error('unsupported-openolt-onu-adapter')

        else:
            self.log.warn('Not-implemented-or-invalid-value-of-oper-state',
                          oper_state=onu_indication.oper_state)
Пример #7
0
    def onu_indication(self, onu_indication):
        self.log.debug("onu indication",
                       intf_id=onu_indication.intf_id,
                       onu_id=onu_indication.onu_id,
                       serial_number=onu_indication.serial_number,
                       oper_state=onu_indication.oper_state,
                       admin_state=onu_indication.admin_state)
        try:
            serial_number_str = self.stringify_serial_number(
                onu_indication.serial_number)
        except Exception as e:
            serial_number_str = None

        if serial_number_str is not None:
            onu_device = self.adapter_agent.get_child_device(
                self.device_id, serial_number=serial_number_str)
        else:
            onu_device = self.adapter_agent.get_child_device(
                self.device_id,
                parent_port_no=platform.intf_id_to_port_no(
                    onu_indication.intf_id, Port.PON_OLT),
                onu_id=onu_indication.onu_id)

        if onu_device is None:
            self.log.error('onu not found',
                           intf_id=onu_indication.intf_id,
                           onu_id=onu_indication.onu_id)
            return

        # We will use this alloc_id and gemport_id to pass on to the onu adapter
        pon_intf_onu_id = (onu_indication.intf_id, onu_indication.onu_id)
        alloc_id = yield self.resource_manager.get_alloc_id(pon_intf_onu_id)
        gemport_id = yield self.resource_manager.get_gemport_id(
            pon_intf_onu_id)

        if platform.intf_id_from_pon_port_no(onu_device.parent_port_no) \
                != onu_indication.intf_id:
            self.log.warn('ONU-is-on-a-different-intf-id-now',
                          previous_intf_id=platform.intf_id_from_pon_port_no(
                              onu_device.parent_port_no),
                          current_intf_id=onu_indication.intf_id)
            # FIXME - handle intf_id mismatch (ONU move?)

        if onu_device.proxy_address.onu_id != onu_indication.onu_id:
            # FIXME - handle onu id mismatch
            self.log.warn(
                'ONU-id-mismatch, can happen if both voltha and '
                'the olt rebooted',
                expected_onu_id=onu_device.proxy_address.onu_id,
                received_onu_id=onu_indication.onu_id)

        uni_no = platform.mk_uni_port_num(onu_indication.intf_id,
                                          onu_indication.onu_id)
        uni_name = self.port_name(uni_no,
                                  Port.ETHERNET_UNI,
                                  serial_number=onu_device.serial_number)

        self.log.debug('port-number-ready', uni_no=uni_no, uni_name=uni_name)

        # Admin state
        if onu_indication.admin_state == 'down':
            if onu_indication.oper_state != 'down':
                self.log.error('ONU-admin-state-down-and-oper-status-not-down',
                               oper_state=onu_indication.oper_state)
                # Forcing the oper state change code to execute
                onu_indication.oper_state = 'down'

            # Port and logical port update is taken care of by oper state block

        elif onu_indication.admin_state == 'up':
            pass

        else:
            self.log.warn('Invalid-or-not-implemented-admin-state',
                          received_admin_state=onu_indication.admin_state)

        self.log.debug('admin-state-dealt-with')

        onu_adapter_agent = \
            registry('adapter_loader').get_agent(onu_device.adapter)
        if onu_adapter_agent is None:
            self.log.error('onu_adapter_agent-could-not-be-retrieved',
                           onu_device=onu_device)
            return

        # Operating state
        if onu_indication.oper_state == 'down':

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

            # Move to discovered state
            self.log.debug('onu-oper-state-is-down')

            if onu_device.oper_status != OperStatus.DISCOVERED:
                onu_device.oper_status = OperStatus.DISCOVERED
                self.adapter_agent.update_device(onu_device)
            # Set port oper state to Discovered
            self.onu_ports_down(onu_device, uni_no, uni_name,
                                OperStatus.DISCOVERED)

            if onu_device.adapter == 'brcm_openomci_onu':
                self.log.debug('using-brcm_openomci_onu')
                onu_adapter_agent.update_interface(onu_device,
                                                   {'oper_state': 'down'})

        elif onu_indication.oper_state == 'up':

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

            if onu_device.oper_status != OperStatus.DISCOVERED:
                self.log.debug("ignore onu indication",
                               intf_id=onu_indication.intf_id,
                               onu_id=onu_indication.onu_id,
                               state=onu_device.oper_status,
                               msg_oper_state=onu_indication.oper_state)
                return

            # Device was in Discovered state, setting it to active

            # Prepare onu configuration
            # If we are  brcm_openomci adapter proceed

            if onu_device.adapter == 'brcm_openomci_onu':
                self.log.debug('using-brcm_openomci_onu')

                # tcont creation (onu)
                tcont = TcontsConfigData()
                tcont.alloc_id = alloc_id

                # gem port creation
                gem_port = GemportsConfigData()
                gem_port.gemport_id = gemport_id

                gem_port.tcont_ref = str(tcont.alloc_id)

                self.log.info('inject-tcont-gem-data-onu-handler',
                              onu_indication=onu_indication,
                              tcont=tcont,
                              gem_port=gem_port)

                onu_adapter_agent.create_tcont(onu_device,
                                               tcont,
                                               traffic_descriptor_data=None)
                onu_adapter_agent.create_gemport(onu_device, gem_port)
                onu_adapter_agent.create_interface(onu_device, onu_indication)

            else:
                self.log.error('unsupported-openolt-onu-adapter',
                               onu_adapter=onu_device.adapter)

        else:
            self.log.warn('Not-implemented-or-invalid-value-of-oper-state',
                          oper_state=onu_indication.oper_state)
Пример #8
0
    def onu_indication(self, onu_indication):
        self.log.debug("onu-indication",
                       intf_id=onu_indication.intf_id,
                       onu_id=onu_indication.onu_id,
                       serial_number=onu_indication.serial_number,
                       oper_state=onu_indication.oper_state,
                       admin_state=onu_indication.admin_state)

        serial_number_str = self.stringify_serial_number(
            onu_indication.serial_number)

        if serial_number_str == '000000000000':
            self.log.debug(
                'serial-number-was-not-provided-or-default-serial-number-provided-identifying-onu-by-onu_id'
            )
            #FIXME: if multiple PON ports onu_id is not a sufficient key
            onu_device = self.adapter_agent.get_child_device(
                self.device_id, onu_id=onu_indication.onu_id)
        else:
            onu_device = self.adapter_agent.get_child_device(
                self.device_id, serial_number=serial_number_str)

        self.log.debug('onu-device',
                       olt_device_id=self.device_id,
                       device=onu_device)

        # FIXME - handle serial_number mismatch
        # assert key is not None
        # assert onu_device is not None
        if onu_device is None:
            self.log.warn('onu-device-is-none-invalid-message')
            return

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

        if platform.intf_id_from_pon_port_no(
                onu_device.parent_port_no) != onu_indication.intf_id:
            self.log.warn('ONU-is-on-a-different-intf-id-now',
                          previous_intf_id=platform.intf_id_from_pon_port_no(
                              onu_device.parent_port_no),
                          current_intf_id=onu_indication.intf_id)
            # FIXME - handle intf_id mismatch (ONU move?)

        if onu_device.proxy_address.onu_id != onu_indication.onu_id:
            # FIXME - handle onu id mismatch
            self.log.warn('ONU-id-mismatch',
                          expected_onu_id=onu_device.proxy_address.onu_id,
                          received_onu_id=onu_indication.onu_id)

        uni_no = platform.mk_uni_port_num(onu_indication.intf_id,
                                          onu_indication.onu_id)
        uni_name = self.port_name(uni_no,
                                  Port.ETHERNET_UNI,
                                  serial_number=serial_number_str)

        self.log.debug('port-number-ready', uni_no=uni_no, uni_name=uni_name)

        #Admin state
        if onu_indication.admin_state == 'down':
            if onu_indication.oper_state != 'down':
                self.log.error('ONU-admin-state-down-and-oper-status-not-down',
                               oper_state=onu_indication.oper_state)
                onu_indication.oper_state = 'down'  # Forcing the oper state change code to execute

            if onu_device.admin_state != AdminState.DISABLED:
                onu_device.admin_state = AdminState.DISABLED
                self.adapter_agent.update(onu_device)
                self.log.debug('putting-onu-in-disabled-state',
                               onu_serial_number=onu_device.serial_number)

            #Port and logical port update is taken care of by oper state block

        elif onu_indication.admin_state == 'up':
            if onu_device.admin_state != AdminState.ENABLED:
                onu_device.admin_state = AdminState.ENABLED
                self.adapter_agent.update(onu_device)
                self.log.debug('putting-onu-in-enabled-state',
                               onu_serial_number=onu_device.serial_number)

        else:
            self.log.warn('Invalid-or-not-implemented-admin-state',
                          received_admin_state=onu_indication.admin_state)

        self.log.debug('admin-state-dealt-with')

        #Operating state
        if onu_indication.oper_state == 'down':
            #Move to discovered state
            self.log.debug('onu-oper-state-is-down')

            if onu_device.oper_status != OperStatus.DISCOVERED:
                onu_device.oper_status = OperStatus.DISCOVERED
                self.adapter_agent.update_device(onu_device)
            #Set port oper state to Discovered

            self.onu_ports_down(onu_device, uni_no, uni_name,
                                OperStatus.DISCOVERED)

        elif onu_indication.oper_state == 'up':

            if onu_device.oper_status != OperStatus.DISCOVERED:
                self.log.debug("ignore onu indication",
                               intf_id=onu_indication.intf_id,
                               onu_id=onu_indication.onu_id,
                               state=onu_device.oper_status,
                               msg_oper_state=onu_indication.oper_state)
                return

            #Device was in Discovered state, setting it to active

            onu_adapter_agent = registry('adapter_loader').get_agent(
                onu_device.adapter)
            if onu_adapter_agent is None:
                self.log.error('onu_adapter_agent-could-not-be-retrieved',
                               onu_device=onu_device)
                return

            #Prepare onu configuration

            # onu initialization, base configuration (bridge setup ...)
            def onu_initialization():

                #FIXME: that's definitely cheating
                if onu_device.adapter == 'broadcom_onu':
                    onu_adapter_agent.adapter.devices_handlers[
                        onu_device.id].message_exchange()
                    self.log.debug('broadcom-message-exchange-started')

            # tcont creation (onu)
            tcont = TcontsConfigData()
            tcont.alloc_id = platform.mk_alloc_id(onu_indication.onu_id)

            # gem port creation
            gem_port = GemportsConfigData()
            gem_port.gemport_id = platform.mk_gemport_id(onu_indication.onu_id)

            #ports creation/update
            def port_config():

                # "v_enet" creation (olt)

                #add_port update port when it exists
                self.adapter_agent.add_port(
                    self.device_id,
                    Port(port_no=uni_no,
                         label=uni_name,
                         type=Port.ETHERNET_UNI,
                         admin_state=AdminState.ENABLED,
                         oper_status=OperStatus.ACTIVE))

                # v_enet creation (onu)

                venet = VEnetConfig(name=uni_name)
                venet.interface.name = uni_name
                onu_adapter_agent.create_interface(onu_device, venet)

            # ONU device status update in the datastore
            def onu_update_oper_status():
                onu_device.oper_status = OperStatus.ACTIVE
                onu_device.connect_status = ConnectStatus.REACHABLE
                self.adapter_agent.update_device(onu_device)

            # FIXME : the asynchronicity has to be taken care of properly
            onu_initialization()
            reactor.callLater(10,
                              onu_adapter_agent.create_tcont,
                              device=onu_device,
                              tcont_data=tcont,
                              traffic_descriptor_data=None)
            reactor.callLater(11, onu_adapter_agent.create_gemport, onu_device,
                              gem_port)
            reactor.callLater(12, port_config)
            reactor.callLater(12, onu_update_oper_status)

        else:
            self.log.warn('Not-implemented-or-invalid-value-of-oper-state',
                          oper_state=onu_indication.oper_state)