def update_vaps(self): """Update active VAPs.""" for tenant in RUNTIME.tenants.values(): # tenant does not use shared VAPs if tenant.bssid_type == T_TYPE_UNIQUE: continue # wtp not in this tenant if self.wtp.addr not in tenant.wtps: continue for block in self.wtp.supports: bssid = tenant.generate_bssid(block.hwaddr) # vap has already been created if bssid in tenant.vaps: continue vap = VAP(bssid, block, tenant) self.send_add_vap(vap) tenant.vaps[bssid] = vap
def _handle_status_vap(self, wtp, status): """Handle an incoming STATUS_VAP message. Args: status, a STATUS_VAP message Returns: None """ bssid = EtherAddress(status.bssid) ssid = SSID(status.ssid) tenant = RUNTIME.load_tenant(ssid) if not tenant: self.log.info("VAP %s from unknown tenant %s", bssid, ssid) return # Check if block is valid valid = wtp.get_block(status.hwaddr, status.channel, status.band) if not valid: self.log.warning("No valid intersection found. Removing VAP.") wtp.connection.send_del_vap(bssid) return # If the VAP does not exists, then create a new one if bssid not in tenant.vaps: vap = VAP(bssid, valid, tenant) tenant.vaps[bssid] = vap vap = tenant.vaps[bssid] self.log.info("VAP status %s", vap)
def _handle_status_vap(cls, wtp, status): """Handle an incoming STATUS_VAP message. Args: status, a STATUS_VAP message Returns: None """ if not wtp.connection: LOG.info("VAP Status from disconnected WTP %s", wtp.addr) return net_bssid_addr = EtherAddress(status.net_bssid) ssid = SSID(status.ssid) tenant = RUNTIME.load_tenant(ssid) if not tenant: LOG.info("VAP %s from unknown tenant %s", net_bssid_addr, ssid) return incoming = ResourceBlock(wtp, EtherAddress(status.hwaddr), status.channel, status.band) LOG.info("VAP status update from %s", net_bssid_addr) # If the VAP does not exists, then create a new one if net_bssid_addr not in tenant.vaps: vap = VAP(net_bssid_addr, incoming, wtp, tenant) tenant.vaps[net_bssid_addr] = vap vap = tenant.vaps[net_bssid_addr] LOG.info("VAP status %s", vap)
def update_vaps(self): """Update active VAPs.""" for project in self.manager.projects_manager.projects.values(): # project does not have wifi_props if not project.wifi_props: continue # project does not use shared VAPs if project.wifi_props.bssid_type == T_BSSID_TYPE_UNIQUE: continue for block in self.device.blocks.values(): bssid = project.generate_bssid(block.hwaddr) # vap has already been created if bssid in self.manager.vaps: continue vap = VAP(bssid, block, project.wifi_props.ssid) self.send_add_vap(vap) self.manager.vaps[bssid] = vap
def _handle_hello(self, wtp, hello): """Handle an incoming HELLO message. Args: hello, a HELLO message Returns: None """ LOG.info("Hello from %s WTP %s seq %u", self.addr[0], wtp.addr, hello.seq) # New connection if not wtp.connection: # set pointer to pnfdev object self.wtp = wtp # set connection wtp.connection = self # Update WTP params wtp.period = hello.period wtp.last_seen = hello.seq wtp.last_seen_ts = time.time() # Upon connection to the controller, the WTP must be provided # with the list of shared VAP for tenant in RUNTIME.tenants.values(): # tenant does not use shared VAPs if tenant.bssid_type == T_TYPE_UNIQUE: continue # wtp not in this tenant if wtp.addr not in tenant.wtps: continue tenant_id = tenant.tenant_id tokens = [tenant_id.hex[0:12][i:i + 2] for i in range(0, 12, 2)] base_bssid = EtherAddress(':'.join(tokens)) for block in wtp.supports: net_bssid = generate_bssid(base_bssid, block.hwaddr) # vap has already been created if net_bssid in RUNTIME.tenants[tenant_id].vaps: continue vap = VAP(net_bssid, block, wtp, tenant) self.send_add_vap(vap) RUNTIME.tenants[tenant_id].vaps[net_bssid] = vap
def _handle_status_vap(cls, status): """Handle an incoming STATUS_VAP message. Args: status, a STATUS_VAP message Returns: None """ wtp_addr = EtherAddress(status.wtp) try: wtp = RUNTIME.wtps[wtp_addr] except KeyError: LOG.info("VAP Status from unknown WTP %s", wtp_addr) return if not wtp.connection: LOG.info("VAP Status from disconnected WTP %s", wtp_addr) return net_bssid_addr = EtherAddress(status.net_bssid) ssid = SSID(status.ssid) tenant_id = None for tenant in RUNTIME.tenants.values(): if tenant.tenant_name == ssid: tenant_id = tenant.tenant_id break if not tenant_id: LOG.info("VAP %s from unknown tenant %s", net_bssid_addr, ssid) return tenant = RUNTIME.tenants[tenant_id] vap = None hwaddr = EtherAddress(status.hwaddr) block = ResourceBlock(wtp, hwaddr, status.channel, status.band) ssid = status.ssid LOG.info("VAP %s status update block %s", net_bssid_addr, block) # If the VAP does not exists, then create a new one if net_bssid_addr not in tenant.vaps: tenant.vaps[net_bssid_addr] = \ VAP(net_bssid_addr, block, wtp, tenant) vap = tenant.vaps[net_bssid_addr] LOG.info("VAP status %s", vap)
def send_vaps(self): """Send VAPs configurations. Upon connection to the controller, the WTP must be provided with the list of shared VAPs Args: None Returns: None """ for tenant in RUNTIME.tenants.values(): # tenant does not use shared VAPs if tenant.bssid_type == T_TYPE_UNIQUE: continue # wtp not in this tenant if self.wtp.addr not in tenant.wtps: continue tenant_id = tenant.tenant_id tokens = [tenant_id.hex[0:12][i:i + 2] for i in range(0, 12, 2)] base_bssid = EtherAddress(':'.join(tokens)) for block in self.wtp.supports: net_bssid = generate_bssid(base_bssid, block.hwaddr) # vap has already been created if net_bssid in RUNTIME.tenants[tenant_id].vaps: continue vap = VAP(net_bssid, block, self.wtp, tenant) self.send_add_vap(vap) RUNTIME.tenants[tenant_id].vaps[net_bssid] = vap
def _handle_vap_status_response(self, status): """Handle an incoming STATUS_VAP message.""" bssid = EtherAddress(status.bssid) ssid = SSID(status.ssid) project = self.manager.projects_manager.load_project_by_ssid(ssid) if not project: self.log.warning("Unable to find SSID %s", ssid) self.send_del_vap(bssid) return # If the VAP does not exists, then create a new one if bssid not in self.manager.vaps: incoming = self.device.blocks[status.iface_id] self.manager.vaps[bssid] = VAP(bssid, incoming, project.wifi_props.ssid) vap = self.manager.vaps[bssid] self.log.info("VAP status %s", vap)
def _handle_hello(self, hello): """Handle an incoming HELLO message. Args: hello, a HELLO message Returns: None """ wtp_addr = EtherAddress(hello.wtp) try: wtp = RUNTIME.wtps[wtp_addr] except KeyError: LOG.info("Hello from unknown WTP (%s)", wtp_addr) return LOG.info("Hello from %s seq %u", self.addr[0], hello.seq) # compute delta if not new connection if wtp.connection: delta = time.time() - wtp.last_seen_ts # uplink ul_bytes = hello.uplink_bytes - wtp.uplink_bytes wtp.uplink_bytes_per_second = int(ul_bytes / delta) * 8 # downlink dl_bytes = hello.downlink_bytes - wtp.downlink_bytes wtp.downlink_bytes_per_second = int(dl_bytes / delta) * 8 # If this is a new connection, then send caps request if not wtp.connection: # set wtp before connection because it is used when the # connection attribute of the PNFDev object is set self.wtp = wtp wtp.connection = self # Update WTP params wtp.period = hello.period wtp.last_seen = hello.seq wtp.uplink_bytes = hello.uplink_bytes wtp.downlink_bytes = hello.downlink_bytes wtp.last_seen_ts = time.time() # Upon connection to the controller, the WTP must be provided # with the list of shared VAP for tenant in RUNTIME.tenants.values(): # tenant does not use shared VAPs if tenant.bssid_type == T_TYPE_UNIQUE: continue # wtp not in this tenant if wtp_addr not in tenant.wtps: continue tenant_id = tenant.tenant_id tokens = [tenant_id.hex[0:12][i:i + 2] for i in range(0, 12, 2)] base_bssid = EtherAddress(':'.join(tokens)) for block in wtp.supports: net_bssid = generate_bssid(base_bssid, block.hwaddr) # vap has already been created if net_bssid in RUNTIME.tenants[tenant_id].vaps: continue vap = VAP(net_bssid, block, wtp, tenant) self.send_add_vap(vap) RUNTIME.tenants[tenant_id].vaps[net_bssid] = vap