Add support for additional volume-types

Currently, the cinder role only supports creating
one volume-type per configured cinder backend.

This change allows deployers to specify an optional
list ``extra_volume_types`` for any/each of the cinder
backends to create additional volume types and associate
them to the respective backend.

Change-Id: Ie1b1fcaaa355584cbb364ac448f784e3644d668e
This commit is contained in:
Michael Gugino 2016-09-28 18:24:27 -04:00
parent 4888d5a5d1
commit dabee73b27
3 changed files with 20 additions and 0 deletions

View File

@ -193,6 +193,9 @@ cinder_quota_backup_gigabytes: 1000
# volume_group: cinder-volumes
# volume_driver: cinder.volume.drivers.lvm.LVMVolumeDriver
# volume_backend_name: LVM_iSCSI
# extra_volume_types:
# - lvm_high_iops
# - lvm_low_iops
# cinder_backend_lvm_inuse: True if current host has an lvm backend
cinder_backend_lvm_inuse: '{{ (cinder_backends|default("")|to_json).find("lvm") != -1 }}'

View File

@ -0,0 +1,5 @@
---
features:
- Additional volume-types can be created by defining a
list named ``extra_volume_types`` in the desired
backend of the variable(s) ``cinder_backends``

View File

@ -30,3 +30,15 @@
{{ cinder_bin }}/cinder {{ keystone_service_adminuri_insecure | bool | ternary('--insecure','') }} type-key "{{ item.key }}" set volume_backend_name="{{ item.value.volume_backend_name }}"
fi
with_dict: "{{ cinder_backends|default({}) }}"
- name: Add extra cinder volume types
shell: |
. {{ ansible_env.HOME }}/openrc
{% for evtype in item.value.extra_volume_types %}
if ! {{ cinder_bin }}/cinder {{ keystone_service_adminuri_insecure | bool | ternary('--insecure','') }} type-list | grep "{{ evtype }}"; then
{{ cinder_bin }}/cinder {{ keystone_service_adminuri_insecure | bool | ternary('--insecure','') }} type-create "{{ evtype }}"
{{ cinder_bin }}/cinder {{ keystone_service_adminuri_insecure | bool | ternary('--insecure','') }} type-key "{{ evtype }}" set volume_backend_name="{{ item.value.volume_backend_name }}"
fi
{% endfor %}
with_dict: "{{ cinder_backends|default({}) }}"
when: item.value.extra_volume_types is defined