From 1dc7a0b93c9980c8bee163a6ca9fea215d7a48ac Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Tue, 29 Jun 2010 22:16:55 -0400 Subject: 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. --- cloudinit/CloudConfig/__init__.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'cloudinit') 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)) -- cgit v1.2.3