Add socket timeout to uri module.

The uri module can be configured to abort after a specified timeout if
it cannot connect to the configured uri. This prevents a uri action from
hanging indefinitely when the remote endpoint cannot be reached because
it is unavailable, there is a firewall in place etc. The default behavior
is left unchanged: timeout=None

This change also introduces a new type for module_parameters: int
Code was added to perform conversion from string -> int type in
module_common.py.

The new type was required in order to play nice with httplib2 which
refuses to accept (and convert) anything other than a numeric type for
the timeout value.
This commit is contained in:
Grant Gavares 2013-03-02 17:27:09 -08:00
parent b130716b61
commit cd51c7f234
2 changed files with 16 additions and 3 deletions

View file

@ -597,6 +597,12 @@ class AnsibleModule(object):
self.params[k] = self.boolean(value)
else:
is_invalid = True
elif wanted == 'int':
if not isinstance(value, int):
if isinstance(value, basestring):
self.params[k] = int(value)
else:
is_invalid = True
else:
self.fail_json(msg="implementation error: unknown type %s requested for %s" % (wanted, k))