diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-07-02 10:56:22 -0700 |
---|---|---|
committer | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-07-02 10:56:22 -0700 |
commit | 879946c26f005f5ae5c2bbdd537beb295d7f4773 (patch) | |
tree | d9036cd7fe1eee3cb5ce4510f4374a6bb7c95057 /cloudinit | |
parent | 8037b4723ad641701750f9b4c9b7d7216bf50838 (diff) | |
download | vyos-cloud-init-879946c26f005f5ae5c2bbdd537beb295d7f4773.tar.gz vyos-cloud-init-879946c26f005f5ae5c2bbdd537beb295d7f4773.zip |
1. Move the welcome message template string to a constant at the top of the module
2. Fix the usage of multi_log to log to only one of the places (for now)
3. Update comment about multi-log and why write_file isn't used in this case
Diffstat (limited to 'cloudinit')
-rw-r--r-- | cloudinit/config/cc_final_message.py | 3 | ||||
-rw-r--r-- | cloudinit/config/cc_keys_to_console.py | 3 | ||||
-rw-r--r-- | cloudinit/util.py | 7 |
3 files changed, 9 insertions, 4 deletions
diff --git a/cloudinit/config/cc_final_message.py b/cloudinit/config/cc_final_message.py index 711e7b5b..b1caca47 100644 --- a/cloudinit/config/cc_final_message.py +++ b/cloudinit/config/cc_final_message.py @@ -55,7 +55,8 @@ def handle(_name, cfg, cloud, log, args): 'timestamp': ts, 'version': cver, } - util.multi_log("%s\n" % (templater.render_string(msg_in, subs))) + util.multi_log("%s\n" % (templater.render_string(msg_in, subs)), + console=False, stderr=True) except Exception: util.logexc(log, "Failed to render final message template") diff --git a/cloudinit/config/cc_keys_to_console.py b/cloudinit/config/cc_keys_to_console.py index da7d5219..ed7af690 100644 --- a/cloudinit/config/cc_keys_to_console.py +++ b/cloudinit/config/cc_keys_to_console.py @@ -46,7 +46,8 @@ def handle(name, cfg, _cloud, log, _args): cmd.append(','.join(fp_blacklist)) cmd.append(','.join(key_blacklist)) (stdout, _stderr) = util.subp(cmd) - util.multi_log("%s\n" % (stdout.strip()), stderr=False) + util.multi_log("%s\n" % (stdout.strip()), + stderr=False, console=True) except: log.warn("Writing keys to the system console failed!") raise diff --git a/cloudinit/util.py b/cloudinit/util.py index 6b23a0ee..4c29432b 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -275,15 +275,18 @@ def find_modules(root_dir): return entries -def multi_log(text, console=True, stderr=True, log=None): +def multi_log(text, console=True, stderr=True, + log=None, log_level=logging.DEBUG): if stderr: sys.stderr.write(text) if console: + # Don't use the write_file since + # this might be 'sensitive' info (not debug worthy?) with open('/dev/console', 'wb') as wfh: wfh.write(text) wfh.flush() if log: - log.debug(text) + log.log(log_level, text) def is_ipv4(instr): |