module_utils/vultr.py: Ensure comparison is accurate (#43298)

In query_resource_by_key(), there is an equal comparison that is made to
know if the object we are looking for is present. Due to type difference
this comparison doesn't always retrieve true, even when it should.

This is due to the fact that the value in r_data dict are of type
unicode, while the other can be of type int, float,... .

```
>>> a = u'1'
>>> type(a)
<type 'unicode'>
>>> b = 1
>>> type(b)
<type 'int'>
>>> a == b
False
>>> str(a) == str(b)
True
```

Hence the values, for comparison purposes, are casted into strings.
pull/41222/merge
Yanis Guenane 6 years ago committed by ansibot
parent 051320a5f5
commit ffcdc53536

@ -217,7 +217,7 @@ class Vultr:
return {} return {}
for r_id, r_data in r_list.items(): for r_id, r_data in r_list.items():
if r_data[key] == value: if str(r_data[key]) == str(value):
self.api_cache.update({ self.api_cache.update({
resource: r_data resource: r_data
}) })

Loading…
Cancel
Save