summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cloudinit/config/cc_rsyslog.py2
-rw-r--r--tests/unittests/test_handler/test_handler_rsyslog.py9
2 files changed, 11 insertions, 0 deletions
diff --git a/cloudinit/config/cc_rsyslog.py b/cloudinit/config/cc_rsyslog.py
index 5ecf1629..a0132d28 100644
--- a/cloudinit/config/cc_rsyslog.py
+++ b/cloudinit/config/cc_rsyslog.py
@@ -307,6 +307,8 @@ def remotes_to_rsyslog_cfg(remotes, header=None, footer=None):
if header is not None:
lines.append(header)
for name, line in remotes.items():
+ if not line:
+ continue
try:
lines.append(str(parse_remotes_line(line, name=name)))
except ValueError as e:
diff --git a/tests/unittests/test_handler/test_handler_rsyslog.py b/tests/unittests/test_handler/test_handler_rsyslog.py
index 7bfa65a9..b932165c 100644
--- a/tests/unittests/test_handler/test_handler_rsyslog.py
+++ b/tests/unittests/test_handler/test_handler_rsyslog.py
@@ -163,3 +163,12 @@ class TestRemotesToSyslog(t_help.TestCase):
lines = r.splitlines()
self.assertTrue(header, lines[0])
self.assertTrue(footer, lines[-1])
+
+ def test_with_empty_or_null(self):
+ mycfg = "*.* myhost"
+ myline = str(parse_remotes_line(mycfg, name="myname"))
+ r = remotes_to_rsyslog_cfg(
+ {'myname': mycfg, 'removed': None, 'removed2': ""})
+ lines = r.splitlines()
+ self.assertEqual(1, len(lines))
+ self.assertTrue(myline in r.splitlines())