integrate gnocchi with ceilometer

Closes-Bug: #1626364
Change-Id: I9d586b950b7099a9b160f7b32c9ff00b189a0287
This commit is contained in:
Jeffrey Zhang 2016-09-29 01:14:55 +08:00 committed by Jeffrey Zhang
parent 7fa1a08fd2
commit 18fa72c901
8 changed files with 35 additions and 17 deletions

View File

@ -344,7 +344,7 @@ glance_backend_ceph: "{{ enable_ceph }}"
#######################
# Ceilometer options
#######################
# Valid options are [ mongodb, mysql ]
# Valid options are [ mongodb, mysql, gnocchi ]
ceilometer_database_type: "mongodb"

View File

@ -7,10 +7,9 @@ project_name: "ceilometer"
####################
ceilometer_database_name: "ceilometer"
ceilometer_database_user: "ceilometer"
ceilometer_database_address_mappings:
mongodb: "{% for host in groups['mongodb'] %}{{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ mongodb_port }}{% if not loop.last %},{% endif %}{% endfor %}"
mysql: "{{ kolla_internal_fqdn }}:{{ database_port }}"
ceilometer_database_address: "{{ ceilometer_database_address_mappings[ceilometer_database_type] }}"
ceilometer_database_mongodb_address: "{% for host in groups['mongodb'] %}{{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ mongodb_port }}{% if not loop.last %},{% endif %}{% endfor %}"
ceilometer_database_mysql_address: "{{ kolla_internal_fqdn }}:{{ database_port }}"
####################

View File

@ -49,6 +49,3 @@
- ceilometer_database_type == "mysql"
- include: bootstrap_service.yml
when:
- ceilometer_database_type == "mysql"
- database.created

View File

@ -7,6 +7,7 @@
environment:
KOLLA_BOOTSTRAP:
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
CEILOMETER_DATABASE_TYPE: "{{ ceilometer_database_type }}"
image: "{{ ceilometer_api_image_full }}"
labels:
BOOTSTRAP:

View File

@ -5,6 +5,11 @@ log_dir = /var/log/kolla/ceilometer
transport_url = rabbit://{% for host in groups['rabbitmq'] %}{{ rabbitmq_user }}:{{ rabbitmq_password }}@{{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ rabbitmq_port }}{% if not loop.last %},{% endif %}{% endfor %}
{% if ceilometer_database_type == 'gnocchi' %}
meter_dispatchers = gnocchi
event_dispatchers = gnocchi
{% endif %}
[api]
port = {{ ceilometer_api_port }}
host = {{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }}
@ -13,11 +18,11 @@ host = {{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['addr
[database]
{% if ceilometer_database_type == "mongodb" %}
event_connection = mongodb://{{ ceilometer_database_user }}:{{ ceilometer_database_password }}@{{ ceilometer_database_address }}/{{ ceilometer_database_name }}
metering_connection = mongodb://{{ ceilometer_database_user }}:{{ ceilometer_database_password }}@{{ ceilometer_database_address }}/{{ ceilometer_database_name }}
event_connection = mongodb://{{ ceilometer_database_user }}:{{ ceilometer_database_password }}@{{ ceilometer_database_mongodb_address }}/{{ ceilometer_database_name }}
metering_connection = mongodb://{{ ceilometer_database_user }}:{{ ceilometer_database_password }}@{{ ceilometer_database_mongodb_address }}/{{ ceilometer_database_name }}
{% elif ceilometer_database_type == "mysql" %}
event_connection = mysql+pymysql://{{ ceilometer_database_user }}:{{ ceilometer_database_password }}@{{ ceilometer_database_address }}/{{ ceilometer_database_name }}
metering_connection = mysql+pymysql://{{ ceilometer_database_user }}:{{ ceilometer_database_password }}@{{ ceilometer_database_address }}/{{ ceilometer_database_name }}
event_connection = mysql+pymysql://{{ ceilometer_database_user }}:{{ ceilometer_database_password }}@{{ ceilometer_database_mysql_address }}/{{ ceilometer_database_name }}
metering_connection = mysql+pymysql://{{ ceilometer_database_user }}:{{ ceilometer_database_password }}@{{ ceilometer_database_mysql_address }}/{{ ceilometer_database_name }}
{% endif %}
[keystone_authtoken]
@ -43,3 +48,10 @@ project_name = service
project_domain_id = default
user_domain_id = default
auth_type = password
{% if ceilometer_database_type == 'gnocchi' %}
[dispatcher_gnocchi]
filter_service_activity = False
url = {{ internal_protocol }}://{{ kolla_internal_fqdn }}:{{ gnocchi_api_port }}
archive_policy = low
{% endif %}

View File

@ -3,7 +3,16 @@
# Bootstrap and exit if KOLLA_BOOTSTRAP variable is set. This catches all cases
# of the KOLLA_BOOTSTRAP variable being set, including empty.
if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
sudo -H -u ceilometer ceilometer-upgrade --skip-gnocchi-resource-types
if [[ "${CEILOMETER_DATABASE_TYPE}" == "mysql" ]]; then
sudo -H -u ceilometer ceilometer-upgrade --skip-gnocchi-resource-types
elif [[ "${CEILOMETER_DATABASE_TYPE}" == "gnocchi" ]]; then
sudo -H -u ceilometer ceilometer-upgrade --skip-metering-database --skip-event-database
elif [[ "${CEILOMETER_DATABASE_TYPE}" == "mongodb" ]]; then
echo "Ceilometer doesn't need to initialize a database when MongoDB is configured as the database backend."
else
echo "Unsupported database type: ${CEILOMETER_DATABASE_TYPE}"
exit 1
fi
sudo chown -R ceilometer: /var/lib/ceilometer/
exit 0
fi

View File

@ -26,10 +26,10 @@ MAINTAINER {{ maintainer }}
ADD ceilometer-base-archive /ceilometer-base-source
RUN ln -s ceilometer-base-source/* ceilometer \
&& useradd --user-group ceilometer \
&& /var/lib/kolla/venv/bin/pip --no-cache-dir install --upgrade -c requirements/upper-constraints.txt /ceilometer pymongo \
&& mkdir -p /etc/ceilometer /var/log/ceilometer /home/ceilometer \
&& /var/lib/kolla/venv/bin/pip --no-cache-dir install --upgrade -c requirements/upper-constraints.txt /ceilometer[gnocchi,mongo,mysql] \
&& mkdir -p /etc/ceilometer /var/lib/ceilometer /home/ceilometer \
&& cp -r /ceilometer/etc/ceilometer/* /etc/ceilometer/ \
&& chown -R ceilometer: /etc/ceilometer /var/log/ceilometer /home/ceilometer \
&& chown -R ceilometer: /etc/ceilometer /var/lib/ceilometer /home/ceilometer \
&& sed -i 's|^exec_dirs.*|exec_dirs=/var/lib/kolla/venv/bin,/sbin,/usr/sbin,/bin,/usr/bin,/usr/local/bin,/usr/local/sbin|g' /etc/ceilometer/rootwrap.conf
{% endif %}

View File

@ -189,7 +189,7 @@ kolla_internal_vip_address: "10.10.10.254"
#######################
# Ceilometer options
#######################
# Valid options are [ mongodb, mysql ]
# Valid options are [ mongodb, mysql, gnocchi ]
#ceilometer_database_type: "mongodb"