summaryrefslogtreecommitdiff
path: root/cloudinit/config/cc_landscape.py
diff options
context:
space:
mode:
authorChad Smith <chad.smith@canonical.com>2017-08-23 13:24:38 -0600
committerChad Smith <chad.smith@canonical.com>2017-08-23 13:24:38 -0600
commitf831a874021f3d6d24cbe5639a176f416b5436a6 (patch)
treebde30e1520ea195fdf3c2d2faeca47810f7f4034 /cloudinit/config/cc_landscape.py
parentcc9762a2d737ead386ffb9f067adc5e543224560 (diff)
downloadvyos-cloud-init-f831a874021f3d6d24cbe5639a176f416b5436a6.tar.gz
vyos-cloud-init-f831a874021f3d6d24cbe5639a176f416b5436a6.zip
cc_landscape & cc_puppet: Fix six.StringIO use in writing configs
Both landscape and puppet modules had issues with the way they wrote /etc/landscape/client.conf or /etc/puppet/puppet.conf in either python3 or python2. This branch adds initial unit tests for both modules which will get better exercise under both python2 and python3. The unit tests shed light on a few issues: - In the cc_landscape module py3 can't provide six.StringIO content to ConfigParser.write, so we need to use six.BytesIO instead - In the cc_puppet module, python <= 2.7 doesn't support using six.StringIO as a context manager, so we drop the context manager fanciness and directly set outputstream = StringIO(). - The docstring in cc_puppet is fixed to document the 'conf' sub-key requiring valid puppet section names for each key-value list. LP: #1699282 LP: #1710932
Diffstat (limited to 'cloudinit/config/cc_landscape.py')
-rw-r--r--cloudinit/config/cc_landscape.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/cloudinit/config/cc_landscape.py b/cloudinit/config/cc_landscape.py
index 86b71383..8f9f1abd 100644
--- a/cloudinit/config/cc_landscape.py
+++ b/cloudinit/config/cc_landscape.py
@@ -57,7 +57,7 @@ The following default client config is provided, but can be overridden::
import os
-from six import StringIO
+from six import BytesIO
from configobj import ConfigObj
@@ -109,7 +109,7 @@ def handle(_name, cfg, cloud, log, _args):
ls_cloudcfg,
]
merged = merge_together(merge_data)
- contents = StringIO()
+ contents = BytesIO()
merged.write(contents)
util.ensure_dir(os.path.dirname(LSC_CLIENT_CFG_FILE))