[DEFAULT]
debug = {{ cloudkitty_logging_debug }}

log_dir = /var/log/kolla/cloudkitty

{% if service_name == 'cloudkitty-api' %}
# Force cloudkitty-api.log or will use app.wsgi
log_file = /var/log/kolla/cloudkitty/cloudkitty-api.log
{% endif %}

transport_url = {{ rpc_transport_url }}

[database]
connection = mysql+pymysql://{{ cloudkitty_database_user }}:{{ cloudkitty_database_password }}@{{ cloudkitty_database_address }}/{{ cloudkitty_database_name }}
connection_recycle_time = {{ database_connection_recycle_time }}
max_pool_size = {{ database_max_pool_size }}
max_retries = -1

[keystone_authtoken]
service_type = rating
www_authenticate_uri = {{ keystone_internal_url }}
auth_url = {{ keystone_internal_url }}
auth_type = password
project_domain_id = {{ default_project_domain_id }}
user_domain_id = {{ default_user_domain_id }}
project_name = service
username = {{ cloudkitty_keystone_user }}
password = {{ cloudkitty_keystone_password }}
region_name = {{ openstack_region_name }}
cafile = {{ openstack_cacert }}

memcache_security_strategy = ENCRYPT
memcache_secret_key = {{ memcache_secret_key }}
memcached_servers = {% for host in groups['memcached'] %}{{ 'api' | kolla_address(host) | put_address_in_context('memcache') }}:{{ memcached_port }}{% if not loop.last %},{% endif %}{% endfor %}

[oslo_middleware]
enable_proxy_headers_parsing = True

[oslo_concurrency]
lock_path = /var/lib/cloudkitty/tmp

{% if cloudkitty_policy_file is defined %}
[oslo_policy]
policy_file = {{ cloudkitty_policy_file }}
{% endif %}

[oslo_messaging_rabbit]
heartbeat_in_pthread = {{ service_name == 'cloudkitty-api' }}
{% if om_enable_rabbitmq_tls | bool %}
ssl = true
ssl_ca_file = {{ om_rabbitmq_cacert }}
{% endif %}
{% if om_enable_rabbitmq_high_availability | bool %}
amqp_durable_queues = true
{% endif %}

[collect]
collector = {{ cloudkitty_collector_backend }}
{% if cloudkitty_custom_metrics_used %}
metrics_conf = /etc/cloudkitty/{{ cloudkitty_custom_metrics_yaml_file }}
{% endif %}

{% if cloudkitty_collector_backend == "gnocchi" %}
[collector_gnocchi]
auth_section = keystone_authtoken
region_name = {{ openstack_region_name }}
{% endif %}

{% if cloudkitty_collector_backend == "prometheus" %}
[collector_prometheus]
prometheus_url = {{ cloudkitty_prometheus_url }}

{% if cloudkitty_prometheus_cafile is defined %}
cafile = {{ cloudkitty_prometheus_cafile }}
{% endif %}

insecure = {{ cloudkitty_prometheus_insecure_connections }}
{% endif %}

[fetcher]
backend = {{ cloudkitty_fetcher_backend }}

{% if cloudkitty_fetcher_backend == "keystone" %}
[fetcher_keystone]
keystone_version = 3
auth_section = keystone_authtoken
cafile = {{ openstack_cacert }}
region_name = {{ openstack_region_name }}
{% endif %}

{% if cloudkitty_fetcher_backend == "prometheus" %}
[fetcher_prometheus]
metric = openstack_identity_project_info
scope_attribute = id
prometheus_url = {{ cloudkitty_prometheus_url }}

{% if cloudkitty_prometheus_cafile is defined %}
cafile = {{ cloudkitty_prometheus_cafile }}
{% endif %}

insecure = {{ cloudkitty_prometheus_insecure_connections }}
{% endif %}

[api]
host_ip = {{ api_interface_address }}
port = {{ cloudkitty_api_port }}

[orchestrator]
coordination_url = mysql://{{ cloudkitty_database_user }}:{{ cloudkitty_database_password }}@{{ cloudkitty_database_address }}/{{ cloudkitty_database_name }}
max_workers = {{ cloudkitty_processor_workers }}

[storage]
backend = {{ cloudkitty_storage_backend }}
{% if cloudkitty_storage_backend == 'sqlalchemy' %}
version = 1
{% else %}
version = 2
{% endif %}

{% if cloudkitty_storage_backend == 'influxdb' %}
[storage_influxdb]
database = {{ cloudkitty_influxdb_name }}
host = {{ influxdb_address }}
port = {{ influxdb_http_port }}

{% if cloudkitty_influxdb_retention_policy is defined %}
retention_policy = {{ cloudkitty_influxdb_retention_policy }}
{% endif %}

{% if cloudkitty_influxdb_use_ssl is defined %}
use_ssl = {{ cloudkitty_influxdb_use_ssl }}
{% endif %}

{% if cloudkitty_influxdb_insecure_connections is defined %}
insecure = {{ cloudkitty_influxdb_insecure_connections }}
{% endif %}

{% if cloudkitty_influxdb_cafile is defined %}
cafile = {{ cloudkitty_influxdb_cafile }}
{% endif %}

{% endif %}

{% if cloudkitty_storage_backend == 'elasticsearch' %}
[storage_elasticsearch]
host = {{ cloudkitty_elasticsearch_url }}
index_name = {{ cloudkitty_elasticsearch_index_name }}
insecure = {{ cloudkitty_elasticsearch_insecure_connections }}

{% if cloudkitty_elasticsearch_cafile is defined %}
cafile = {{ cloudkitty_elasticsearch_cafile }}
{% endif %}

{% endif %}
