1 {%- set node_service_profiles = hosts[inventory_hostname]['service_profiles'] %}
2 {%- if (openstack is defined) and (openstack != '') -%}
3 {%- if (('management' in node_service_profiles) and (ceph_configured | default(False))) -%}
4 {%- set _ = node_service_profiles.append("cephcontroller") -%}
7 {%- if node_service_profiles|length > 1 %}
9 {%- set device_mapping = {} %}
10 {% if device_mapping.update(localstorage[node_service_profiles[0]]) %}{%- endif %}
12 {%- macro update_bigger_hash(hash) -%}
13 {%- set vol_names1 = device_mapping.keys()|list %}
14 {%- set vol_names2 = hash.keys()| list %}
15 {%- set vol_names = vol_names1 + vol_names2| unique|list%}
17 {%- for vol_name in vol_names %}
18 {% if vol_name in device_mapping.keys() and vol_name not in hash.keys() %}
19 {% if device_mapping.update({ vol_name: device_mapping[vol_name]}) %}{%- endif %}
20 {% elif vol_name not in device_mapping.keys() and vol_name in hash.keys() %}
21 {% if device_mapping.update({ vol_name: hash[vol_name]} ) %}{%- endif %}
22 {%- elif device_mapping[vol_name]["lvm_size"]|replace("%VG", "")|int > hash[vol_name]["lvm_size"]|replace("%VG", "")|int %}
23 {% if device_mapping.update({ vol_name: device_mapping[vol_name]}) %}{%- endif %}
25 {% if device_mapping.update({ vol_name: hash[vol_name]} ) %}{%- endif %}
30 {%- for index in range(1, node_service_profiles | length) -%}
31 {%-if update_bigger_hash(localstorage[node_service_profiles[index]]) -%}{%- endif %}
35 {%- set device_mapping = localstorage[node_service_profiles[0]] %}
38 {% set allocated_vg = device_mapping.values() | map(attribute="lvm_size") | map("replace", "%VG", "") | map("int") | sum %}
39 {% set variable_found = device_mapping.values() | selectattr("lvm_size", "search", "variable") | list %}
40 {% if variable_found %}
41 {% set variable_size = (100-allocated_vg) | string + '%VG'%}
42 {% set _ = variable_found[0].update({'lvm_size': variable_size}) %}
47 {%- for vol_value in device_mapping.values() %}
49 {%- for vol_details_key,vol_details_value in vol_value.iteritems() %}
50 "{{vol_details_key}}":"{{vol_details_value}}"{% if not loop.last %},{% endif %}
52 }{% if not loop.last %},{% endif %}