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:
parent
c9a3801a25
commit
efd122c2f0
1 changed files with 7 additions and 0 deletions
|
@ -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'] = []
|
||||
|
|
Loading…
Reference in a new issue