def __setitem__(self, key, value): key = build_block(key) if not isinstance(key, ResourceBlock): raise KeyError("Expected ResourceBlock, got %s" % type(key)) if not isinstance(value, RadioPort): raise KeyError("Expected Port, got %s" % type(key)) # the block is found, update the port if dict.__contains__(self, key): # update dict dict.__setitem__(self, key, value) # the block is not found, max_ports is exceed elif dict.__len__(self) == self.MAX_PORTS: raise ValueError("Max number of ports is %u" % self.MAX_PORTS) # the block is not found, max_ports is not exceed else: # update dict dict.__setitem__(self, key, value) # update LVAP configuration key.radio.connection.send_add_lvap(value.lvap, key, self.SET_MASK) # update Port configuration key.radio.connection.send_set_port(value.tx_policy)
def setitem(self, key, value): """Notice this will set the item without sending out any message.""" key = build_block(key) if not isinstance(key, ResourceBlock): raise KeyError("Expected ResourceBlock, got %s" % type(key)) if not isinstance(value, RadioPort): raise KeyError("Expected Port, got %s" % type(key)) # the block is found, update the port if dict.__contains__(self, key): # update dict dict.__setitem__(self, key, value) # the block is not found, max_ports is exceed elif dict.__len__(self) == self.MAX_PORTS: raise ValueError("Max number of ports is %u" % self.MAX_PORTS) # the block is not found, max_ports is not exceed else: # update dict dict.__setitem__(self, key, value)
def __getitem__(self, key): key = build_block(key) if not isinstance(key, ResourceBlock): raise KeyError("Expected ResourceBlock, got %s" % type(key)) return dict.__getitem__(self, key)
def delitem(self, key): """Notice this will del the item without sending out any message.""" key = build_block(key) if not isinstance(key, ResourceBlock): raise KeyError("Expected ResourceBlock, got %s" % type(key)) dict.__delitem__(self, key)
def __delitem__(self, key): key = build_block(key) if not isinstance(key, ResourceBlock): raise KeyError("Expected ResourceBlock, got %s" % type(key)) # get port port = dict.__getitem__(self, key) # send del lvap message (key.radio is an WTP object, while port.lvap # is an LVAP object) key.radio.connection.send_del_lvap(port.lvap) dict.__delitem__(self, key)