summaryrefslogtreecommitdiffstats
path: root/nova/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'nova/utils.py')
-rw-r--r--nova/utils.py9
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]