Updated config parsing for listOPS
This change updates the list parsing for all list options passed through the config_template module using the INI configuration type. This change is needed so that when passing a list into a configuration file for use within an OpenStack service oslo.config properlly handles the lists as a comma seperated value when rendered. Closes-Bug: #1543588 Change-Id: If8055b3362f1d9d1f274baa447fac094a6a91481 Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
parent
da3da53c10
commit
852ab82262
@ -67,6 +67,8 @@ class ActionModule(object):
|
||||
# If the items value is not a dictionary it is assumed that the
|
||||
# value is a default item for this config type.
|
||||
if not isinstance(items, dict):
|
||||
if isinstance(items, list):
|
||||
items = ','.join(items)
|
||||
config.set('DEFAULT', str(section), str(items))
|
||||
else:
|
||||
# Attempt to add a section to the config file passing if
|
||||
@ -77,6 +79,8 @@ class ActionModule(object):
|
||||
except (ConfigParser.DuplicateSectionError, ValueError):
|
||||
pass
|
||||
for key, value in items.items():
|
||||
if isinstance(value, list):
|
||||
value = ','.join(value)
|
||||
config.set(str(section), str(key), str(value))
|
||||
else:
|
||||
config_object.close()
|
||||
@ -140,11 +144,11 @@ class ActionModule(object):
|
||||
base_items.get(key, {}),
|
||||
value
|
||||
)
|
||||
elif ',' in value or '\n' in value:
|
||||
base_items[key] = re.split(', |,|\n', value)
|
||||
base_items[key] = [i.strip() for i in base_items[key] if i]
|
||||
elif isinstance(value, list):
|
||||
if key in base_items and isinstance(base_items[key], list):
|
||||
base_items[key].extend(value)
|
||||
else:
|
||||
base_items[key] = value
|
||||
base_items[key] = value
|
||||
else:
|
||||
base_items[key] = new_items[key]
|
||||
return base_items
|
||||
|
Loading…
x
Reference in New Issue
Block a user