tasks: cinder_qos: Use the new OpenStack CLI client

Previous fix that changed grep options broke things even more.
This commit changes way how we create and associate QoS rules utilising
python-openstackclient.
It handles correctly cases where names contain their fragments in other.

Related-Bug: #1741990
Change-Id: If6181059f1bb1f582537ebe646f81c0a8d33d59c
This commit is contained in:
Damian Cikowski 2018-10-25 21:40:21 +02:00
parent 981611b35a
commit 86a5ddc49c
1 changed files with 5 additions and 6 deletions

View File

@ -17,9 +17,10 @@
shell: |
. {{ ansible_env.HOME }}/openrc
CLI_OPTIONS="{{ ((keystone_service_adminuri_insecure | bool) or (cinder_service_internaluri_insecure | bool)) | ternary('--insecure','') }}"
{{ cinder_bin }}/cinder qos-list | grep -x {{ item.name }} || \
{{ cinder_bin }}/cinder qos-create {{ item.name }}\
{% for k,v in item.options.items() %} {{ k }}={{ v }}{% endfor %}
{{ cinder_bin }}/openstack volume qos list --format value --column Name | grep -x {{ item.name }} || \
{{ cinder_bin }}/openstack volume qos create {{ item.name }} \
--consumer {{ item.options.consumer }}\
{% for k,v in item.options.items() %} --property {{ k }}={{ v }}{% endfor %}
args:
executable: /bin/bash
with_items: "{{ cinder_qos_specs }}"
@ -32,9 +33,7 @@
. {{ ansible_env.HOME }}/openrc
CLI_OPTIONS="{{ ((keystone_service_adminuri_insecure | bool) or (cinder_service_internaluri_insecure | bool)) | ternary('--insecure','') }}"
{% for vtype in item.cinder_volume_types %}
{{ cinder_bin }}/cinder qos-associate \
$({{ cinder_bin }}/cinder qos-list | grep -x {{ item.name }} | grep -oE "{{ _UUID_regex }}") \
$({{ cinder_bin }}/cinder type-list | grep -x {{ vtype }} | grep -oE "{{ _UUID_regex }}")
{{ cinder_bin }}/openstack volume qos associate {{ item.name }} {{ vtype }}
{% endfor %}
args:
executable: /bin/bash