summaryrefslogtreecommitdiff
path: root/cloudinit/util.py
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2010-06-17 11:29:34 -0400
committerScott Moser <smoser@ubuntu.com>2010-06-17 11:29:34 -0400
commitafb5f8da541f97a9fc5c023cac7dc55b5b81dd06 (patch)
treec2ee0bb23d94f69e5650b728938ab5f7e1e13f56 /cloudinit/util.py
parenta9f600c4fb7426661c478f043791795ddbabb69a (diff)
downloadvyos-cloud-init-afb5f8da541f97a9fc5c023cac7dc55b5b81dd06.tar.gz
vyos-cloud-init-afb5f8da541f97a9fc5c023cac7dc55b5b81dd06.zip
add initial logging support
This logging infrastructure in cloudinit: - uses python logging - allows user supplied config of logging.config.fileConfig format to be supplied in /etc/cloud/cloud.cfg or in cloud_config by user data. - by default, tries to use syslog, if that is not available, writes directly to /var/log/cloud-init.log (syslog will not be available yet when cloud-init runs) - when using syslog, the doc/21-cloudinit.conf file provides a rsyslogd file to be placed in /etc/rsyslog.d/ that will file [CLOUDINIT] messages to /var/log/cloud-init.log
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r--cloudinit/util.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py
index 1c838fa8..79115355 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -20,12 +20,23 @@ import os
import errno
import subprocess
from Cheetah.Template import Template
+import cloudinit
def read_conf(fname):
- stream = file(fname)
- conf = yaml.load(stream)
- stream.close()
- return conf
+ try:
+ stream = open(fname,"r")
+ conf = yaml.load(stream)
+ stream.close()
+ return conf
+ except IOError as e:
+ if e.errno == errno.ENOENT:
+ return { }
+ raise
+
+def get_base_cfg(cfgfile=cloudinit.system_config):
+ syscfg = read_conf(cfgfile)
+ builtin = yaml.load(cloudinit.cfg_builtin)
+ return(mergedict(syscfg,builtin))
def get_cfg_option_bool(yobj, key, default=False):
if not yobj.has_key(key): return default