def scheduled_on(self, blocks): """Assign default resource block to LVAP. Assign default resource block to LVAP. Accepts as input either a ResourcePool or a ResourceBlock. If the resource pool has more than one resource block then one random resource block is assigned as both downlink and default uplink. The remaining resource blocks are assigned as uplink only. Args: downlink: A ResourcePool or a ResourceBlock """ if not blocks: return if isinstance(blocks, ResourcePool): pool = blocks elif isinstance(blocks, ResourceBlock): pool = ResourcePool() pool.add(blocks) else: raise TypeError("Invalid type: %s", type(blocks)) # set downlink block self.downlink = pool.pop() # set uplink blocks self.uplink = pool
def scheduled_on(self, downlink): """Assign default resource block to LVAP. Assign default resource block to LVAP. Accepts as input either a ResourcePool or a ResourceBlock. If the resource pool has more than one resource block then one random resource block is assigned as both downlink and default uplink. The remaining resource blocks are assigned as uplink only. Args: downlink: A ResourcePool or a ResourceBlock """ # Null operation, just return if not downlink: return if isinstance(downlink, ResourcePool): pool = downlink elif isinstance(downlink, ResourceBlock): pool = ResourcePool() pool.add(downlink) else: raise TypeError("Expected ResourcePool, ResourceBlock, got %s", type(downlink)) current = ResourcePool( list(self.downlink.keys()) + list(self.uplink.keys())) # Null operation, just return, but before re-send configuration # commands (ports and of tables) if current == pool: self.set_ports() return # clear downlink blocks for block in list(self.downlink.keys()): del self.downlink[block] # clear uplink blocks for block in list(self.uplink.keys()): del self.uplink[block] # pick default resource block default_block = pool.pop() # If lvap is associated to a shared tenant. I need to reset the lvap # before moving it. if self._tenant and self._tenant.bssid_type == T_TYPE_SHARED: # check if tenant is available at target block base_bssid = self._tenant.get_prefix() net_bssid = generate_bssid(base_bssid, default_block.hwaddr) # if not ignore request if net_bssid not in self._tenant.vaps: LOG.error("VAP %s not found on tenant %s", net_bssid, self._tenant.tenant_name) self.set_ports() return # check if vap is available at target block if net_bssid != self._tenant.vaps[net_bssid].net_bssid: LOG.error("VAP %s not available at target block %s", net_bssid, default_block) self.set_ports() return # otherwise reset lvap self._tenant = None self.association_state = False self.authentication_state = False self._assoc_id = 0 self._lvap_bssid = net_bssid else: self._lvap_bssid = self.net_bssid # assign default port policy to downlink resource block, this will # trigger a send_add_lvap and a set_port (radio) message self.downlink[default_block] = RadioPort(self, default_block) # assign remaining blocks (if any) to the uplink, this could # trigger one or more send_add_lvap and a set_port (radio) messages for block in pool: self.uplink[block] = RadioPort(self, block) # set ports self.set_ports()
def downlink(self, downlink): """Assign default resource block to LVAP. Assign default resource block to LVAP. Accepts as input either a ResourcePool or a ResourceBlock. If the resource pool has more than one resource block then one random resource block is assigned as both downlink and default uplink. The remaining resource blocks are assigned as uplink only. Args: downlink: A ResourcePool or a ResourceBlock """ # Null operation, just return if not downlink: return if isinstance(downlink, ResourcePool): pool = downlink elif isinstance(downlink, ResourceBlock): pool = ResourcePool() pool.add(downlink) else: raise TypeError("Expected ResourcePool, ResourceBlock, got %s", type(downlink)) current = ResourcePool(list(self.downlink.keys()) + list(self.uplink.keys())) # Null operation, just return, but before re-send configuration # commands (ports and of tables) if current == pool: self.set_ports() return # clear downlink blocks for block in list(self.downlink.keys()): del self.downlink[block] # clear uplink blocks for block in list(self.uplink.keys()): del self.uplink[block] # pick default resource block default_block = pool.pop() # assign default port policy to downlink resource block, this will # trigger a send_add_lvap and a set_port (radio) message self.downlink[default_block] = RadioPort(self, default_block) # assign remaining blocks (if any) to the uplink, this could # trigger one or more send_add_lvap and a set_port (radio) messages for block in pool: self.uplink[block] = RadioPort(self, block) # set ports self.set_ports()
def downlink(self, blocks): """Set downlink block. Set the downlink block. Must receive as input a single resource block. """ if isinstance(blocks, ResourcePool): pool = blocks elif isinstance(blocks, ResourceBlock): pool = ResourcePool() pool.add(blocks) else: raise TypeError("Invalid type: %s", type(blocks)) if len(pool) > 1: raise ValueError("Downlink, too many blocks (%u)", len(blocks)) current = ResourcePool(list(self._downlink.keys())) # Null operation, just return, but before re-send intent configuration if current == pool: self.set_ports() return # clear downlink blocks for block in list(self._downlink.keys()): del self._downlink[block] # downlink block default_block = pool.pop() # check if block is also in the uplink, if so remove it if default_block in self._uplink: del self._uplink[default_block] # If lvap is associated to a shared tenant. I need to reset the lvap # before moving it. if self._tenant and self._tenant.bssid_type == T_TYPE_SHARED: # check if tenant is available at target block base_bssid = self._tenant.get_prefix() net_bssid = generate_bssid(base_bssid, default_block.hwaddr) # if not ignore request if net_bssid not in self._tenant.vaps: LOG.error("VAP %s not found on tenant %s", net_bssid, self._tenant.tenant_name) self.set_ports() return # check if vap is available at target block if net_bssid != self._tenant.vaps[net_bssid].net_bssid: LOG.error("VAP %s not available at target block %s", net_bssid, default_block) self.set_ports() return # otherwise reset lvap self._tenant = None self.association_state = False self.authentication_state = False self._assoc_id = 0 self._lvap_bssid = net_bssid # assign default port policy to downlink resource block, this will # trigger a send_add_lvap and a set_port (radio) message self._downlink[default_block] = RadioPort(self, default_block) # set ports self.set_ports()
def scheduled_on(self, downlink): """Assign default resource block to LVAP. Assign default resource block to LVAP. Accepts as input either a ResourcePool or a ResourceBlock. If the resource pool has more than one resource block then one random resource block is assigned as both downlink and default uplink. The remaining resource blocks are assigned as uplink only. Args: downlink: A ResourcePool or a ResourceBlock """ # Null operation, just return if not downlink: return if isinstance(downlink, ResourcePool): pool = downlink elif isinstance(downlink, ResourceBlock): pool = ResourcePool() pool.add(downlink) else: raise TypeError("Expected ResourcePool, ResourceBlock, got %s", type(downlink)) current = ResourcePool(list(self.downlink.keys()) + list(self.uplink.keys())) # Null operation, just return, but before re-send configuration # commands (ports and of tables) if current == pool: self.set_ports() return # clear downlink blocks for block in list(self.downlink.keys()): del self.downlink[block] # clear uplink blocks for block in list(self.uplink.keys()): del self.uplink[block] # pick default resource block default_block = pool.pop() # If lvap is associated to a shared tenant. I need to reset the lvap # before moving it. if self._tenant and self._tenant.bssid_type == T_TYPE_SHARED: # check if tenant is available at target block base_bssid = self._tenant.get_prefix() net_bssid = generate_bssid(base_bssid, default_block.hwaddr) # if not ignore request if net_bssid not in self._tenant.vaps: LOG.error("VAP %s not found on tenant %s", net_bssid, self._tenant.tenant_name) self.set_ports() return # check if vap is available at target block if net_bssid != self._tenant.vaps[net_bssid].net_bssid: LOG.error("VAP %s not available at target block %s", net_bssid, default_block) self.set_ports() return # otherwise reset lvap self._tenant = None self.association_state = False self.authentication_state = False self._assoc_id = 0 self._lvap_bssid = net_bssid else: self._lvap_bssid = self.net_bssid # assign default port policy to downlink resource block, this will # trigger a send_add_lvap and a set_port (radio) message self.downlink[default_block] = RadioPort(self, default_block) # assign remaining blocks (if any) to the uplink, this could # trigger one or more send_add_lvap and a set_port (radio) messages for block in pool: self.uplink[block] = RadioPort(self, block) # set ports self.set_ports()