mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-19 15:21:27 +00:00
cloudstack: add returns_to_int return handling into utils
It is not uncommon that the API returns string for int values e.g. ports in listFirewallRules or listPortForwardings,
This commit is contained in:
@@ -75,6 +75,8 @@ class AnsibleCloudStack(object):
|
||||
|
||||
# Init returns dict for use in subclasses
|
||||
self.returns = {}
|
||||
# these values will be casted to int
|
||||
self.returns_to_int = {}
|
||||
|
||||
self.module = module
|
||||
self._connect()
|
||||
@@ -408,6 +410,11 @@ class AnsibleCloudStack(object):
|
||||
if search_key in resource:
|
||||
self.result[return_key] = resource[search_key]
|
||||
|
||||
# Bad bad API does not always return int when it should.
|
||||
for search_key, return_key in self.returns_to_int.iteritems():
|
||||
if search_key in resource:
|
||||
self.result[return_key] = int(resource[search_key])
|
||||
|
||||
# Special handling for tags
|
||||
if 'tags' in resource:
|
||||
self.result['tags'] = []
|
||||
|
||||
Reference in New Issue
Block a user