Merge pull request #1997 from evgeni/lxc-container_config-fixes

Lxc container config fixes
This commit is contained in:
René Moser 2016-04-14 23:16:52 +02:00
commit 7c613c314c

View file

@ -424,6 +424,8 @@ lxc_container:
sample: True sample: True
""" """
import re
try: try:
import lxc import lxc
except ImportError: except ImportError:
@ -745,10 +747,13 @@ class LxcContainerManagement(object):
config_change = False config_change = False
for key, value in parsed_options: for key, value in parsed_options:
key = key.strip()
value = value.strip()
new_entry = '%s = %s\n' % (key, value) new_entry = '%s = %s\n' % (key, value)
keyre = re.compile(r'%s(\s+)?=' % key)
for option_line in container_config: for option_line in container_config:
# Look for key in config # Look for key in config
if option_line.startswith(key): if keyre.match(option_line):
_, _value = option_line.split('=', 1) _, _value = option_line.split('=', 1)
config_value = ' '.join(_value.split()) config_value = ' '.join(_value.split())
line_index = container_config.index(option_line) line_index = container_config.index(option_line)