summaryrefslogtreecommitdiff
path: root/cloudinit/config/cc_rsyslog.py
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2015-07-27 16:49:30 -0400
committerScott Moser <smoser@ubuntu.com>2015-07-27 16:49:30 -0400
commit22cb92421234c31b783ed9df01439c734535ba01 (patch)
treee09144bdd03cd6559bcf19edfc37f4bb4585446e /cloudinit/config/cc_rsyslog.py
parent247f2cecb72a852a42f147645e80b538eee05f93 (diff)
downloadvyos-cloud-init-22cb92421234c31b783ed9df01439c734535ba01.tar.gz
vyos-cloud-init-22cb92421234c31b783ed9df01439c734535ba01.zip
add rsyslog tests
reasonable test of reworked rsyslog module
Diffstat (limited to 'cloudinit/config/cc_rsyslog.py')
-rw-r--r--cloudinit/config/cc_rsyslog.py27
1 files changed, 9 insertions, 18 deletions
diff --git a/cloudinit/config/cc_rsyslog.py b/cloudinit/config/cc_rsyslog.py
index 7d5657bc..a07200c3 100644
--- a/cloudinit/config/cc_rsyslog.py
+++ b/cloudinit/config/cc_rsyslog.py
@@ -113,17 +113,18 @@ def load_config(cfg):
# support converting the old top level format into new format
mycfg = cfg.get('rsyslog', {})
- if isinstance(mycfg, list):
- mycfg[KEYNAME_CONFIGS] = mycfg
+ if isinstance(cfg.get('rsyslog'), list):
+ mycfg = {KEYNAME_CONFIGS: cfg.get('rsyslog')}
if KEYNAME_LEGACY_FILENAME in cfg:
mycfg[KEYNAME_FILENAME] = cfg[KEYNAME_LEGACY_FILENAME]
if KEYNAME_LEGACY_DIR in cfg:
- mycfg[KEYNAME_DIR] = cfg[KEYNAME_DIR]
+ mycfg[KEYNAME_DIR] = cfg[KEYNAME_LEGACY_DIR]
fillup = (
- (KEYNAME_DIR, DEF_DIR, six.text_type),
- (KEYNAME_FILENAME, DEF_FILENAME, six.text_type)
- (KEYNAME_RELOAD, DEF_RELOAD, (six.text_type, list)))
+ (KEYNAME_CONFIGS, [], list),
+ (KEYNAME_DIR, DEF_DIR, six.string_types),
+ (KEYNAME_FILENAME, DEF_FILENAME, six.string_types),
+ (KEYNAME_RELOAD, DEF_RELOAD, six.string_types + (list,)))
for key, default, vtypes in fillup:
if key not in mycfg or not isinstance(mycfg[key], vtypes):
@@ -156,7 +157,8 @@ def apply_rsyslog_changes(configs, def_fname, cfg_dir):
filename = os.path.join(cfg_dir, filename)
# Truncate filename first time you see it
- omode = "ab" if filename not in files:
+ omode = "ab"
+ if filename not in files:
omode = "wb"
files.append(filename)
@@ -170,17 +172,6 @@ def apply_rsyslog_changes(configs, def_fname, cfg_dir):
def handle(name, cfg, cloud, log, _args):
- # rsyslog:
- # configs:
- # - "*.* @@192.158.1.1"
- # - content: "*.* @@192.0.2.1:10514"
- # - filename: 01-examplecom.conf
- # content: |
- # *.* @@syslogd.example.com
- # config_dir: DEF_DIR
- # config_filename: DEF_FILENAME
- # service_reload: "auto"
-
if 'rsyslog' not in cfg:
log.debug(("Skipping module named %s,"
" no 'rsyslog' key in configuration"), name)