From 4bc301ff13dc4ad742cb4a191cc016c99c7fa846 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotjagov Date: Thu, 27 Sep 2018 18:04:51 +0300 Subject: [PATCH] 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 --- defaults/main.yml | 4 ++++ tasks/main.yml | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/defaults/main.yml b/defaults/main.yml index 68b1842c..fc7da6fc 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -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 }}" diff --git a/tasks/main.yml b/tasks/main.yml index 87e4ef75..18729b53 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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"