Added timeout setting for api. (#109)

* Added timeout setting for api.

* Added changelog fragment

* Added "version_added" to api doc

* Added "," for better diff

* Fixed case and punctuation in changelog

Co-authored-by: Felix Fontein <felix@fontein.de>

* Fixed url in changelog fragment

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
TobsA 2022-09-07 21:10:11 +02:00 committed by GitHub
parent 47bbf95fa3
commit 776b599ffe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 2 deletions

View file

@ -44,11 +44,12 @@ def api_argument_spec():
validate_certs=dict(type='bool', default=True),
validate_cert_hostname=dict(type='bool', default=False),
ca_path=dict(type='path'),
encoding=dict(type='str', default='ASCII')
encoding=dict(type='str', default='ASCII'),
timeout=dict(type='int', default=10),
)
def _ros_api_connect(module, username, password, host, port, use_tls, validate_certs, validate_cert_hostname, ca_path, encoding):
def _ros_api_connect(module, username, password, host, port, use_tls, validate_certs, validate_cert_hostname, ca_path, encoding, timeout):
'''Connect to RouterOS API.'''
if not port:
if use_tls:
@ -62,6 +63,7 @@ def _ros_api_connect(module, username, password, host, port, use_tls, validate_c
host=host,
port=port,
encoding=encoding,
timeout=timeout,
)
if use_tls:
ctx = ssl.create_default_context(cafile=ca_path)
@ -103,4 +105,5 @@ def create_api(module):
module.params['validate_cert_hostname'],
module.params['ca_path'],
module.params['encoding'],
module.params['timeout'],
)