summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Sprygada <psprygada@ansible.com>2017-01-25 22:48:15 -0500
committerPeter Sprygada <psprygada@ansible.com>2017-01-25 22:49:32 -0500
commit82dbe9853c72e157c1dc6517eca90b09ce3e14d2 (patch)
tree22f3a4d2d26e2659a48d4e525fda4bf09ac753fc
parent31d6b6ef67636537037f542e4d089e411843bd44 (diff)
downloadansible-82dbe9853c72e157c1dc6517eca90b09ce3e14d2.tar.gz
adds common function to_list to network_common
used to coerce a value into a list
-rw-r--r--lib/ansible/module_utils/network_common.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/ansible/module_utils/network_common.py b/lib/ansible/module_utils/network_common.py
index d7523cf7a1..31a5d69f4a 100644
--- a/lib/ansible/module_utils/network_common.py
+++ b/lib/ansible/module_utils/network_common.py
@@ -27,6 +27,14 @@
#
from ansible.module_utils.six import iteritems
+def to_list(val):
+ if isinstance(val, (list, tuple, set)):
+ return list(val)
+ elif val is not None:
+ return [val]
+ else:
+ return list()
+
class ComplexDict:
def __init__(self, attrs):