diff options
| author | Peter Sprygada <psprygada@ansible.com> | 2017-01-25 22:48:15 -0500 |
|---|---|---|
| committer | Peter Sprygada <psprygada@ansible.com> | 2017-01-25 22:49:32 -0500 |
| commit | 82dbe9853c72e157c1dc6517eca90b09ce3e14d2 (patch) | |
| tree | 22f3a4d2d26e2659a48d4e525fda4bf09ac753fc | |
| parent | 31d6b6ef67636537037f542e4d089e411843bd44 (diff) | |
| download | ansible-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.py | 8 |
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): |
