def traceroute(<EOL>self,<EOL>destination,<EOL>source=C.TRACEROUTE_SOURCE,<EOL>ttl=C.TRACEROUTE_TTL,<EOL>timeout=C.TRACEROUTE_TIMEOUT,<EOL>vrf=C.TRACEROUTE_VRF,<EOL>):
traceroute_result = {}<EOL>source_str = "<STR_LIT>"<EOL>maxttl_str = "<STR_LIT>"<EOL>wait_str = "<STR_LIT>"<EOL>vrf_str = "<STR_LIT>"<EOL>if source:<EOL><INDENT>source_str = "<STR_LIT>".format(source=source)<EOL><DEDENT>if ttl:<EOL><INDENT>maxttl_str = "<STR_LIT>".format(ttl=ttl)<EOL><DEDENT>if timeout:<EOL><INDENT>wait_str = "<STR_LIT>".format(timeout=timeout)<EOL><DEDENT>if vrf:<EOL><INDENT>vrf_str = "<STR_LIT>".format(vrf=vrf)<EOL><DEDENT>traceroute_command = "<STR_LIT>".format(<EOL>destination=destination,<EOL>source=source_str,<EOL>maxttl=maxttl_str,<EOL>wait=wait_str,<EOL>vrf=vrf_str,<EOL>)<EOL>traceroute_rpc = E("<STR_LIT>", traceroute_command)<EOL>rpc_reply = self.device._conn.rpc(traceroute_rpc)._NCElement__doc<EOL>traceroute_results = rpc_reply.find("<STR_LIT>")<EOL>traceroute_failure = napalm.base.helpers.find_txt(<EOL>traceroute_results, "<STR_LIT>", "<STR_LIT>"<EOL>)<EOL>error_message = napalm.base.helpers.find_txt(<EOL>traceroute_results, "<STR_LIT>", "<STR_LIT>"<EOL>)<EOL>if traceroute_failure and error_message:<EOL><INDENT>return {"<STR_LIT:error>": "<STR_LIT>".format(traceroute_failure, error_message)}<EOL><DEDENT>traceroute_result["<STR_LIT:success>"] = {}<EOL>for hop in traceroute_results.findall("<STR_LIT>"):<EOL><INDENT>ttl_value = napalm.base.helpers.convert(<EOL>int, napalm.base.helpers.find_txt(hop, "<STR_LIT>"), <NUM_LIT:1><EOL>)<EOL>if ttl_value not in traceroute_result["<STR_LIT:success>"]:<EOL><INDENT>traceroute_result["<STR_LIT:success>"][ttl_value] = {"<STR_LIT>": {}}<EOL><DEDENT>for probe in hop.findall("<STR_LIT>"):<EOL><INDENT>probe_index = napalm.base.helpers.convert(<EOL>int, napalm.base.helpers.find_txt(probe, "<STR_LIT>"), <NUM_LIT:0><EOL>)<EOL>ip_address = napalm.base.helpers.convert(<EOL>napalm.base.helpers.ip,<EOL>napalm.base.helpers.find_txt(probe, "<STR_LIT>"),<EOL>"<STR_LIT:*>",<EOL>)<EOL>host_name = py23_compat.text_type(<EOL>napalm.base.helpers.find_txt(probe, "<STR_LIT>", "<STR_LIT:*>")<EOL>)<EOL>rtt = (<EOL>napalm.base.helpers.convert(<EOL>float, napalm.base.helpers.find_txt(probe, "<STR_LIT>"), <NUM_LIT:0><EOL>)<EOL>* <NUM_LIT><EOL>)  <EOL>traceroute_result["<STR_LIT:success>"][ttl_value]["<STR_LIT>"][probe_index] = {<EOL>"<STR_LIT>": ip_address,<EOL>"<STR_LIT>": host_name,<EOL>"<STR_LIT>": rtt,<EOL>}<EOL><DEDENT><DEDENT>return traceroute_result<EOL>
Execute traceroute and return results.