def _get_bgp_route_attr(self, destination, vrf, next_hop, ip_version=<NUM_LIT:4>):
CMD_SHIBNV = '<STR_LIT>'<EOL>search_re_dict = {<EOL>"<STR_LIT>": {<EOL>"<STR_LIT>": r"<STR_LIT>",<EOL>"<STR_LIT>": <NUM_LIT:1>,<EOL>"<STR_LIT:default>": "<STR_LIT>",<EOL>},<EOL>"<STR_LIT>": {<EOL>"<STR_LIT>": r"<STR_LIT>" + IP_ADDR_REGEX + r"<STR_LIT:)>",<EOL>"<STR_LIT>": <NUM_LIT:1>,<EOL>"<STR_LIT:default>": "<STR_LIT>",<EOL>},<EOL>"<STR_LIT>": {<EOL>"<STR_LIT>": r"<STR_LIT>" + IP_ADDR_REGEX + r"<STR_LIT:)>",<EOL>"<STR_LIT>": <NUM_LIT:1>,<EOL>"<STR_LIT:default>": "<STR_LIT>",<EOL>},<EOL>"<STR_LIT>": {<EOL>"<STR_LIT>": r"<STR_LIT>",<EOL>"<STR_LIT>": <NUM_LIT:1>,<EOL>"<STR_LIT:default>": "<STR_LIT>",<EOL>},<EOL>"<STR_LIT>": {"<STR_LIT>": r"<STR_LIT>", "<STR_LIT>": <NUM_LIT:1>, "<STR_LIT:default>": "<STR_LIT>"},<EOL>"<STR_LIT>": {"<STR_LIT>": r"<STR_LIT>", "<STR_LIT>": <NUM_LIT:1>, "<STR_LIT:default>": "<STR_LIT>"},<EOL>"<STR_LIT>": {<EOL>"<STR_LIT>": r"<STR_LIT>",<EOL>"<STR_LIT>": <NUM_LIT:1>,<EOL>"<STR_LIT:default>": "<STR_LIT>",<EOL>},<EOL>}<EOL>bgp_attr = {}<EOL>outbgp = self._send_command('<STR_LIT>')<EOL>matchbgpattr = RE_BGP_PROTO_TAG.match(outbgp)<EOL>if not matchbgpattr:<EOL><INDENT>return bgp_attr<EOL><DEDENT>bgpas = matchbgpattr.group(<NUM_LIT:1>)<EOL>if ip_version == <NUM_LIT:4>:<EOL><INDENT>bgpcmd = "<STR_LIT>".format(<EOL>vrf=vrf, destination=destination<EOL>)<EOL>outbgp = self._send_command(bgpcmd)<EOL>outbgpsec = outbgp.split("<STR_LIT>")<EOL>if len(outbgpsec) == <NUM_LIT:1>:<EOL><INDENT>return bgp_attr<EOL><DEDENT>for bgppath in outbgpsec[<NUM_LIT:1>:]:<EOL><INDENT>if "<STR_LIT>" not in bgppath:<EOL><INDENT>continue<EOL><DEDENT>for key in search_re_dict:<EOL><INDENT>matchre = re.search(search_re_dict[key]["<STR_LIT>"], bgppath)<EOL>if matchre:<EOL><INDENT>groupnr = int(search_re_dict[key]["<STR_LIT>"])<EOL>search_re_dict[key]["<STR_LIT:result>"] = matchre.group(groupnr)<EOL><DEDENT>else:<EOL><INDENT>search_re_dict[key]["<STR_LIT:result>"] = search_re_dict[key]["<STR_LIT:default>"]<EOL><DEDENT><DEDENT>bgpnh = search_re_dict["<STR_LIT>"]["<STR_LIT:result>"]<EOL>if (<EOL>not (search_re_dict["<STR_LIT>"]["<STR_LIT:result>"] in ["<STR_LIT>", "<STR_LIT>"])<EOL>) and (bgpnh != next_hop):<EOL><INDENT>continue<EOL><DEDENT>bgpcmd = CMD_SHIBNV.format(vrf=vrf, neigh=bgpnh)<EOL>outbgpnei = self._send_command(bgpcmd)<EOL>matchbgpras = RE_BGP_REMOTE_AS.search(outbgpnei)<EOL>if matchbgpras:<EOL><INDENT>bgpras = matchbgpras.group(<NUM_LIT:1>)<EOL><DEDENT>else:<EOL><INDENT>bgpie = search_re_dict["<STR_LIT>"]["<STR_LIT:result>"]<EOL>if bgpie == "<STR_LIT>":<EOL><INDENT>bgpras = bgpie.split("<STR_LIT:U+0020>")[<NUM_LIT:0>].replace("<STR_LIT:(>", "<STR_LIT>")<EOL><DEDENT>elif bgpie == "<STR_LIT>":<EOL><INDENT>bgpras = bgpas<EOL><DEDENT>else:  <EOL><INDENT>bgpras = "<STR_LIT>"<EOL><DEDENT><DEDENT>bothcomm = []<EOL>extcomm = []<EOL>stdcomm = search_re_dict["<STR_LIT>"]["<STR_LIT:result>"].split()<EOL>commsplit = bgppath.split("<STR_LIT>")<EOL>if len(commsplit) == <NUM_LIT:2>:<EOL><INDENT>for line in commsplit[<NUM_LIT:1>].split("<STR_LIT:\n>")[<NUM_LIT:1>:]:<EOL><INDENT>matchcommun = RE_BGP_COMMUN.match(line)<EOL>if matchcommun:<EOL><INDENT>extcomm.append(matchcommun.group(<NUM_LIT:1>))<EOL><DEDENT>else:<EOL><INDENT>break<EOL><DEDENT><DEDENT><DEDENT>bothcomm = stdcomm + extcomm<EOL>bgp_attr = {<EOL>"<STR_LIT>": search_re_dict["<STR_LIT>"]["<STR_LIT:result>"].strip(),<EOL>"<STR_LIT>": search_re_dict["<STR_LIT>"]["<STR_LIT:result>"],<EOL>"<STR_LIT>": int(search_re_dict["<STR_LIT>"]["<STR_LIT:result>"]),<EOL>"<STR_LIT>": bothcomm,<EOL>"<STR_LIT>": helpers.as_number(bgpas),<EOL>}<EOL>if bgpras:<EOL><INDENT>bgp_attr["<STR_LIT>"] = helpers.as_number(bgpras)<EOL><DEDENT>else:<EOL><INDENT>bgp_attr["<STR_LIT>"] = <NUM_LIT:0>  <EOL><DEDENT><DEDENT><DEDENT>return bgp_attr<EOL>
BGP protocol attributes for get_route_tp
Only IPv4 supported