def get_route_to(self, destination="<STR_LIT>", protocol="<STR_LIT>"):
longer_pref = "<STR_LIT>"  <EOL>vrf = "<STR_LIT>"<EOL>ip_version = None<EOL>try:<EOL><INDENT>ip_version = IPNetwork(destination).version<EOL><DEDENT>except AddrFormatError:<EOL><INDENT>return "<STR_LIT>"<EOL><DEDENT>if ip_version == <NUM_LIT:4>:  <EOL><INDENT>routes = {}<EOL>if vrf:<EOL><INDENT>send_cmd = "<STR_LIT>".format(<EOL>vrf=vrf, destination=destination, longer=longer_pref<EOL>).rstrip()<EOL><DEDENT>else:<EOL><INDENT>send_cmd = "<STR_LIT>".format(<EOL>destination=destination, longer=longer_pref<EOL>).rstrip()<EOL><DEDENT>out_sh_ip_rou = self._send_command(send_cmd)<EOL>for vrfsec in out_sh_ip_rou.split("<STR_LIT>")[<NUM_LIT:1>:]:<EOL><INDENT>if "<STR_LIT>" in vrfsec:<EOL><INDENT>continue<EOL><DEDENT>vrffound = False<EOL>preffound = False<EOL>nh_list = []<EOL>cur_prefix = "<STR_LIT>"<EOL>for line in vrfsec.split("<STR_LIT:\n>"):<EOL><INDENT>if not vrffound:<EOL><INDENT>vrfstr = RE_RT_VRF_NAME.match(line)<EOL>if vrfstr:<EOL><INDENT>curvrf = vrfstr.group(<NUM_LIT:1>)<EOL>vrffound = True<EOL><DEDENT><DEDENT>else:<EOL><INDENT>prefstr = RE_RT_IPV4_ROUTE_PREF.match(line)<EOL>if prefstr:<EOL><INDENT>if preffound:  <EOL><INDENT>if cur_prefix not in routes:<EOL><INDENT>routes[cur_prefix] = []<EOL><DEDENT>for nh in nh_list:<EOL><INDENT>routes[cur_prefix].append(nh)<EOL><DEDENT>nh_list = []<EOL><DEDENT>else:<EOL><INDENT>preffound = True<EOL><DEDENT>cur_prefix = prefstr.group(<NUM_LIT:1>)<EOL>continue<EOL><DEDENT>viastr = RE_IP_ROUTE_VIA_REGEX.match(line)<EOL>if viastr:<EOL><INDENT>nh_used = viastr.group("<STR_LIT>") == "<STR_LIT:*>"<EOL>nh_ip = viastr.group("<STR_LIT>") or "<STR_LIT>"<EOL>nh_int = viastr.group("<STR_LIT:int>")<EOL>nh_metric = viastr.group("<STR_LIT>")<EOL>nh_age = bgp_time_conversion(viastr.group("<STR_LIT>"))<EOL>nh_source = viastr.group("<STR_LIT:source>")<EOL>if protocol and protocol != nh_source:<EOL><INDENT>continue<EOL><DEDENT>if nh_int:<EOL><INDENT>nh_int_canon = helpers.canonical_interface_name(nh_int)<EOL><DEDENT>else:<EOL><INDENT>nh_int_canon = "<STR_LIT>"<EOL><DEDENT>route_entry = {<EOL>"<STR_LIT>": nh_source,<EOL>"<STR_LIT>": nh_int_canon,<EOL>"<STR_LIT>": nh_age,<EOL>"<STR_LIT>": nh_used,<EOL>"<STR_LIT>": curvrf,<EOL>"<STR_LIT>": nh_used,<EOL>"<STR_LIT>": nh_ip,<EOL>"<STR_LIT>": nh_used,<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": int(nh_metric),<EOL>}<EOL>if nh_source == "<STR_LIT>":<EOL><INDENT>route_entry[<EOL>"<STR_LIT>"<EOL>] = self._get_bgp_route_attr(cur_prefix, curvrf, nh_ip)<EOL><DEDENT>else:<EOL><INDENT>route_entry["<STR_LIT>"] = {}<EOL><DEDENT>nh_list.append(route_entry)<EOL><DEDENT><DEDENT><DEDENT>if preffound:<EOL><INDENT>if cur_prefix not in routes:<EOL><INDENT>routes[cur_prefix] = []<EOL><DEDENT>for nh in nh_list:<EOL><INDENT>routes[cur_prefix].append(nh)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>return routes<EOL>
Only IPv4 supported, vrf aware, longer_prefixes parameter ready