Esempio n. 1
0
    def handle_write_handler_response(self, handler_response):
        """Handle an incoming WRITE_HANDLER_RESPONSE message.
        Args:
            handler_response, a WRITE_HANDLER_RESPONSE message
        Returns:
            None
        """

        if handler_response['handler_id'] not in self.modules:
            return

        handler = self.modules[handler_response['handler_id']]

        tenant_id = UUID(handler_response['tenant_id'])
        lvnf_id = UUID(handler_response['lvnf_id'])

        tenant = RUNTIME.tenants[tenant_id]

        if lvnf_id not in tenant.lvnfs:
            return

        # update this object
        if handler_response['retcode'] != 200:
            error = handler_response['samples']
            LOG.error("Error while polling %s: %s" % (handler.handler, error))
            self.remove_module(handler.module_id)
            return

        handler.retcode = handler_response['retcode']
        handler.samples = handler_response['samples']

        # handle callback
        handle_callback(handler, handler)
    def handle_write_handler_response(self, handler_response):
        """Handle an incoming WRITE_HANDLER_RESPONSE message.
        Args:
            handler_response, a WRITE_HANDLER_RESPONSE message
        Returns:
            None
        """

        if handler_response['handler_id'] not in self.modules:
            return

        handler = self.modules[handler_response['handler_id']]

        tenant_id = UUID(handler_response['tenant_id'])
        lvnf_id = UUID(handler_response['lvnf_id'])

        tenant = RUNTIME.tenants[tenant_id]

        if lvnf_id not in tenant.lvnfs:
            return

        # update this object
        if handler_response['retcode'] != 200:
            error = handler_response['samples']
            LOG.error("Error while polling %s: %s" % (handler.handler, error))
            self.remove_module(handler.module_id)
            return

        handler.retcode = handler_response['retcode']
        handler.samples = handler_response['samples']

        # handle callback
        handle_callback(handler, handler)
Esempio n. 3
0
    def handle_lvnf_stats_response(self, stats_response):
        """Handle an incoming stats response message.
        Args:
            stats_response, a stats response message
        Returns:
            None
        """

        if stats_response['lvnf_stats_id'] not in self.modules:
            return

        stats = self.modules[stats_response['lvnf_stats_id']]

        # stop profiling
        stats.toc()

        tenant_id = UUID(stats_response['tenant_id'])
        lvnf_id = UUID(stats_response['lvnf_id'])

        tenant = RUNTIME.tenants[tenant_id]

        if lvnf_id not in tenant.lvnfs:
            return

        stats.stats = stats_response['stats']

        # handle callback
        handle_callback(stats, stats)
Esempio n. 4
0
    def on_wtp_up(self, caps_response):
        """ Handle an CAPS_RESPONSE message.

        Args:
            caps_response, a CAPS_RESPONSE message

        Returns:
            None
        """

        for event in self.modules.values():

            if event.tenant_id not in RUNTIME.tenants:
                return

            addr = caps_response.wtp
            wtps = RUNTIME.tenants[event.tenant_id].wtps

            if addr not in wtps:
                return

            wtp = wtps[addr]

            LOG.info("Event: WTP Up %s", wtp.addr)

            handle_callback(wtp, event)
Esempio n. 5
0
    def handle_trigger(self, message):
        """ Handle an incoming poller response message.
        Args:
            message, a poller response message
        Returns:
            None
        """

        if message.trigger_id not in self.modules:
            return

        wtp_addr = EtherAddress(message.wtp)

        if wtp_addr not in RUNTIME.wtps:
            return

        lvap_addr = EtherAddress(message.sta)

        # find trigger object
        trigger = self.modules[message.trigger_id]

        tenant = RUNTIME.tenants[trigger.tenant_id]

        if lvap_addr not in tenant.lvaps:
            return

        # handle the message
        trigger.handle_trigger(message)

        # call callback
        handle_callback(trigger, trigger)
Esempio n. 6
0
    def on_cpp_down(self, bye):
        """ Handle an BYE message.

        Args:
            bye, a BYE message

        Returns:
            None
        """

        for event in list(self.modules.values()):

            if event.tenant_id not in RUNTIME.tenants:
                return

            addr = EtherAddress(bye['addr'])
            cpps = RUNTIME.tenants[event.tenant_id].cpps

            if addr not in cpps:
                return

            cpp = cpps[addr]

            LOG.info("Event: CPP Down %s", cpp.addr)

            handle_callback(cpp, event)
Esempio n. 7
0
    def handle_poller_response(self, message):
        """Handle an incoming poller response message.
        Args:
            message, a poller response message
        Returns:
            None
        """

        if message.poller_id not in self.modules:
            return

        wtp_addr = EtherAddress(message.wtp)

        if wtp_addr not in RUNTIME.wtps:
            return

        wtp = RUNTIME.wtps[wtp_addr]
        hwaddr = EtherAddress(message.hwaddr)
        incoming = ResourcePool()
        incoming.add(ResourceBlock(wtp, hwaddr, message.channel, message.band))

        matching = (wtp.supports & incoming).pop()

        LOG.info("Received %s response from %s (id=%u)",
                 self.MODULE_NAME,
                 matching,
                 message.poller_id)

        # find poller object
        poller = self.modules[message.poller_id]

        # handle the message
        map_type = self.MODULE_NAME
        setattr(poller.block, map_type, CQM())
        map_entry = getattr(poller.block, map_type)

        for entry in message.img_entries:

            addr = EtherAddress(entry[0])

            if not addr.match(poller.addrs):
                continue

            value = {'addr': addr,
                     'last_rssi_std': entry[1] / 1000.0,
                     'last_rssi_avg': entry[2] / 1000.0,
                     'last_packets': entry[3],
                     'hist_packets': entry[4],
                     'ewma_rssi': entry[5] / 1000.0,
                     'sma_rssi': entry[6] / 1000.0}

            map_entry[addr] = value

        # call callback
        handle_callback(poller, poller)
Esempio n. 8
0
    def on_lvnf_join(self, lvnf):
        """ Handle an kvnf join event.

        Args:
            lvnf, an LVNF instance

        Returns:
            None
        """

        for event in list(self.modules.values()):

            tenant = RUNTIME.tenants[event.tenant_id]

            if lvnf.lvnf_id not in tenant.lvnfs:
                continue

            LOG.info("Event: LVNF Join %s", lvnf.lvnf_id)

            handle_callback(lvnf, event)
Esempio n. 9
0
    def on_lvnf_join(self, lvnf):
        """ Handle an kvnf join event.

        Args:
            lvnf, an LVNF instance

        Returns:
            None
        """

        for event in list(self.modules.values()):

            tenant = RUNTIME.tenants[event.tenant_id]

            if lvnf.lvnf_id not in tenant.lvnfs:
                continue

            LOG.info("Event: LVNF Join %s", lvnf.lvnf_id)

            handle_callback(lvnf, event)
Esempio n. 10
0
    def on_lvap_join(self, lvap):
        """ Handle an LVAL JOIN event.
        Args:
            lvap, an LVAP object
        Returns:
            None
        """

        for event in self.modules.values():

            if event.tenant_id not in RUNTIME.tenants:
                return

            lvaps = RUNTIME.tenants[event.tenant_id].lvaps

            if lvap.addr not in lvaps:
                return

            LOG.info("Event: LVAP Join %s", lvap.addr)

            handle_callback(lvap, event)
Esempio n. 11
0
    def on_lvap_join(self, lvap):
        """ Handle an LVAL JOIN event.
        Args:
            lvap, an LVAP object
        Returns:
            None
        """

        for event in self.modules.values():

            if event.tenant_id not in RUNTIME.tenants:
                return

            lvaps = RUNTIME.tenants[event.tenant_id].lvaps

            if lvap.addr not in lvaps:
                return

            LOG.info("Event: LVAP Join %s", lvap.addr)

            handle_callback(lvap, event)
Esempio n. 12
0
    def handle_rates_response(self, rates):
        """Handle an incoming RATES_RESPONSE message.
        Args:
            rates, a RATES_RESPONSE message
        Returns:
            None
        """

        if rates.rates_id not in self.modules:
            return

        counter = self.modules[rates.rates_id]

        # update cache
        lvap = RUNTIME.lvaps[counter.lvap]
        lvap.rates = {x[0]: x[1] for x in rates.rates}

        # update this object
        counter.rates = {x[0]: x[1] for x in rates.rates}

        # call callback
        handle_callback(counter, counter)
Esempio n. 13
0
    def handle_rates_response(self, rates):
        """Handle an incoming RATES_RESPONSE message.
        Args:
            rates, a RATES_RESPONSE message
        Returns:
            None
        """

        if rates.rates_id not in self.modules:
            return

        counter = self.modules[rates.rates_id]

        # update cache
        lvap = RUNTIME.lvaps[counter.lvap]
        lvap.rates = {x[0]: x[1] for x in rates.rates}

        # update this object
        counter.rates = {x[0]: x[1] for x in rates.rates}

        # call callback
        handle_callback(counter, counter)
Esempio n. 14
0
    def on_wtp_down(self, wtp):
        """ Handle an BYE message.

        Args:
            pnfdev_bye, a PNFDEV_BYE message

        Returns:
            None
        """

        for event in self.modules.values():

            if event.tenant_id not in RUNTIME.tenants:
                return

            wtps = RUNTIME.tenants[event.tenant_id].wtps

            if wtp.addr not in wtps:
                return

            LOG.info("Event: WTP Down %s", wtp.addr)

            handle_callback(wtp, event)
Esempio n. 15
0
    def on_wtp_down(self, wtp):
        """ Handle an BYE message.

        Args:
            pnfdev_bye, a PNFDEV_BYE message

        Returns:
            None
        """

        for event in self.modules.values():

            if event.tenant_id not in RUNTIME.tenants:
                return

            wtps = RUNTIME.tenants[event.tenant_id].wtps

            if wtp.addr not in wtps:
                return

            LOG.info("Event: WTP Down %s", wtp.addr)

            handle_callback(wtp, event)
Esempio n. 16
0
    def on_cpp_up(self, register):
        """ Handle an REGISTER message.

        Args:
            register, a REGISTER message

        Returns:
            None
        """

        for event in list(self.modules.values()):

            if event.tenant_id not in RUNTIME.tenants:
                return

            addr = EtherAddress(register['addr'])
            cpps = RUNTIME.tenants[event.tenant_id].cpps

            if addr not in cpps:
                return

            LOG.info("Event: CPP Up %s", addr)

            handle_callback(cpps[addr], event)
Esempio n. 17
0
    def handle_stats_response(self, stats):
        """Handle an incoming STATS_RESPONSE message.
        Args:
            stats, a STATS_RESPONSE message
        Returns:
            None
        """

        if stats.stats_id not in self.modules:
            return

        counter = self.modules[stats.stats_id]

        # update cache
        lvap = RUNTIME.lvaps[counter.lvap]
        lvap.tx_samples = stats.stats[0:stats.nb_tx]
        lvap.rx_samples = stats.stats[stats.nb_tx:-1]

        # update this object
        counter.tx_samples = stats.stats[0:stats.nb_tx]
        counter.rx_samples = stats.stats[stats.nb_tx:-1]

        # call callback
        handle_callback(counter, counter)
Esempio n. 18
0
    def handle_stats_response(self, stats):
        """Handle an incoming STATS_RESPONSE message.
        Args:
            stats, a STATS_RESPONSE message
        Returns:
            None
        """

        if stats.stats_id not in self.modules:
            return

        counter = self.modules[stats.stats_id]

        # update cache
        lvap = RUNTIME.lvaps[counter.lvap]
        lvap.tx_samples = stats.stats[0:stats.nb_tx]
        lvap.rx_samples = stats.stats[stats.nb_tx:-1]

        # update this object
        counter.tx_samples = stats.stats[0:stats.nb_tx]
        counter.rx_samples = stats.stats[stats.nb_tx:-1]

        # call callback
        handle_callback(counter, counter)
Esempio n. 19
0
    def on_cpp_up(self, register):
        """ Handle an REGISTER message.

        Args:
            register, a REGISTER message

        Returns:
            None
        """

        for event in list(self.modules.values()):

            if event.tenant_id not in RUNTIME.tenants:
                return

            addr = EtherAddress(register['addr'])
            cpps = RUNTIME.tenants[event.tenant_id].cpps

            if addr not in cpps:
                return

            LOG.info("Event: CPP Up %s", addr)

            handle_callback(cpps[addr], event)