summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cloudinit/net/sysconfig.py6
-rw-r--r--tests/unittests/test_net.py3
2 files changed, 8 insertions, 1 deletions
diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py
index a550f97c..f5727969 100644
--- a/cloudinit/net/sysconfig.py
+++ b/cloudinit/net/sysconfig.py
@@ -484,7 +484,11 @@ class Renderer(renderer.Renderer):
content.add_nameserver(nameserver)
for searchdomain in network_state.dns_searchdomains:
content.add_search_domain(searchdomain)
- return "\n".join([_make_header(';'), str(content)])
+ header = _make_header(';')
+ content_str = str(content)
+ if not content_str.startswith(header):
+ content_str = header + '\n' + content_str
+ return content_str
@staticmethod
def _render_networkmanager_conf(network_state):
diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
index e49abcc4..4653be1a 100644
--- a/tests/unittests/test_net.py
+++ b/tests/unittests/test_net.py
@@ -1683,6 +1683,9 @@ USERCTL=no
ns = network_state.parse_net_config_data(network_cfg,
skip_broken=False)
renderer = sysconfig.Renderer()
+ # render a multiple times to simulate reboots
+ renderer.render_network_state(ns, render_dir)
+ renderer.render_network_state(ns, render_dir)
renderer.render_network_state(ns, render_dir)
for fn, expected_content in os_sample.get('out_sysconfig', []):
with open(os.path.join(render_dir, fn)) as fh: