Added volume usage collection, when cinder_ceilometer_enabled

In order to get volume metrics sended to ceilometer,
cinder-volume-usage-audit must be manually runned (or with cron/systemd timer).
Similar to nova approach (volume_usage_audit_period in cinder.conf)
is not working.

So this change add cinder_volume_usage_audit variable,
according to which cron job will be placed
on cinder-volumes servers.

Job uses another type of quotes, due to escaping problems

Change-Id: Iaf021f7776a73a68676d762cb84518b0db412ddd
This commit is contained in:
Dmitriy Rabotjagov 2018-09-27 18:04:51 +03:00 committed by Dmitriy Rabotjagov (noonedeadpunk)
parent 9cd2f62e81
commit 4bc301ff13
2 changed files with 26 additions and 0 deletions

View File

@ -58,6 +58,10 @@ cinder_barbican_enabled: False
# Enable/Disable Ceilometer
cinder_ceilometer_enabled: False
# Time period for which to generate volume usages. The options are hour, day,
# month, or year. (string value)
cinder_volume_usage_audit: hour
cinder_storage_availability_zone: nova
cinder_default_availability_zone: "{{ cinder_storage_availability_zone }}"

View File

@ -72,6 +72,28 @@
tags:
- cinder-config
- name: Run the systemd service role
include_role:
name: systemd_service
private: true
vars:
systemd_service_enabled: "{{ ((cinder_services['cinder-volume']['group'] in group_names) and (cinder_ceilometer_enabled | bool)) | ternary(true, false) }}"
systemd_service_restart_changed: false
systemd_user_name: "{{ cinder_system_user_name }}"
systemd_group_name: "{{ cinder_system_group_name }}"
systemd_services:
- service_name: "cinder-volume-usage-audit"
execstarts:
- '/bin/bash -c "{{ cinder_bin }}/cinder-volume-usage-audit --start_time \"$$(date\s+%%Y-%%m-%%d\\\s%%H:00:00\s-d\s-1{{ cinder_volume_usage_audit }})\" --end_time \"$$(date\s+%%Y-%%m-%%d\\\s%%H:00:00)\" --send_actions"'
timer:
state: "{{ ((cinder_services['cinder-volume']['group'] in group_names) and (cinder_ceilometer_enabled | bool)) | ternary('started', 'stopped') }}"
options:
OnBootSec: 30min
OnCalendar: "{{ (cinder_volume_usage_audit == 'day') | ternary('daily', cinder_volume_usage_audit+'ly') }}"
Persistent: true
tags:
- cinder-config
- import_tasks: mq_setup.yml
when:
- "cinder_services['cinder-api']['group'] in group_names"