Sync support for openstack comma-separated config values from charm-helpers

Openstack config files accept comma-separated lists for values so
we now accept this in charm config files when defining openstack
config values.
  
Fixes: bug 1246796
This commit is contained in:
Edward Hope-Morley 2013-12-18 14:57:37 +00:00
parent f66ad7c77c
commit 5a3c16ed49

@ -446,7 +446,15 @@ class OSConfigFlagContext(OSContextGenerator):
if not config_flags:
return {}
strippers = ' ,'
if config_flags.find('==') >= 0:
log("config_flags is not in expected format (key=value)",
level=ERROR)
raise OSContextError
# strip the following from each value.
post_strippers = ' ,'
# we strip any leading/trailing '=' or ' ' from the string then
# split on '='.
split = config_flags.strip(' =').split('=')
limit = len(split)
flags = {}
@ -457,18 +465,21 @@ class OSConfigFlagContext(OSContextGenerator):
if (i == limit - 2) or (vindex < 0):
value = next
else:
value = next[:vindex]
value = next[:vindex]
if i == 0:
key = current
else:
# if this not the first entry, expect an embedded key.
index = current.rfind(',')
if index < 0:
log("error: invalid config value(s) at index %s" % (i))
log("invalid config value(s) at index %s" % (i),
level=ERROR)
raise OSContextError
key = current[index + 1:]
flags[key.strip(strippers)] = value.rstrip(strippers)
# Add to collection.
flags[key.strip(post_strippers)] = value.rstrip(post_strippers)
return {'user_config_flags': flags}