Vultr: Ensure self.returns is the source of truth (#44115)

As of today, self.returns it not the source of truth. If the return
value from querying the resource contains more values than the one
listed in self.returns, those value will be returned even though not
explicitly specified in self.returns.

This commit ensures that only the values listed on self.returns are
actually returned. The other values not listed are supressed.
pull/44122/head
Yanis Guenane 6 years ago committed by René Moser
parent d6d7b6123e
commit 763d66ff9c

@ -237,6 +237,10 @@ class Vultr:
self.module.fail_json(msg="Could not find %s with %s: %s" % (resource, key, value))
def normalize_result(self, resource):
fields_to_remove = set(resource.keys()) - set(self.returns.keys())
for field in fields_to_remove:
resource.pop(field)
for search_key, config in self.returns.items():
if search_key in resource:
if 'convert_to' in config:

@ -142,7 +142,7 @@ class AnsibleVultrStartupScript(Vultr):
self.returns = {
'SCRIPTID': dict(key='id'),
'type': dict(key='script_type'),
'name': dict(key='name'),
'name': dict(),
'script': dict(),
'date_created': dict(),
'date_modified': dict(),

Loading…
Cancel
Save