summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené Moser <mail@renemoser.net>2016-09-19 14:02:29 +0200
committerGitHub <noreply@github.com>2016-09-19 14:02:29 +0200
commit3f6f4617dc2dcf4f6ffcff0bc9d2a2756a225969 (patch)
tree59dca15a560b323e3b9753a7db35a92e41cf6b95
parentff52e01a11eb431525fb842346615d0981eb23d8 (diff)
downloadansible-3f6f4617dc2dcf4f6ffcff0bc9d2a2756a225969.tar.gz
cloudstack: fix has_changed dict values comparsion (#17632)
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: