summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRene Moser <mail@renemoser.net>2016-09-02 08:28:00 +0200
committerRene Moser <mail@renemoser.net>2016-09-16 08:52:13 +0200
commit2a57a4a74e7583bd2312566f59668fba6ebc0e80 (patch)
tree947863771e5be55e0998ff8eb10805e51ca741ae
parent67177105e3c1bc0b0d44c58155c56ae0e4d6fdb2 (diff)
downloadansible-fix/cloudstack_has_changed.tar.gz
cloudstack: fix has_changed dict values comparsionfix/cloudstack_has_changed
In some rare situations, the CloudStack API returns string for numbers when we expected int. With this fix, we ensure we compare the types expected.
-rw-r--r--lib/ansible/module_utils/cloudstack.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/ansible/module_utils/cloudstack.py b/lib/ansible/module_utils/cloudstack.py
index 2332286200..6ac2e08797 100644
--- a/lib/ansible/module_utils/cloudstack.py
+++ b/lib/ansible/module_utils/cloudstack.py
@@ -158,7 +158,17 @@ class AnsibleCloudStack(object):
continue
if key in current_dict:
- if isinstance(current_dict[key], (int, long, float, complex)):
+ if isinstance(value, (int, float, long, complex)):
+ # ensure we compare the same type
+ if isinstance(value, int):
+ current_dict[key] = int(current_dict[key])
+ elif isinstance(value, float):
+ current_dict[key] = float(current_dict[key])
+ elif isinstance(value, long):
+ current_dict[key] = long(current_dict[key])
+ elif isinstance(value, complex):
+ current_dict[key] = complex(current_dict[key])
+
if value != current_dict[key]:
return True
else: