Пример #1
0
    def query(self, plugin, key, element='', nb_test=QUERY_CONFIG_NUM_TRY):
        '''
        Ask the config system for the value. Calling this function will make
        your program wait until it got an answer

        @param plugin : the plugin of the item requesting the value,
        must exists in the config database
        @param element : the name of the element which requests config, None if
        it's a technolgy global parameter
        @param key : the key to fetch corresponding value, if it's an empty string,
        all the config items for this technology will be fetched
        '''
        msg = MQMessage()
        msg._action = 'config.get'
        msg._data = {
            'plugin': plugin,
            'key': key,
            'element': element,
            'hostname': get_sanitized_hostname()
        }
        ret = self.cli.request('dbmgr', msg.get(), timeout=QUERY_CONFIG_WAIT)
        if ret is None:
            return None
        else:
            if 'value' in ret._data.keys():
                return ret._data['value']
            else:
                return None
Пример #2
0
    def set(self, plugin, key, value):
        """
        Send a xpl message to set value for a param

        @param technology : the technology of the item
        @param key : the key to set corresponding value,
        @param value : the value to set
        """
        msg = MQMessage()
        msg._action = "config.set"
        self.cli.request("dbmgr", msg.get(), timeout=QUERY_CONFIG_WAIT)
Пример #3
0
    def set(self, plugin, key, value):
        '''
        Send a xpl message to set value for a param

        @param technology : the technology of the item
        @param key : the key to set corresponding value,
        @param value : the value to set
        '''
        msg = MQMessage()
        msg._action = 'config.set'
        self.cli.request('dbmgr', msg.get(), timeout=QUERY_CONFIG_WAIT)
Пример #4
0
    def query(self, plugin, key, element="", nb_test=QUERY_CONFIG_NUM_TRY):
        """
        Ask the config system for the value. Calling this function will make
        your program wait until it got an answer

        @param plugin : the plugin of the item requesting the value,
        must exists in the config database
        @param element : the name of the element which requests config, None if
        it's a technolgy global parameter
        @param key : the key to fetch corresponding value, if it's an empty string,
        all the config items for this technology will be fetched
        """
        msg = MQMessage()
        msg._action = "config.get"
        msg._data = {"plugin": plugin, "key": key, "element": element, "hostname": get_sanitized_hostname()}
        ret = self.cli.request("dbmgr", msg.get(), timeout=QUERY_CONFIG_WAIT)
        if ret is None:
            return None
        else:
            if "value" in ret._data.keys():
                return ret._data["value"]
            else:
                return None