← Back to team overview

cloud-init-dev team mailing list archive

[Merge] lp:~sgolovatiuk/cloud-init/fix_mcollective into lp:cloud-init

 

Sergii Golovatiuk has proposed merging lp:~sgolovatiuk/cloud-init/fix_mcollective into lp:cloud-init.

Requested reviews:
  cloud init development team (cloud-init-dev)
Related bugs:
  Bug #1597699 in cloud-init: "cc_mcollective.py fails on Ubuntu16.04"
  https://bugs.launchpad.net/cloud-init/+bug/1597699

For more details, see:
https://code.launchpad.net/~sgolovatiuk/cloud-init/fix_mcollective/+merge/298759

Fix cc_mcollective with python 3.

Fixes bug: 1597699
-- 
Your team cloud init development team is requested to review the proposed merge of lp:~sgolovatiuk/cloud-init/fix_mcollective into lp:cloud-init.
=== modified file 'cloudinit/config/cc_mcollective.py'
--- cloudinit/config/cc_mcollective.py	2015-01-21 22:56:53 +0000
+++ cloudinit/config/cc_mcollective.py	2016-06-30 11:09:13 +0000
@@ -20,7 +20,12 @@
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 import six
-from six import StringIO
+try:
+   # Python 3
+i  from io import BytesIO
+except ImportError:
+   # Python 2
+   from six import StringIO as BytesIO
 
 # Used since this can maintain comments
 # and doesn't need a top level section
@@ -79,7 +84,7 @@
         # the previous server.cfg and create our new one
         util.rename(SERVER_CFG, "%s.old" % (SERVER_CFG))
         # Now we got the whole file, write to disk...
-        contents = StringIO()
+        contents = BytesIO()
         mcollective_config.write(contents)
         contents = contents.getvalue()
         util.write_file(SERVER_CFG, contents, mode=0o644)


Follow ups