From b04a1b2fb41c32074001058e7fad1d79c321b139 Mon Sep 17 00:00:00 2001 From: Joe Talerico Date: Mon, 13 Mar 2017 14:51:59 -0400 Subject: [PATCH] Metdata was missing section If there is no section, section will default to DEFAULT. Change-Id: I4d42d0ceac54e923cdb7d62b801336e1f07d258c --- .../common/files/openstack-config-parser.py | 8 +++-- ansible/gather/roles/keystone/tasks/main.yml | 8 ++--- lib/Metadata.py | 35 ++++++++++++++----- 3 files changed, 35 insertions(+), 16 deletions(-) diff --git a/ansible/gather/roles/common/files/openstack-config-parser.py b/ansible/gather/roles/common/files/openstack-config-parser.py index 64c628483..2673b0418 100644 --- a/ansible/gather/roles/common/files/openstack-config-parser.py +++ b/ansible/gather/roles/common/files/openstack-config-parser.py @@ -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 diff --git a/ansible/gather/roles/keystone/tasks/main.yml b/ansible/gather/roles/keystone/tasks/main.yml index ae6052a8f..e8c9da47b 100644 --- a/ansible/gather/roles/keystone/tasks/main.yml +++ b/ansible/gather/roles/keystone/tasks/main.yml @@ -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 diff --git a/lib/Metadata.py b/lib/Metadata.py index c9f8851ba..bce7da98f 100644 --- a/lib/Metadata.py +++ b/lib/Metadata.py @@ -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