summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2016-04-06 14:30:02 -0400
committerScott Moser <smoser@ubuntu.com>2016-04-06 14:30:02 -0400
commit822ac18bc98dee35c805bf238f6bf0a1543a39dc (patch)
tree4170307285b8f6ce5563ac3c8b8dbf2a71b3087e
parentd75a912fb375afbab055db3178966d1f83b44143 (diff)
parent2fd22530737468a00bfb58eed9b6e231aa6d6652 (diff)
downloadvyos-cloud-init-822ac18bc98dee35c805bf238f6bf0a1543a39dc.tar.gz
vyos-cloud-init-822ac18bc98dee35c805bf238f6bf0a1543a39dc.zip
Ensure that a resolve conf object is written as a string.
Instead of passing the raw object and expecting the write_file to work automatically make sure we explicitly pass the string version of it so that the write_file routine can correctly encode/decode it as needed. LP: #1479988
-rw-r--r--ChangeLog1
-rw-r--r--cloudinit/distros/rhel_util.py2
-rw-r--r--tests/unittests/test_distros/test_resolv.py6
3 files changed, 8 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 9fb6e6d4..d12ad501 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -102,6 +102,7 @@
- disk_setup: correctly send --force to mkfs on block devices (LP: #1548772)
- chef: fix chef install from gems (LP: #1553345)
- systemd: do not specify After of obsolete syslog.target (LP: #1536964)
+ - centos: Ensure that resolve conf object is written as a str (LP: #1479988)
0.7.6:
- open 0.7.6
diff --git a/cloudinit/distros/rhel_util.py b/cloudinit/distros/rhel_util.py
index 84aad623..903d7793 100644
--- a/cloudinit/distros/rhel_util.py
+++ b/cloudinit/distros/rhel_util.py
@@ -86,4 +86,4 @@ def update_resolve_conf_file(fn, dns_servers, search_servers):
r_conf.add_search_domain(s)
except ValueError:
util.logexc(LOG, "Failed at adding search domain %s", s)
- util.write_file(fn, r_conf, 0o644)
+ util.write_file(fn, str(r_conf), 0o644)
diff --git a/tests/unittests/test_distros/test_resolv.py b/tests/unittests/test_distros/test_resolv.py
index faaf5b7f..9edeb6e7 100644
--- a/tests/unittests/test_distros/test_resolv.py
+++ b/tests/unittests/test_distros/test_resolv.py
@@ -1,6 +1,8 @@
from cloudinit.distros.parsers import resolv_conf
+from cloudinit.distros import rhel_util
import re
+import tempfile
from ..helpers import TestCase
@@ -19,6 +21,10 @@ class TestResolvHelper(TestCase):
rp_r = str(rp).strip()
self.assertEquals(BASE_RESOLVE, rp_r)
+ def test_write_works(self):
+ with tempfile.NamedTemporaryFile() as fh:
+ rhel_util.update_resolve_conf_file(fh.name, [], [])
+
def test_local_domain(self):
rp = resolv_conf.ResolvConf(BASE_RESOLVE)
self.assertEquals(None, rp.local_domain)