def get_bgp_config(self, group="<STR_LIT>", neighbor="<STR_LIT>"):
bgp_config = {}<EOL>def build_prefix_limit(af_table, limit, prefix_percent, prefix_timeout):<EOL><INDENT>prefix_limit = {}<EOL>inet = False<EOL>inet6 = False<EOL>preifx_type = "<STR_LIT>"<EOL>if isinstance(af_table, list):<EOL><INDENT>af_table = str(af_table)<EOL><DEDENT>if "<STR_LIT>" in af_table.lower():<EOL><INDENT>inet = True<EOL><DEDENT>if "<STR_LIT>" in af_table.lower():<EOL><INDENT>inet6 = True<EOL>preifx_type = "<STR_LIT>"<EOL><DEDENT>if len(af_table.split()) == <NUM_LIT:2>:<EOL><INDENT>safi = "<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>safi = af_table.split()[-<NUM_LIT:1>]<EOL><DEDENT>if inet or inet6:<EOL><INDENT>prefix_limit = {<EOL>preifx_type: {<EOL>safi: {<EOL>"<STR_LIT>": limit,<EOL>"<STR_LIT>": {<EOL>"<STR_LIT>": prefix_percent,<EOL>"<STR_LIT>": prefix_timeout,<EOL>},<EOL>}<EOL>}<EOL>}<EOL><DEDENT>return prefix_limit<EOL><DEDENT>cfg = self.get_config(retrieve="<STR_LIT>")<EOL>cfg = cfg["<STR_LIT>"].splitlines()<EOL>bgp_config_text = napalm.base.helpers.cisco_conf_parse_objects(<EOL>"<STR_LIT>", cfg<EOL>)<EOL>bgp_asn = napalm.base.helpers.regex_find_txt(<EOL>r"<STR_LIT>", bgp_config_text, default=<NUM_LIT:0><EOL>)<EOL>all_neighbors = set()<EOL>all_groups = set()<EOL>bgp_group_neighbors = {}<EOL>all_groups.add("<STR_LIT:_>")<EOL>for line in bgp_config_text:<EOL><INDENT>if "<STR_LIT>" in line:<EOL><INDENT>if re.search(IP_ADDR_REGEX, line) is not None:<EOL><INDENT>all_neighbors.add(re.search(IP_ADDR_REGEX, line).group())<EOL><DEDENT>elif re.search(IPV6_ADDR_REGEX_2, line) is not None:<EOL><INDENT>all_neighbors.add(re.search(IPV6_ADDR_REGEX_2, line).group())<EOL><DEDENT>else:<EOL><INDENT>bgp_group = re.search(r"<STR_LIT>", line).group()<EOL>bgp_group = bgp_group.split()[<NUM_LIT:1>]<EOL>all_groups.add(bgp_group)<EOL><DEDENT><DEDENT><DEDENT>for bgp_neighbor in all_neighbors:<EOL><INDENT>if neighbor:<EOL><INDENT>if bgp_neighbor != neighbor:<EOL><INDENT>continue<EOL><DEDENT><DEDENT>afi_list = napalm.base.helpers.cisco_conf_parse_parents(<EOL>r"<STR_LIT>", bgp_neighbor, bgp_config_text<EOL>)<EOL>afi = afi_list[<NUM_LIT:0>]<EOL>if "<STR_LIT>" in str(afi_list):<EOL><INDENT>continue<EOL><DEDENT>else:<EOL><INDENT>neighbor_config = napalm.base.helpers.cisco_conf_parse_objects(<EOL>bgp_neighbor, bgp_config_text<EOL>)<EOL><DEDENT>group_name = napalm.base.helpers.regex_find_txt(<EOL>"<STR_LIT>", neighbor_config, default="<STR_LIT:_>"<EOL>)<EOL>description = napalm.base.helpers.regex_find_txt(<EOL>r"<STR_LIT>", neighbor_config<EOL>)<EOL>peer_as = napalm.base.helpers.regex_find_txt(<EOL>r"<STR_LIT>", neighbor_config, default=<NUM_LIT:0><EOL>)<EOL>prefix_limit = napalm.base.helpers.regex_find_txt(<EOL>r"<STR_LIT>", neighbor_config, default=<NUM_LIT:0><EOL>)<EOL>prefix_percent = napalm.base.helpers.regex_find_txt(<EOL>r"<STR_LIT>", neighbor_config, default=<NUM_LIT:0><EOL>)<EOL>prefix_timeout = napalm.base.helpers.regex_find_txt(<EOL>r"<STR_LIT>", neighbor_config, default=<NUM_LIT:0><EOL>)<EOL>export_policy = napalm.base.helpers.regex_find_txt(<EOL>r"<STR_LIT>", neighbor_config<EOL>)<EOL>import_policy = napalm.base.helpers.regex_find_txt(<EOL>r"<STR_LIT>", neighbor_config<EOL>)<EOL>local_address = napalm.base.helpers.regex_find_txt(<EOL>r"<STR_LIT>", neighbor_config<EOL>)<EOL>local_as = napalm.base.helpers.regex_find_txt(<EOL>r"<STR_LIT>", neighbor_config, default=<NUM_LIT:0><EOL>)<EOL>password = napalm.base.helpers.regex_find_txt(<EOL>r"<STR_LIT>", neighbor_config<EOL>)<EOL>nhs = bool(<EOL>napalm.base.helpers.regex_find_txt(r"<STR_LIT>", neighbor_config)<EOL>)<EOL>route_reflector_client = bool(<EOL>napalm.base.helpers.regex_find_txt(<EOL>r"<STR_LIT>", neighbor_config<EOL>)<EOL>)<EOL>if group_name not in bgp_group_neighbors.keys():<EOL><INDENT>bgp_group_neighbors[group_name] = {}<EOL><DEDENT>bgp_group_neighbors[group_name][bgp_neighbor] = {<EOL>"<STR_LIT:description>": description,<EOL>"<STR_LIT>": peer_as,<EOL>"<STR_LIT>": build_prefix_limit(<EOL>afi, prefix_limit, prefix_percent, prefix_timeout<EOL>),<EOL>"<STR_LIT>": export_policy,<EOL>"<STR_LIT>": import_policy,<EOL>"<STR_LIT>": local_address,<EOL>"<STR_LIT>": local_as,<EOL>"<STR_LIT>": password,<EOL>"<STR_LIT>": nhs,<EOL>"<STR_LIT>": route_reflector_client,<EOL>}<EOL><DEDENT>for group_name in bgp_group_neighbors.keys():<EOL><INDENT>if group:<EOL><INDENT>if group_name != group:<EOL><INDENT>continue<EOL><DEDENT><DEDENT>if group_name == "<STR_LIT:_>":<EOL><INDENT>bgp_config["<STR_LIT:_>"] = {<EOL>"<STR_LIT>": [],<EOL>"<STR_LIT:description>": "<STR_LIT>",<EOL>"<STR_LIT>": <NUM_LIT:0>,<EOL>"<STR_LIT:type>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": False,<EOL>"<STR_LIT>": <NUM_LIT:0>,<EOL>"<STR_LIT>": <NUM_LIT:0>,<EOL>"<STR_LIT>": False,<EOL>"<STR_LIT>": {},<EOL>"<STR_LIT>": bgp_group_neighbors.get("<STR_LIT:_>", {}),<EOL>}<EOL>continue<EOL><DEDENT>neighbor_config = napalm.base.helpers.cisco_conf_parse_objects(<EOL>group_name, bgp_config_text<EOL>)<EOL>multipath = False<EOL>afi_list = napalm.base.helpers.cisco_conf_parse_parents(<EOL>r"<STR_LIT>", group_name, neighbor_config<EOL>)<EOL>for afi in afi_list:<EOL><INDENT>afi_config = napalm.base.helpers.cisco_conf_parse_objects(<EOL>afi, bgp_config_text<EOL>)<EOL>multipath = bool(<EOL>napalm.base.helpers.regex_find_txt(r"<STR_LIT>", str(afi_config))<EOL>)<EOL>if multipath:<EOL><INDENT>break<EOL><DEDENT><DEDENT>description = napalm.base.helpers.regex_find_txt(<EOL>r"<STR_LIT>", neighbor_config<EOL>)<EOL>local_as = napalm.base.helpers.regex_find_txt(<EOL>r"<STR_LIT>", neighbor_config, default=<NUM_LIT:0><EOL>)<EOL>import_policy = napalm.base.helpers.regex_find_txt(<EOL>r"<STR_LIT>", neighbor_config<EOL>)<EOL>export_policy = napalm.base.helpers.regex_find_txt(<EOL>r"<STR_LIT>", neighbor_config<EOL>)<EOL>local_address = napalm.base.helpers.regex_find_txt(<EOL>r"<STR_LIT>", neighbor_config<EOL>)<EOL>multihop_ttl = napalm.base.helpers.regex_find_txt(<EOL>r"<STR_LIT>", neighbor_config, default=<NUM_LIT:0><EOL>)<EOL>peer_as = napalm.base.helpers.regex_find_txt(<EOL>r"<STR_LIT>", neighbor_config, default=<NUM_LIT:0><EOL>)<EOL>remove_private_as = bool(<EOL>napalm.base.helpers.regex_find_txt(<EOL>r"<STR_LIT>", neighbor_config<EOL>)<EOL>)<EOL>prefix_limit = napalm.base.helpers.regex_find_txt(<EOL>r"<STR_LIT>", neighbor_config, default=<NUM_LIT:0><EOL>)<EOL>prefix_percent = napalm.base.helpers.regex_find_txt(<EOL>r"<STR_LIT>", neighbor_config, default=<NUM_LIT:0><EOL>)<EOL>prefix_timeout = napalm.base.helpers.regex_find_txt(<EOL>r"<STR_LIT>", neighbor_config, default=<NUM_LIT:0><EOL>)<EOL>bgp_type = "<STR_LIT>"<EOL>if local_as:<EOL><INDENT>if local_as == peer_as:<EOL><INDENT>bgp_type = "<STR_LIT>"<EOL><DEDENT><DEDENT>elif bgp_asn == peer_as:<EOL><INDENT>bgp_type = "<STR_LIT>"<EOL><DEDENT>bgp_config[group_name] = {<EOL>"<STR_LIT>": [],  <EOL>"<STR_LIT:description>": description,<EOL>"<STR_LIT>": local_as,<EOL>"<STR_LIT:type>": bgp_type,<EOL>"<STR_LIT>": import_policy,<EOL>"<STR_LIT>": export_policy,<EOL>"<STR_LIT>": local_address,<EOL>"<STR_LIT>": multipath,<EOL>"<STR_LIT>": multihop_ttl,<EOL>"<STR_LIT>": peer_as,<EOL>"<STR_LIT>": remove_private_as,<EOL>"<STR_LIT>": build_prefix_limit(<EOL>afi, prefix_limit, prefix_percent, prefix_timeout<EOL>),<EOL>"<STR_LIT>": bgp_group_neighbors.get(group_name, {}),<EOL>}<EOL><DEDENT>return bgp_config<EOL>
Parse BGP config params into a dict
    :param group='':
    :param neighbor='':