call to_text on full config file fixes issue #30571pull/4420/head
parent
c6a676c025
commit
0a114436fc
|
@ -438,6 +438,7 @@ else:
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.parsing.convert_bool import BOOLEANS_FALSE, BOOLEANS_TRUE
|
from ansible.module_utils.parsing.convert_bool import BOOLEANS_FALSE, BOOLEANS_TRUE
|
||||||
from ansible.module_utils.six.moves import xrange
|
from ansible.module_utils.six.moves import xrange
|
||||||
|
from ansible.module_utils._text import to_text, to_bytes
|
||||||
|
|
||||||
|
|
||||||
# LXC_COMPRESSION_MAP is a map of available compression types when creating
|
# LXC_COMPRESSION_MAP is a map of available compression types when creating
|
||||||
|
@ -572,7 +573,7 @@ def create_script(command):
|
||||||
(fd, script_file) = tempfile.mkstemp(prefix='lxc-attach-script')
|
(fd, script_file) = tempfile.mkstemp(prefix='lxc-attach-script')
|
||||||
f = os.fdopen(fd, 'wb')
|
f = os.fdopen(fd, 'wb')
|
||||||
try:
|
try:
|
||||||
f.write(ATTACH_TEMPLATE % {'container_command': command})
|
f.write(to_bytes(ATTACH_TEMPLATE % {'container_command': command}, errors='surrogate_or_strict'))
|
||||||
f.flush()
|
f.flush()
|
||||||
finally:
|
finally:
|
||||||
f.close()
|
f.close()
|
||||||
|
@ -722,7 +723,7 @@ class LxcContainerManagement(object):
|
||||||
|
|
||||||
container_config_file = self.container.config_file_name
|
container_config_file = self.container.config_file_name
|
||||||
with open(container_config_file, 'rb') as f:
|
with open(container_config_file, 'rb') as f:
|
||||||
container_config = f.readlines()
|
container_config = to_text(f.read(), errors='surrogate_or_strict').splitlines()
|
||||||
|
|
||||||
# Note used ast literal_eval because AnsibleModule does not provide for
|
# Note used ast literal_eval because AnsibleModule does not provide for
|
||||||
# adequate dictionary parsing.
|
# adequate dictionary parsing.
|
||||||
|
@ -763,7 +764,7 @@ class LxcContainerManagement(object):
|
||||||
self.container.stop()
|
self.container.stop()
|
||||||
|
|
||||||
with open(container_config_file, 'wb') as f:
|
with open(container_config_file, 'wb') as f:
|
||||||
f.writelines(container_config)
|
f.writelines([to_bytes(line, errors='surrogate_or_strict') for line in container_config])
|
||||||
|
|
||||||
self.state_change = True
|
self.state_change = True
|
||||||
if container_state == 'running':
|
if container_state == 'running':
|
||||||
|
|
Loading…
Reference in New Issue