def configure(config_values):
    """
    Converts a collectd configuration into rabbitmq configuration.
    """

    collectd.debug('Configuring RabbitMQ Plugin')
    data_to_ignore = dict()
    scheme = 'http'
    validate_certs = True
    vhost_prefix = None
    local_queues_only = False

    for config_value in config_values.children:
        collectd.debug("%s = %s" % (config_value.key, config_value.values))
        if len(config_value.values) > 0:
            if config_value.key == 'Username':
                username = config_value.values[0]
            elif config_value.key == 'Password':
                password = config_value.values[0]
            elif config_value.key == 'Host':
                host = config_value.values[0]
            elif config_value.key == 'Port':
                port = config_value.values[0]
            elif config_value.key == 'Realm':
                realm = config_value.values[0]
            elif config_value.key == 'Scheme':
                scheme = config_value.values[0]
            elif config_value.key == 'VHostPrefix':
                vhost_prefix = config_value.values[0]
            elif config_value.key == 'ValidateCerts':
                validate_certs = config_value.values[0]
            elif config_value.key == 'LocalQueuesOnly':
                local_queues_only = config_value.values[0]
            elif config_value.key == 'Ignore':
                type_rmq = config_value.values[0]
                data_to_ignore[type_rmq] = list()
                for regex in config_value.children:
                    data_to_ignore[type_rmq].append(regex.values[0])

    global CONFIGS  # pylint: disable=W0603

    auth = utils.Auth(username, password, realm)
    conn = utils.ConnectionInfo(host, port, scheme,
                                validate_certs=validate_certs)
    config = utils.Config(auth, conn, data_to_ignore, vhost_prefix,
                          local_queues_only)
    CONFIGS.append(config)
Example #2
0
def configure(config_values):
    """
    Converts a collectd configuration into rabbitmq configuration.
    """

    collectd.debug('Configuring RabbitMQ Plugin')
    data_to_ignore = dict()
    scheme = 'http'
    vhost_prefix = None

    for config_value in config_values.children:
        collectd.debug("%s = %s" % (config_value.key, config_value.values))
        if len(config_value.values) > 0:
            if config_value.key == 'Username':
                username = config_value.values[0]
            elif config_value.key == 'Password':
                password = config_value.values[0]
            elif config_value.key == 'Host':
                host = config_value.values[0]
            elif config_value.key == 'Port':
                port = config_value.values[0]
            elif config_value.key == 'Realm':
                realm = config_value.values[0]
            elif config_value.key == 'Scheme':
                scheme = config_value.values[0]
            elif config_value.key == 'VHostPrefix':
                vhost_prefix = config_value.values[0]
            elif config_value.key == 'Ignore':
                type_rmq = config_value.values[0]
                data_to_ignore[type_rmq] = list()
                for regex in config_value.children:
                    data_to_ignore[type_rmq].append(regex.values[0])

    global AUTH  # pylint: disable=W0603
    global CONN  # pylint: disable=W0603
    global CONFIG  # pylint: disable=W0603

    AUTH = utils.Auth(username, password, realm)
    CONN = utils.ConnectionInfo(host, port, scheme)
    CONFIG = utils.Config(AUTH, CONN, data_to_ignore, vhost_prefix)
 def setUp(self):
     self.conn = utils.ConnectionInfo(host="example.com",
                                      port=15672,
                                      scheme="http")
     self.auth = utils.Auth()