fix to alwasy use param in case subpec is used

pull/25225/merge
Brian Coca 8 years ago
parent 3ae69302a2
commit 05caa3654c

@ -1723,7 +1723,8 @@ class AnsibleModule(object):
if spec is None: if spec is None:
spec = self.argument_spec spec = self.argument_spec
if param is None: if param is None:
param= self.params param = self.params
for (k, v) in spec.items(): for (k, v) in spec.items():
wanted = v.get('type', None) wanted = v.get('type', None)
if k not in param: if k not in param:
@ -1732,7 +1733,7 @@ class AnsibleModule(object):
# Mostly we want to default to str. # Mostly we want to default to str.
# For values set to None explicitly, return None instead as # For values set to None explicitly, return None instead as
# that allows a user to unset a parameter # that allows a user to unset a parameter
if self.params[k] is None: if param[k] is None:
continue continue
wanted = 'str' wanted = 'str'
@ -1745,7 +1746,7 @@ class AnsibleModule(object):
except KeyError: except KeyError:
self.fail_json(msg="implementation error: unknown type %s requested for %s" % (wanted, k)) self.fail_json(msg="implementation error: unknown type %s requested for %s" % (wanted, k))
try: try:
self.params[k] = type_checker(value) param[k] = type_checker(value)
except (TypeError, ValueError): except (TypeError, ValueError):
e = get_exception() e = get_exception()
self.fail_json(msg="argument %s is of type %s and we were unable to convert to %s: %s" % (k, type(value), wanted, e)) self.fail_json(msg="argument %s is of type %s and we were unable to convert to %s: %s" % (k, type(value), wanted, e))

Loading…
Cancel
Save