Metdata was missing section

If there is no section, section will default to DEFAULT.

Change-Id: I4d42d0ceac54e923cdb7d62b801336e1f07d258c
This commit is contained in:
Joe Talerico 2017-03-13 14:51:59 -04:00
parent e89796ad1c
commit b04a1b2fb4
3 changed files with 35 additions and 16 deletions

View File

@ -8,6 +8,7 @@ def parse_config(serviceName, fileName):
# stored.
values = {}
with open(fileName) as config:
section = None
for line in config:
pair = line.replace('#', '')
pair = pair.replace('\n', '')
@ -20,9 +21,10 @@ def parse_config(serviceName, fileName):
# excludes any line without a key/val pair
valid_line = not line.startswith(
"# ") and '[' not in line and line != '\n' and line != '#\n' and "password" not in line.lower()
if '#' not in line and valid_line:
values["openstack_" + serviceName + "_" + pair[0]] = pair[1]
if line.startswith('['):
section = line.replace('[','').replace(']','').replace('\n','')
if '#' not in line and valid_line and not section == None:
values["openstack_S_" + serviceName + "_S_" + section + "_S_" + pair[0]] = pair[1]
return values

View File

@ -57,8 +57,8 @@
- name: Set keystone httpd worker facts
set_fact:
openstack_keystone_admin_workers_processes: "{{ keystone_admin_worker_processes.stdout }}"
openstack_keystone_admin_workers_threads: "{{ keystone_admin_worker_threads.stdout }}"
openstack_keystone_main_workers_processes: "{{ keystone_main_worker_processes.stdout }}"
openstack_keystone_main_workers_threads: "{{ keystone_main_worker_threads.stdout }}"
openstack_S_keystone_S_admin_workers_S_processes: "{{ keystone_admin_worker_processes.stdout }}"
openstack_S_keystone_S_admin_workers_S_threads: "{{ keystone_admin_worker_threads.stdout }}"
openstack_S_keystone_S_main_workers_S_processes: "{{ keystone_main_worker_processes.stdout }}"
openstack_S_keystone_S_main_workers_S_threads: "{{ keystone_main_worker_threads.stdout }}"
when: keystone_in_eventlet.stdout|int == 0

View File

@ -72,18 +72,35 @@ class Metadata(object):
software_dict = {}
for soft in item:
if 'openstack' in soft:
service = soft.split('_')
key = soft.split('_', 2)[2]
service_name = service[1]
"""
Why _S_? Because Ansible doesn't allow for
many seperators. The _S_ was used to mimic
a seperator.
"""
service = soft.split('_S_')
if len(service) < 2 :
service = soft.split('_')
key = service[2]
section = "DEFAULT"
service_name = service[1]
else :
key = service[3]
section = service[2]
service_name = service[1]
node = item['inventory_hostname']
if service_name in software_dict:
if service_name in soft:
software_dict[service_name][key] = item[soft]
if service_name in software_dict :
if section in software_dict[service_name] :
software_dict[service_name][section][key] = item[soft]
else :
software_dict[service_name][section] = {}
software_dict[service_name][section][key] = item[soft]
else:
software_dict[service_name] = {}
if service_name in soft:
software_dict[service_name]['node_name'] = node
software_dict[service_name][key] = item[soft]
software_dict[service_name]['node_name'] = node
software_dict[service_name][section] = {}
software_dict[service_name][section][key] = item[soft]
soft_all_dict.append(software_dict)
return soft_all_dict