summaryrefslogtreecommitdiff
path: root/cloudinit/CloudConfig/__init__.py
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2010-06-29 22:16:55 -0400
committerScott Moser <smoser@ubuntu.com>2010-06-29 22:16:55 -0400
commit1dc7a0b93c9980c8bee163a6ca9fea215d7a48ac (patch)
tree708df22dc1f560389b09c53b00eaa7f149fb2e61 /cloudinit/CloudConfig/__init__.py
parent08925d194df374971d2b06d32534cf9ada6b2035 (diff)
downloadvyos-cloud-init-1dc7a0b93c9980c8bee163a6ca9fea215d7a48ac.tar.gz
vyos-cloud-init-1dc7a0b93c9980c8bee163a6ca9fea215d7a48ac.zip
on bad cloud-config syntax (failure to yaml.load) continue on
If user gives bad cloud-config syntax, its not very useful to die, as that is most likely to leave the system unreachable. This instead logs the error and continues as if it no cloud-config was given.
Diffstat (limited to 'cloudinit/CloudConfig/__init__.py')
-rw-r--r--cloudinit/CloudConfig/__init__.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/cloudinit/CloudConfig/__init__.py b/cloudinit/CloudConfig/__init__.py
index c0d8928c..874f8d0a 100644
--- a/cloudinit/CloudConfig/__init__.py
+++ b/cloudinit/CloudConfig/__init__.py
@@ -35,9 +35,12 @@ class CloudConfig():
self.cloud.get_data_source()
def get_config_obj(self,cfgfile):
- f=file(cfgfile)
- cfg=yaml.load(f.read())
- f.close()
+ try:
+ cfg = util.read_conf(cfgfile)
+ except:
+ cloudinit.log.critical("Failed loading of cloud config '%s'. Continuing with empty config %s\n" % cfgfile)
+ cloudinit.log.debug(traceback.format_exc() + "\n")
+ cfg = None
if cfg is None: cfg = { }
return(util.mergedict(cfg,self.cloud.cfg))