From d3999e9ce22ab42ab1464e8f12de897000ad2ac8 Mon Sep 17 00:00:00 2001 From: Ying Xie Date: Mon, 19 Mar 2018 12:33:27 -0700 Subject: [PATCH 1/3] [snmp_fact] Add debug information to each failure --- ansible/library/snmp_facts.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ansible/library/snmp_facts.py b/ansible/library/snmp_facts.py index ceb1c460362..5eda1f50205 100644 --- a/ansible/library/snmp_facts.py +++ b/ansible/library/snmp_facts.py @@ -302,7 +302,7 @@ def main(): ) if errorIndication: - module.fail_json(msg=str(errorIndication)) + module.fail_json(msg=str(errorIndication) + ' querying system infomation.') for oid, val in varBinds: current_oid = oid.prettyPrint() @@ -337,7 +337,7 @@ def main(): ) if errorIndication: - module.fail_json(msg=str(errorIndication)) + module.fail_json(msg=str(errorIndication) + ' querying interface details') interface_indexes = [] @@ -401,7 +401,7 @@ def main(): ) if errorIndication: - module.fail_json(msg=str(errorIndication)) + module.fail_json(msg=str(errorIndication) + ' querying interface counters') for varBinds in varTable: for oid, val in varBinds: @@ -458,7 +458,7 @@ def main(): ) if errorIndication: - module.fail_json(msg=str(errorIndication)) + module.fail_json(msg=str(errorIndication) + ' querying CPU busy indeces') for oid, val in varBinds: current_oid = oid.prettyPrint() @@ -476,7 +476,7 @@ def main(): ) if errorIndication: - module.fail_json(msg=str(errorIndication)) + module.fail_json(msg=str(errorIndication) + ' querying PFC counters') for varBinds in varTable: for oid, val in varBinds: @@ -504,7 +504,7 @@ def main(): ) if errorIndication: - module.fail_json(msg=str(errorIndication)) + module.fail_json(msg=str(errorIndication) + ' querying QoS stats') for varBinds in varTable: for oid, val in varBinds: @@ -524,7 +524,7 @@ def main(): ) if errorIndication: - module.fail_json(msg=str(errorIndication)) + module.fail_json(msg=str(errorIndication) + ' querying FRU') for varBinds in varTable: for oid, val in varBinds: From f82db34d7d3794aefdb031fc9fc0f9b849f2121d Mon Sep 17 00:00:00 2001 From: Ying Xie Date: Mon, 19 Mar 2018 12:34:40 -0700 Subject: [PATCH 2/3] [snmp_facts] separate system description query - snmp cpu test consistently fails on s6000 with default timeout. - System description takes more than 1 seconds in snmp cpu test (when all cores are pined at 100% busy). - Give this query its own timeout (5 seconds). --- ansible/library/snmp_facts.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/ansible/library/snmp_facts.py b/ansible/library/snmp_facts.py index 5eda1f50205..61793cdeacf 100644 --- a/ansible/library/snmp_facts.py +++ b/ansible/library/snmp_facts.py @@ -290,10 +290,26 @@ def main(): results = Tree() + # Getting system description could take more than 1 second on some Dell platform + # (e.g. S6000), increse timeout to tolerate the delay. errorIndication, errorStatus, errorIndex, varBinds = cmdGen.getCmd( snmp_auth, - cmdgen.UdpTransportTarget((m_args['host'], 161)), + cmdgen.UdpTransportTarget((m_args['host'], 161), timeout=5.0), cmdgen.MibVariable(p.sysDescr,), + ) + + if errorIndication: + module.fail_json(msg=str(errorIndication) + ' querying system description.') + + for oid, val in varBinds: + current_oid = oid.prettyPrint() + current_val = val.prettyPrint() + if current_oid == v.sysDescr: + results['ansible_sysdescr'] = decode_hex(current_val) + + errorIndication, errorStatus, errorIndex, varBinds = cmdGen.getCmd( + snmp_auth, + cmdgen.UdpTransportTarget((m_args['host'], 161)), cmdgen.MibVariable(p.sysObjectId,), cmdgen.MibVariable(p.sysUpTime,), cmdgen.MibVariable(p.sysContact,), @@ -307,9 +323,7 @@ def main(): for oid, val in varBinds: current_oid = oid.prettyPrint() current_val = val.prettyPrint() - if current_oid == v.sysDescr: - results['ansible_sysdescr'] = decode_hex(current_val) - elif current_oid == v.sysObjectId: + if current_oid == v.sysObjectId: results['ansible_sysobjectid'] = current_val elif current_oid == v.sysUpTime: results['ansible_sysuptime'] = current_val From 0fb152ecc6e7bf60810556c7acc3ad499794c567 Mon Sep 17 00:00:00 2001 From: Ying Xie Date: Tue, 20 Mar 2018 15:03:27 -0700 Subject: [PATCH 3/3] Update snmp_facts.py --- ansible/library/snmp_facts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ansible/library/snmp_facts.py b/ansible/library/snmp_facts.py index 61793cdeacf..85ce82a9dd0 100644 --- a/ansible/library/snmp_facts.py +++ b/ansible/library/snmp_facts.py @@ -291,7 +291,7 @@ def main(): results = Tree() # Getting system description could take more than 1 second on some Dell platform - # (e.g. S6000), increse timeout to tolerate the delay. + # (e.g. S6000) when cpu utilization is high, increse timeout to tolerate the delay. errorIndication, errorStatus, errorIndex, varBinds = cmdGen.getCmd( snmp_auth, cmdgen.UdpTransportTarget((m_args['host'], 161), timeout=5.0),