mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
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.
This commit is contained in:
parent
ff52e01a11
commit
3f6f4617dc
1 changed files with 11 additions and 1 deletions
|
@ -158,7 +158,17 @@ class AnsibleCloudStack(object):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if key in current_dict:
|
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]:
|
if value != current_dict[key]:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue