mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
snmp_facts - added timeout and retries params to module (#2065)
* added timeout and retries params to module * added changelog fragment * Update plugins/modules/net_tools/snmp_facts.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/net_tools/snmp_facts.py Co-authored-by: Felix Fontein <felix@fontein.de> * removed default for retries per suggestion in PR * Update plugins/modules/net_tools/snmp_facts.py Co-authored-by: Felix Fontein <felix@fontein.de> Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
68fc48cd1f
commit
c147d2fb98
2 changed files with 17 additions and 2 deletions
2
changelogs/fragments/2065-snmp-facts-timeout.yml
Normal file
2
changelogs/fragments/2065-snmp-facts-timeout.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
minor_changes:
|
||||||
|
- snmp_facts - added parameters ``timeout`` and ``retries`` to module (https://github.com/ansible-collections/community.general/issues/980).
|
|
@ -67,6 +67,16 @@ options:
|
||||||
- Encryption key.
|
- Encryption key.
|
||||||
- Required if I(level) is C(authPriv).
|
- Required if I(level) is C(authPriv).
|
||||||
type: str
|
type: str
|
||||||
|
timeout:
|
||||||
|
description:
|
||||||
|
- Response timeout in seconds.
|
||||||
|
type: int
|
||||||
|
version_added: 2.3.0
|
||||||
|
retries:
|
||||||
|
description:
|
||||||
|
- Maximum number of request retries, 0 retries means just a single request.
|
||||||
|
type: int
|
||||||
|
version_added: 2.3.0
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = r'''
|
EXAMPLES = r'''
|
||||||
|
@ -271,6 +281,8 @@ def main():
|
||||||
privacy=dict(type='str', choices=['aes', 'des']),
|
privacy=dict(type='str', choices=['aes', 'des']),
|
||||||
authkey=dict(type='str', no_log=True),
|
authkey=dict(type='str', no_log=True),
|
||||||
privkey=dict(type='str', no_log=True),
|
privkey=dict(type='str', no_log=True),
|
||||||
|
timeout=dict(type='int'),
|
||||||
|
retries=dict(type='int'),
|
||||||
),
|
),
|
||||||
required_together=(
|
required_together=(
|
||||||
['username', 'level', 'integrity', 'authkey'],
|
['username', 'level', 'integrity', 'authkey'],
|
||||||
|
@ -285,6 +297,7 @@ def main():
|
||||||
module.fail_json(msg=missing_required_lib('pysnmp'), exception=PYSNMP_IMP_ERR)
|
module.fail_json(msg=missing_required_lib('pysnmp'), exception=PYSNMP_IMP_ERR)
|
||||||
|
|
||||||
cmdGen = cmdgen.CommandGenerator()
|
cmdGen = cmdgen.CommandGenerator()
|
||||||
|
transport_opts = dict((k, m_args[k]) for k in ('timeout', 'retries') if m_args[k] is not None)
|
||||||
|
|
||||||
# Verify that we receive a community when using snmp v2
|
# Verify that we receive a community when using snmp v2
|
||||||
if m_args['version'] in ("v2", "v2c"):
|
if m_args['version'] in ("v2", "v2c"):
|
||||||
|
@ -333,7 +346,7 @@ def main():
|
||||||
|
|
||||||
errorIndication, errorStatus, errorIndex, varBinds = cmdGen.getCmd(
|
errorIndication, errorStatus, errorIndex, varBinds = cmdGen.getCmd(
|
||||||
snmp_auth,
|
snmp_auth,
|
||||||
cmdgen.UdpTransportTarget((m_args['host'], 161)),
|
cmdgen.UdpTransportTarget((m_args['host'], 161), **transport_opts),
|
||||||
cmdgen.MibVariable(p.sysDescr,),
|
cmdgen.MibVariable(p.sysDescr,),
|
||||||
cmdgen.MibVariable(p.sysObjectId,),
|
cmdgen.MibVariable(p.sysObjectId,),
|
||||||
cmdgen.MibVariable(p.sysUpTime,),
|
cmdgen.MibVariable(p.sysUpTime,),
|
||||||
|
@ -364,7 +377,7 @@ def main():
|
||||||
|
|
||||||
errorIndication, errorStatus, errorIndex, varTable = cmdGen.nextCmd(
|
errorIndication, errorStatus, errorIndex, varTable = cmdGen.nextCmd(
|
||||||
snmp_auth,
|
snmp_auth,
|
||||||
cmdgen.UdpTransportTarget((m_args['host'], 161)),
|
cmdgen.UdpTransportTarget((m_args['host'], 161), **transport_opts),
|
||||||
cmdgen.MibVariable(p.ifIndex,),
|
cmdgen.MibVariable(p.ifIndex,),
|
||||||
cmdgen.MibVariable(p.ifDescr,),
|
cmdgen.MibVariable(p.ifDescr,),
|
||||||
cmdgen.MibVariable(p.ifMtu,),
|
cmdgen.MibVariable(p.ifMtu,),
|
||||||
|
|
Loading…
Reference in a new issue