summaryrefslogtreecommitdiff
path: root/lib/ansible/utils
diff options
context:
space:
mode:
authorBrian Coca <brian.coca+git@gmail.com>2017-08-18 13:44:10 -0400
committerBrian Coca <brian.coca+git@gmail.com>2017-08-18 18:13:51 -0400
commit49c54024e6636580f59269d4c6a4072c0894f1b7 (patch)
tree41d27131987c69403bea5c4cc4c5f1cee4e59e34 /lib/ansible/utils
parentde16ce42ef49c7067d23fcbe41a34f0558a2cd9b (diff)
downloadansible-49c54024e6636580f59269d4c6a4072c0894f1b7.tar.gz
added helper function to convert objects to dicts
Diffstat (limited to 'lib/ansible/utils')
-rw-r--r--lib/ansible/utils/helpers.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/ansible/utils/helpers.py b/lib/ansible/utils/helpers.py
index 0ecb160813..ecb5d0c96a 100644
--- a/lib/ansible/utils/helpers.py
+++ b/lib/ansible/utils/helpers.py
@@ -32,3 +32,9 @@ def pct_to_int(value, num_items, min_value=1):
return int((value_pct / 100.0) * num_items) or min_value
else:
return int(value)
+
+def object_to_dict(obj):
+ """
+ Converts an object into a dict making the properties into keys
+ """
+ return dict((key, getattr(obj, key)) for key in dir(obj) if not key.startswith('__'))