Пример #1
0
    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)
Пример #2
0
    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)
Пример #3
0
    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)
Пример #4
0
    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)
Пример #5
0
    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)