From 3f6f4617dc2dcf4f6ffcff0bc9d2a2756a225969 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Moser?= Date: Mon, 19 Sep 2016 14:02:29 +0200 Subject: [PATCH] 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. --- lib/ansible/module_utils/cloudstack.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/ansible/module_utils/cloudstack.py b/lib/ansible/module_utils/cloudstack.py index 2332286200a..6ac2e08797b 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: