Exemplo n.º 1
0
    def __set_ports(self):
        """Set virtual ports.

        This method is called everytime an LVAP is moved to another WTP. More
        preciselly it is called every time an assignment to the downlink
        property is made.
        """

        # Delete all outgoing virtual link and then remove the entire port
        if self.ports:
            self.ports[0].clear()
            del self.ports[0]

        # Create a new port from scratch
        self.ports[0] = VirtualPortLvap(phy_port=self.wtp.port(),
                                        virtual_port_id=0,
                                        lvap=self)

        # set/update intent
        intent = {
            'version': '1.0',
            'dpid': self.ports[0].dpid,
            'port': self.ports[0].ovs_port_id,
            'hwaddr': self.addr
        }

        intent_server = RUNTIME.components[IntentServer.__module__]

        if self.poa_uuid:
            intent_server.update_poa(intent, self.poa_uuid)
        else:
            self.poa_uuid = intent_server.add_poa(intent)
Exemplo n.º 2
0
    def set_ports(self):
        """Set virtual ports.

        This method is called everytime an LVAP is moved to another WTP. More
        preciselly it is called every time an assignment to the downlink
        property is made.

        Consider an SFC like this:

        lvap[0][dl_src=11:22:33:44:55:66] -> [0] dupes

        In this case all outgoing virtual links must be preserved. Virtual
        links should deleted and then recreated in order to keep the system in
        the correct state.

        In the current draft implementation virtual links are not restored.
        Basically after an handover all virtual links must be reconfigured by
        the application.
        """

        # Save virtual links and delete them
        # TODO: Implement.
        self.clear_ports()

        if not self.wtp:
            return

        for port in self.wtp.ports.values():

            if port.iface != "empower0":
                continue

            virtual_port = VirtualPortLvap(dpid=self.wtp.addr,
                                           ovs_port_id=port.port_id,
                                           virtual_port_id=0,
                                           hwaddr=port.hwaddr,
                                           iface=port.iface)

            # These are needed because when assigning the next method of a
            # virtual port I need to access the lvap configuration: encap, and
            # downlinks/uplinks blocks
            virtual_port.next.lvap = self

            self.__ports[0] = virtual_port

            break

        # Restore virtual links
        # TODO: Implement.
        if self.__ports:
            self.__ports[0].next[{}] = None
Exemplo n.º 3
0
    def _handle_status_lvap(self, wtp, status):
        """Handle an incoming STATUS_LVAP message.
        Args:
            status, a STATUS_LVAP message
        Returns:
            None
        """

        if not wtp.connection:
            LOG.info("Status from disconnected WTP %s", wtp.addr)
            return

        sta = EtherAddress(status.sta)
        set_mask = bool(status.flags.set_mask)

        lvap = None

        accum = []
        incoming_ssids = [SSID(x.ssid) for x in status.ssids]

        accum.append("addr ")
        accum.append(EtherAddress(status.sta).to_str())
        accum.append(" net_bssid ")
        accum.append(EtherAddress(status.net_bssid).to_str())
        accum.append(" lvap_bssid ")
        accum.append(EtherAddress(status.lvap_bssid).to_str())

        accum.append(" ssid ")

        if incoming_ssids[0]:
            accum.append(incoming_ssids[0].to_str())
        else:
            accum.append("None")

        accum.append(" ssids [")

        for ssid in incoming_ssids[1:]:
            accum.append(" ")
            accum.append(ssid.to_str())

        accum.append(" ]")

        accum.append(" assoc_id ")
        accum.append(str(status.assoc_id))

        if bool(status.flags.authenticated):
            accum.append(" AUTH")

        if bool(status.flags.associated):
            accum.append(" ASSOC")

        LOG.info("LVAP status %s", ''.join(accum))

        # If the LVAP does not exists, then create a new one
        if sta not in RUNTIME.lvaps:

            net_bssid_addr = EtherAddress(status.net_bssid)
            lvap_bssid_addr = EtherAddress(status.lvap_bssid)
            lvap = LVAP(sta, net_bssid_addr, lvap_bssid_addr)

            RUNTIME.lvaps[sta] = lvap

        lvap = RUNTIME.lvaps[sta]

        # Check if block is valid
        incoming = ResourceBlock(wtp, EtherAddress(status.hwaddr),
                                 status.channel, status.band)

        valid = [block for block in wtp.supports if block == incoming]

        if not valid:
            LOG.warning("No valid intersection found. Removing block.")
            wtp.connection.send_del_lvap(lvap)
            return

        # this will try to updated the lvap object with the resource block
        # coming in this status update message.
        try:
            if set_mask:
                # set downlink+uplink block
                lvap._downlink.setitem(valid[0], RadioPort(lvap, valid[0]))
            else:
                # set uplink only blocks
                lvap._uplink.setitem(valid[0], RadioPort(lvap, valid[0]))
        except Exception as e:
            LOG.exception(e)
            LOG.error("Error while importing block %s, removing.", valid[0])
            wtp.connection.send_del_lvap(lvap)
            return

        # update LVAP ports
        lvap.ports[0] = VirtualPortLvap(phy_port=wtp.port(),
                                        virtual_port_id=0,
                                        lvap=lvap)

        # set supported band
        lvap.supported_band = status.supported_band

        # update LVAP params
        lvap.authentication_state = bool(status.flags.authenticated)
        lvap.association_state = bool(status.flags.associated)

        lvap._assoc_id = status.assoc_id
        lvap._encap = EtherAddress(status.encap)
        ssids = [SSID(x.ssid) for x in status.ssids]

        # update ssid
        if lvap.ssid:

            # Raise LVAP leave event
            self.server.send_lvap_leave_message_to_self(lvap)

            # removing LVAP from tenant, need first to look for right tenant
            if lvap.addr in lvap.tenant.lvaps:
                LOG.info("Removing %s from tenant %s", lvap.addr, lvap.ssid)
                del lvap.tenant.lvaps[lvap.addr]

            lvap._tenant = None

        # update remaining ssids
        lvap._ssids = ssids[1:]

        if ssids[0]:

            tenant = RUNTIME.load_tenant(ssids[0])

            if not tenant:
                LOG.info("LVAP %s from unknown tenant %s", lvap.addr, ssids[0])
                RUNTIME.remove_lvap(lvap.addr)
                return

            # setting tenant without seding out add lvap message
            lvap._tenant = tenant

            # adding LVAP to tenant
            LOG.info("Adding %s to tenant %s", lvap.addr, ssids[0])
            lvap.tenant.lvaps[lvap.addr] = lvap

            # Raise LVAP join event
            self.server.send_lvap_join_message_to_self(lvap)