summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2012-07-12 15:43:35 -0400
committerScott Moser <smoser@ubuntu.com>2012-07-12 15:43:35 -0400
commit265f2c74bb7202c2641b387b5a09c92bbe6563c8 (patch)
treec1805a6de271b95e3e76bb7f709aacba1f15c58c /cloudinit
parent5e296811619c7e814f61c8671cd596fe4203a38a (diff)
downloadvyos-cloud-init-265f2c74bb7202c2641b387b5a09c92bbe6563c8.tar.gz
vyos-cloud-init-265f2c74bb7202c2641b387b5a09c92bbe6563c8.zip
load_yaml: if conversion fails, but string is empty, return default
the problem sovled here is that most callers of yaml_load do not pass 'None' as a allowed type. I didn't want to change all the callers. If the yaml.safe_load ended up being None we were raising a TypeError and that was getting logged (meaning output to console). Even though the this was not really bad. So, if the type is not in the list, *and* it is not empty, then log exception. If it in the list and empty, just debug. empty input was occurring when cloud-config was empty (no user-data)
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/util.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py
index eb0b088a..23b67d48 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -609,7 +609,10 @@ def load_yaml(blob, default=None, allowed=(dict,)):
(allowed, obj_name(converted)))
loaded = converted
except (yaml.YAMLError, TypeError, ValueError):
- logexc(LOG, "Failed loading yaml blob")
+ if len(blob) == 0:
+ LOG.debug("load_yaml given empty string, returning default")
+ else:
+ logexc(LOG, "Failed loading yaml blob")
return loaded