be verbose explicitly if run from cmdline.

Let the command line (or module args) that set outfile explicitly
override a config'd value of 'verbose'.

Ie, if /etc/cloud/cloud.cfg.d/my.cfg had:
 debug:
  verbose: False

but the user ran:
  cloud-init single --frequency=always --name=debug output.txt

Then they probably wanted to have the debug in output.txt even
though verbose was configured to False.
This commit is contained in:
Scott Moser 2013-12-12 11:50:55 -05:00
parent fe069d3a72
commit c3fb65b931

View File

@ -33,15 +33,17 @@ def _make_header(text):
def handle(name, cfg, cloud, log, args):
verbose = util.get_cfg_by_path(cfg, ('debug', 'verbose'), default=True)
if args:
# if args are provided (from cmdline) then explicitly set verbose
out_file = args[0]
verbose = True
else:
out_file = util.get_cfg_by_path(cfg, ('debug', 'output'))
if not verbose:
log.debug(("Skipping module named %s,"
" verbose printing disabled"), name)
return
out_file = None
if args:
out_file = args[0]
else:
out_file = util.get_cfg_by_path(cfg, ('debug', 'output'))
# Clean out some keys that we just don't care about showing...
dump_cfg = copy.deepcopy(cfg)
for k in ['log_cfgs']: