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:
Rene Moser 2015-09-22 14:44:08 +02:00
parent c9a3801a25
commit efd122c2f0

View file

@ -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'] = []