diff options
author | Scott Moser <smoser@ubuntu.com> | 2010-06-18 14:13:24 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2010-06-18 14:13:24 -0400 |
commit | 789fdb0cb6514859630b533cb53289f30c4426fe (patch) | |
tree | c688f4a3620e8e38656fbf5560164a21b784a29d /cloudinit/util.py | |
parent | 6b0bb7b68c86ce8d0297cb1b2d2ee8eaa5427369 (diff) | |
download | vyos-cloud-init-789fdb0cb6514859630b533cb53289f30c4426fe.tar.gz vyos-cloud-init-789fdb0cb6514859630b533cb53289f30c4426fe.zip |
add util.get_cfg_option_list_or_str
This is useful for getting a config option that is either string or a
list as a list
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r-- | cloudinit/util.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py index 0cee8e17..7f5c1db4 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -53,6 +53,11 @@ def get_cfg_option_str(yobj, key, default=None): if not yobj.has_key(key): return default return yobj[key] +def get_cfg_option_list_or_str(yobj, key, default=None): + if not yobj.has_key(key): return default + if isinstance(yobj[key],list): return yobj[key] + return([yobj[key]]) + # merge values from src into cand. # if src has a key, cand will not override def mergedict(src,cand): |