From fed20b825f2edd0f6c5c147a32a494194dfa8164 Mon Sep 17 00:00:00 2001 From: nwgarner Date: Thu, 15 Feb 2018 09:07:29 -0800 Subject: [PATCH] Update ios_ping.py to allow for count > 70. (#36142) * Update ios_ping.py to allow for count > 70. Find 'Success...' output rather than relying on list index. Index -1 won't pass unit test. --- lib/ansible/modules/network/ios/ios_ping.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/network/ios/ios_ping.py b/lib/ansible/modules/network/ios/ios_ping.py index 743045bf2d..65c80a5608 100644 --- a/lib/ansible/modules/network/ios/ios_ping.py +++ b/lib/ansible/modules/network/ios/ios_ping.py @@ -143,7 +143,12 @@ def main(): ping_results = run_commands(module, commands=results["commands"]) ping_results_list = ping_results[0].split("\n") - success, rx, tx, rtt = parse_ping(ping_results_list[3]) + stats = "" + for line in ping_results_list: + if line.startswith('Success'): + stats = line + + success, rx, tx, rtt = parse_ping(stats) loss = abs(100 - int(success)) results["packet_loss"] = str(loss) + "%" results["packets_rx"] = int(rx)