Fix writing of keys without values
Sometimes there might be a key in configfile, that should be empty but defined correctly. This patch fixes such behaviour and adds testing. Change-Id: I693bc3a2aade7015d0465583001962df4ba53443
This commit is contained in:
parent
09c76e2380
commit
b7f38639a2
@ -220,8 +220,11 @@ class ConfigTemplateParser(ConfigParser.RawConfigParser):
|
||||
|
||||
def _write_check(self, fp, key, value, section=False):
|
||||
def _return_entry(option, item):
|
||||
if item:
|
||||
# If we have item, we consider it as a config parameter with value
|
||||
if item is not None:
|
||||
return "%s = %s\n" % (option, str(item).replace('\n', '\n\t'))
|
||||
elif not option:
|
||||
return option
|
||||
else:
|
||||
return "%s\n" % option
|
||||
|
||||
|
@ -1,44 +1,36 @@
|
||||
[DEFAULT]
|
||||
|
||||
#
|
||||
# From nova.conf
|
||||
#
|
||||
|
||||
#
|
||||
# Availability zone for internal services. For more information, refer to the
|
||||
# documentation. (string value)
|
||||
#internal_service_availability_zone = internal
|
||||
|
||||
#
|
||||
# Default availability zone for compute services. For more information, refer to
|
||||
# the documentation. (string value)
|
||||
#default_availability_zone = nova
|
||||
default_availability_zone = zone1
|
||||
|
||||
#
|
||||
# Default availability zone for instances. For more information, refer to the
|
||||
# documentation. (string value)
|
||||
#default_schedule_zone = <None>
|
||||
|
||||
# Length of generated instance admin passwords (integer value)
|
||||
# Minimum value = 0
|
||||
#password_length = 12
|
||||
password_length = 100
|
||||
|
||||
#
|
||||
# Time period to generate instance usages for. It is possible to define optional
|
||||
# offset to given period by appending @ character followed by a number defining
|
||||
# offset. For more information, refer to the documentation. (string value)
|
||||
#instance_usage_audit_period = month
|
||||
instance_usage_audit_period = blah blah blah
|
||||
|
||||
test = test1,test2
|
||||
|
||||
[SubSection]
|
||||
#Comments and overrides in a subsection
|
||||
#testopt1 = 9000
|
||||
testopt1 = 9000
|
||||
|
||||
# This is another test opt
|
||||
#testop2 = over 9000
|
||||
|
||||
|
@ -1,9 +1,11 @@
|
||||
[global]
|
||||
test1 = 1
|
||||
# This is a post option comment
|
||||
|
||||
test2 = 2
|
||||
|
||||
[section1]
|
||||
setting1 = 1
|
||||
setting2 = 2
|
||||
setting2 = 2
|
||||
|
||||
[section2]
|
||||
setting3 =
|
||||
|
@ -3,10 +3,8 @@ test = test1
|
||||
test = test2
|
||||
test = test3
|
||||
|
||||
|
||||
[testsection]
|
||||
test = output
|
||||
|
||||
|
||||
[remote_src_section]
|
||||
test = output
|
||||
|
@ -3,4 +3,7 @@ test1 = 1
|
||||
# This is a post option comment
|
||||
|
||||
[section1]
|
||||
setting1 = 1
|
||||
setting1 = 1
|
||||
|
||||
[section2]
|
||||
setting3 =
|
Loading…
x
Reference in New Issue
Block a user