diff options
author | Dan Wendlandt <dan@nicira.com> | 2011-09-07 14:27:06 -0700 |
---|---|---|
committer | Dan Wendlandt <dan@nicira.com> | 2011-09-07 14:27:06 -0700 |
commit | 0f5eb3f888de5f6eb23f968fa5a2270d2a350bcc (patch) | |
tree | 0ee3f8a60147da042b0b14db350a320228876fa6 /nova/utils.py | |
parent | e5e3b306985a3b1fdd8a971f48b76eaf8f923f21 (diff) | |
parent | 3e0698e3b57c9f73a359340f51c2797d8adc669a (diff) | |
download | nova-0f5eb3f888de5f6eb23f968fa5a2270d2a350bcc.tar.gz nova-0f5eb3f888de5f6eb23f968fa5a2270d2a350bcc.tar.xz nova-0f5eb3f888de5f6eb23f968fa5a2270d2a350bcc.zip |
merge trunk
Diffstat (limited to 'nova/utils.py')
-rw-r--r-- | nova/utils.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/nova/utils.py b/nova/utils.py index 21e6221b2..81157a4cd 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -901,3 +901,12 @@ def monkey_patch(): func = import_class("%s.%s" % (module, key)) setattr(sys.modules[module], key,\ decorator("%s.%s" % (module, key), func)) + + +def convert_to_list_dict(lst, label): + """Convert a value or list into a list of dicts""" + if not lst: + return None + if not isinstance(lst, list): + lst = [lst] + return [{label: x} for x in lst] |