diff options
author | Scott Moser <smoser@ubuntu.com> | 2011-01-20 06:44:05 -0500 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2011-01-20 06:44:05 -0500 |
commit | 39f3129de68cf19df14e47371736a543057f83bb (patch) | |
tree | 2b39836fbdac2c8a13c54da455620c8cb699ff91 /cloudinit/__init__.py | |
parent | fe3ece415c5c6d815bd0a88f86a92627e9baae6a (diff) | |
download | vyos-cloud-init-39f3129de68cf19df14e47371736a543057f83bb.tar.gz vyos-cloud-init-39f3129de68cf19df14e47371736a543057f83bb.zip |
support configuration of what is the default log file
since user names and group names wont' be the same on all images,
allow configuration of what ownership to put on 'default_log_file'.
Diffstat (limited to 'cloudinit/__init__.py')
-rw-r--r-- | cloudinit/__init__.py | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/cloudinit/__init__.py b/cloudinit/__init__.py index 296af051..889455d2 100644 --- a/cloudinit/__init__.py +++ b/cloudinit/__init__.py @@ -24,13 +24,11 @@ system_config = '/etc/cloud/cloud.cfg' seeddir = varlibdir + "/seed" cfg_env_name = "CLOUD_CFG" -def_log_file = '/var/log/cloud-init.log' -def_log_user = "syslog" -def_log_group = "adm" - cfg_builtin = """ log_cfgs: [ ] cloud_type: auto +def_log_file: /var/log/cloud-init.log +syslog_fix_perms: syslog:adm """ logger_name = "cloudinit" @@ -47,6 +45,8 @@ pathmap = { None : "", } +parsed_cfgs = { } + import os from configobj import ConfigObj @@ -70,7 +70,7 @@ log = logging.getLogger(logger_name) log.addHandler(NullHandler()) def logging_set_from_cfg_file(cfg_file=system_config): - logging_set_from_cfg(util.get_base_cfg(cfg_file,cfg_builtin)) + logging_set_from_cfg(util.get_base_cfg(cfg_file,cfg_builtin,parsed_cfgs)) def logging_set_from_cfg(cfg, logfile=None): log_cfgs = [] @@ -135,7 +135,7 @@ class CloudInit: if self.cfg: return(self.cfg) - conf = util.get_base_cfg(self.sysconfig,cfg_builtin) + conf = util.get_base_cfg(self.sysconfig,cfg_builtin, parsed_cfgs) # support reading the old ConfigObj format file and merging # it into the yaml dictionary @@ -487,11 +487,16 @@ def initfs(): dlist.append("%s/%s" % (varlibdir, subd)) util.ensure_dirs(dlist) - fp = open(def_log_file,"ab") - fp.close() - util.chownbyname(def_log_file,def_log_user, def_log_group) - - + cfg = util.get_base_cfg(system_config,cfg_builtin,parsed_cfgs) + if 'def_log_file' in cfg: + fp = open(def_log_file,"ab") + fp.close() + if 'syslog_fix_perms' in cfg: + perms = cfg['syslog'] + (u,g) = perms.split(':',1) + if u == "-1" or u == "None": u = None + if g == "-1" or g == "None": g = None + util.chownbyname(def_log_file, u, g) def purge_cache(): try: |