Merge "Log output and exception when traceroute fails"
This commit is contained in:
commit
94cc113ade
@ -18,6 +18,7 @@
|
|||||||
import os
|
import os
|
||||||
import shlex
|
import shlex
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
|
||||||
command_map = {
|
command_map = {
|
||||||
@ -68,19 +69,25 @@ def main():
|
|||||||
ret['traceroute_v6'] = run_command(
|
ret['traceroute_v6'] = run_command(
|
||||||
'traceroute6 -n {host}'.format(host=traceroute_host))
|
'traceroute6 -n {host}'.format(host=traceroute_host))
|
||||||
passed = True
|
passed = True
|
||||||
except (subprocess.CalledProcessError, OSError):
|
except (subprocess.CalledProcessError, OSError) as e:
|
||||||
|
ret['traceroute_v6_exception'] = traceback.format_exc(e)
|
||||||
|
ret['traceroute_v6_output'] = e.output
|
||||||
|
ret['traceroute_v6_return'] = e.returncode
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
ret['traceroute_v4'] = run_command(
|
ret['traceroute_v4'] = run_command(
|
||||||
'traceroute -n {host}'.format(host=traceroute_host))
|
'traceroute -n {host}'.format(host=traceroute_host))
|
||||||
passed = True
|
passed = True
|
||||||
except (subprocess.CalledProcessError, OSError):
|
except (subprocess.CalledProcessError, OSError) as e:
|
||||||
|
ret['traceroute_v4_exception'] = traceback.format_exc(e)
|
||||||
|
ret['traceroute_v4_output'] = e.output
|
||||||
|
ret['traceroute_v4_return'] = e.returncode
|
||||||
pass
|
pass
|
||||||
if not passed:
|
if not passed:
|
||||||
module.fail_json(
|
module.fail_json(
|
||||||
msg="No viable v4 or v6 route found to {traceroute_host}."
|
msg="No viable v4 or v6 route found to {traceroute_host}."
|
||||||
" The build node is assumed to be invalid.".format(
|
" The build node is assumed to be invalid.".format(
|
||||||
traceroute_host=traceroute_host))
|
traceroute_host=traceroute_host), **ret)
|
||||||
|
|
||||||
for key, command in command_map.items():
|
for key, command in command_map.items():
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user