BGP neighbor information.

        Currently no VRF support. Supports both IPv4 and IPv6.
541748
def get_bgp_neighbors(self):
        
        supported_afi = ["ipv4", "ipv6"]

        bgp_neighbor_data = dict()
        bgp_neighbor_data["global"] = {}

        # get summary output from device
        cmd_bgp_all_sum = "show bgp all summary"
        summary_output = self._send_command(cmd_bgp_all_sum).strip()

        if "Invalid input detected" in summary_output:
            raise CommandErrorException("BGP is not running on this device")

        # get neighbor output from device
        neighbor_output = ""
        for afi in supported_afi:
            cmd_bgp_neighbor = "show bgp %s unicast neighbors" % afi
            neighbor_output += self._send_command(cmd_bgp_neighbor).strip()
            # trailing newline required for parsing
            neighbor_output += "\n"

        # Regular expressions used for parsing BGP summary
        parse_summary = {
            "patterns": [
                # For address family: IPv4 Unicast
                {
                    "regexp": re.compile(r"^For address family: (?P<afi>\S+) "),
                    "record": False,
                },
                # Capture router_id and local_as values, e.g.:
                # BGP router identifier 10.0.1.1, local AS number 65000
                {
                    "regexp": re.compile(
                        r"^.* router identifier (?P<router_id>{}), "
                        r"local AS number (?P<local_as>{})".format(
                            IPV4_ADDR_REGEX, ASN_REGEX
                        )
                    ),
                    "record": False,
                },
                # Match neighbor summary row, capturing useful details and
                # discarding the 5 columns that we don't care about, e.g.:
                # Neighbor   V          AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
                # 10.0.0.2   4       65000 1336020 64337701 1011343614    0    0 8w0d         3143
                {
                    "regexp": re.compile(
                        r"^\*?(?P<remote_addr>({})|({}))"
                        r"\s+\d+\s+(?P<remote_as>{})(\s+\S+){{5}}\s+"
                        r"(?P<uptime>(never)|\d+\S+)"
                        r"\s+(?P<accepted_prefixes>\d+)".format(
                            IPV4_ADDR_REGEX, IPV6_ADDR_REGEX, ASN_REGEX
                        )
                    ),
                    "record": True,
                },
                # Same as above, but for peer that are not Established, e.g.:
                # Neighbor      V       AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
                # 192.168.0.2   4    65002       0       0        1    0    0 never    Active
                {
                    "regexp": re.compile(
                        r"^\*?(?P<remote_addr>({})|({}))"
                        r"\s+\d+\s+(?P<remote_as>{})(\s+\S+){{5}}\s+"
                        r"(?P<uptime>(never)|\d+\S+)\s+(?P<state>\D.*)".format(
                            IPV4_ADDR_REGEX, IPV6_ADDR_REGEX, ASN_REGEX
                        )
                    ),
                    "record": True,
                },
                # ipv6 peers often break accross rows because of the longer peer address,
                # match as above, but in separate expressions, e.g.:
                # Neighbor      V       AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
                # 2001:DB8::4
                #               4    65004 9900690  612449 155362939    0    0 26w6d       36391
                {
                    "regexp": re.compile(
                        r"^\*?(?P<remote_addr>({})|({}))".format(
                            IPV4_ADDR_REGEX, IPV6_ADDR_REGEX
                        )
                    ),
                    "record": False,
                },
                {
                    "regexp": re.compile(
                        r"^\s+\d+\s+(?P<remote_as>{})(\s+\S+){{5}}\s+"
                        r"(?P<uptime>(never)|\d+\S+)"
                        r"\s+(?P<accepted_prefixes>\d+)".format(ASN_REGEX)
                    ),
                    "record": True,
                },
                # Same as above, but for peers that are not Established, e.g.:
                # Neighbor      V       AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
                # 2001:DB8::3
                #               4    65003       0       0        1    0    0 never    Idle (Admin)
                {
                    "regexp": re.compile(
                        r"^\s+\d+\s+(?P<remote_as>{})(\s+\S+){{5}}\s+"
                        r"(?P<uptime>(never)|\d+\S+)\s+(?P<state>\D.*)".format(
                            ASN_REGEX
                        )
                    ),
                    "record": True,
                },
            ],
            "no_fill_fields": [
                "accepted_prefixes",
                "state",
                "uptime",
                "remote_as",
                "remote_addr",
            ],
        }

        parse_neighbors = {
            "patterns": [
                # Capture BGP neighbor is 10.0.0.2,  remote AS 65000, internal link
                {
                    "regexp": re.compile(
                        r"^BGP neighbor is (?P<remote_addr>({})|({})),"
                        r"\s+remote AS (?P<remote_as>{}).*".format(
                            IPV4_ADDR_REGEX, IPV6_ADDR_REGEX, ASN_REGEX
                        )
                    ),
                    "record": False,
                },
                # Capture description
                {
                    "regexp": re.compile(r"^\s+Description: (?P<description>.+)"),
                    "record": False,
                },
                # Capture remote_id, e.g.:
                # BGP version 4, remote router ID 10.0.1.2
                {
                    "regexp": re.compile(
                        r"^\s+BGP version \d+, remote router ID "
                        r"(?P<remote_id>{})".format(IPV4_ADDR_REGEX)
                    ),
                    "record": False,
                },
                # Capture state
                {
                    "regexp": re.compile(r"^\s+BGP state = (?P<state>\w+)"),
                    "record": False,
                },
                # Capture AFI and SAFI names, e.g.:
                # For address family: IPv4 Unicast
                {
                    "regexp": re.compile(r"^\s+For address family: (?P<afi>\S+) "),
                    "record": False,
                },
                # Capture current sent and accepted prefixes, e.g.:
                #     Prefixes Current:          637213       3142 (Consumes 377040 bytes)
                {
                    "regexp": re.compile(
                        r"^\s+Prefixes Current:\s+(?P<sent_prefixes>\d+)\s+"
                        r"(?P<accepted_prefixes>\d+).*"
                    ),
                    "record": False,
                },
                # Capture received_prefixes if soft-reconfig is enabled for the peer
                {
                    "regexp": re.compile(
                        r"^\s+Saved (soft-reconfig):.+(?P<received_prefixes>\d+).*"
                    ),
                    "record": True,
                },
                # Otherwise, use the following as an end of row marker
                {
                    "regexp": re.compile(r"^\s+Local Policy Denied Prefixes:.+"),
                    "record": True,
                },
            ],
            # fields that should not be "filled down" across table rows
            "no_fill_fields": [
                "received_prefixes",
                "accepted_prefixes",
                "sent_prefixes",
            ],
        }

        # Parse outputs into a list of dicts
        summary_data = []
        summary_data_entry = {}

        for line in summary_output.splitlines():
            # check for matches against each pattern
            for item in parse_summary["patterns"]:
                match = item["regexp"].match(line)
                if match:
                    # a match was found, so update the temp entry with the match's groupdict
                    summary_data_entry.update(match.groupdict())
                    if item["record"]:
                        # Record indicates the last piece of data has been obtained; move
                        # on to next entry
                        summary_data.append(copy.deepcopy(summary_data_entry))
                        # remove keys that are listed in no_fill_fields before the next pass
                        for field in parse_summary["no_fill_fields"]:
                            try:
                                del summary_data_entry[field]
                            except KeyError:
                                pass
                    break

        neighbor_data = []
        neighbor_data_entry = {}
        for line in neighbor_output.splitlines():
            # check for matches against each pattern
            for item in parse_neighbors["patterns"]:
                match = item["regexp"].match(line)
                if match:
                    # a match was found, so update the temp entry with the match's groupdict
                    neighbor_data_entry.update(match.groupdict())
                    if item["record"]:
                        # Record indicates the last piece of data has been obtained; move
                        # on to next entry
                        neighbor_data.append(copy.deepcopy(neighbor_data_entry))
                        # remove keys that are listed in no_fill_fields before the next pass
                        for field in parse_neighbors["no_fill_fields"]:
                            try:
                                del neighbor_data_entry[field]
                            except KeyError:
                                pass
                    break

        router_id = None

        for entry in summary_data:
            if not router_id:
                router_id = entry["router_id"]
            elif entry["router_id"] != router_id:
                raise ValueError

        # check the router_id looks like an ipv4 address
        router_id = napalm.base.helpers.ip(router_id, version=4)

        # add parsed data to output dict
        bgp_neighbor_data["global"]["router_id"] = router_id
        bgp_neighbor_data["global"]["peers"] = {}
        for entry in summary_data:
            remote_addr = napalm.base.helpers.ip(entry["remote_addr"])
            afi = entry["afi"].lower()
            # check that we're looking at a supported afi
            if afi not in supported_afi:
                continue
            # get neighbor_entry out of neighbor data
            neighbor_entry = None
            for neighbor in neighbor_data:
                if (
                    neighbor["afi"].lower() == afi
                    and napalm.base.helpers.ip(neighbor["remote_addr"]) == remote_addr
                ):
                    neighbor_entry = neighbor
                    break
            # check for proper session data for the afi
            if neighbor_entry is None:
                continue
            elif not isinstance(neighbor_entry, dict):
                raise ValueError(
                    msg="Couldn't find neighbor data for %s in afi %s"
                    % (remote_addr, afi)
                )

            # check for admin down state
            try:
                if "(Admin)" in entry["state"]:
                    is_enabled = False
                else:
                    is_enabled = True
            except KeyError:
                is_enabled = True

            # parse uptime value
            uptime = self.bgp_time_conversion(entry["uptime"])

            # BGP is up if state is Established
            is_up = "Established" in neighbor_entry["state"]

            # check whether session is up for address family and get prefix count
            try:
                accepted_prefixes = int(entry["accepted_prefixes"])
            except (ValueError, KeyError):
                accepted_prefixes = -1

            # Only parse neighbor detailed data if BGP session is-up
            if is_up:
                try:
                    # overide accepted_prefixes with neighbor data if possible (since that's newer)
                    accepted_prefixes = int(neighbor_entry["accepted_prefixes"])
                except (ValueError, KeyError):
                    pass

                # try to get received prefix count, otherwise set to accepted_prefixes
                received_prefixes = neighbor_entry.get(
                    "received_prefixes", accepted_prefixes
                )

                # try to get sent prefix count and convert to int, otherwise set to -1
                sent_prefixes = int(neighbor_entry.get("sent_prefixes", -1))
            else:
                received_prefixes = -1
                sent_prefixes = -1
                uptime = -1

            # get description
            try:
                description = py23_compat.text_type(neighbor_entry["description"])
            except KeyError:
                description = ""

            # check the remote router_id looks like an ipv4 address
            remote_id = napalm.base.helpers.ip(neighbor_entry["remote_id"], version=4)

            if remote_addr not in bgp_neighbor_data["global"]["peers"]:
                bgp_neighbor_data["global"]["peers"][remote_addr] = {
                    "local_as": napalm.base.helpers.as_number(entry["local_as"]),
                    "remote_as": napalm.base.helpers.as_number(entry["remote_as"]),
                    "remote_id": remote_id,
                    "is_up": is_up,
                    "is_enabled": is_enabled,
                    "description": description,
                    "uptime": uptime,
                    "address_family": {
                        afi: {
                            "received_prefixes": received_prefixes,
                            "accepted_prefixes": accepted_prefixes,
                            "sent_prefixes": sent_prefixes,
                        }
                    },
                }
            else:
                # found previous data for matching remote_addr, but for different afi
                existing = bgp_neighbor_data["global"]["peers"][remote_addr]
                assert afi not in existing["address_family"]
                # compare with existing values and croak if they don't match
                assert existing["local_as"] == napalm.base.helpers.as_number(
                    entry["local_as"]
                )
                assert existing["remote_as"] == napalm.base.helpers.as_number(
                    entry["remote_as"]
                )
                assert existing["remote_id"] == remote_id
                assert existing["is_enabled"] == is_enabled
                assert existing["description"] == description
                # merge other values in a sane manner
                existing["is_up"] = existing["is_up"] or is_up
                existing["uptime"] = max(existing["uptime"], uptime)
                existing["address_family"][afi] = {
                    "received_prefixes": received_prefixes,
                    "accepted_prefixes": accepted_prefixes,
                    "sent_prefixes": sent_prefixes,
                }
        return bgp_neighbor_data
679413
private synchronized int seekCountryV6(InetAddress addr) {
        byte[] v6vec = addr.getAddress();

        if (v6vec.length == 4) {
            // sometimes java returns an ipv4 address for IPv6 input
            // we have to work around that feature
            // It happens for ::ffff:24.24.24.24
            byte[] t = new byte[16];
            System.arraycopy(v6vec, 0, t, 12, 4);
            v6vec = t;
        }

        byte[] buf = new byte[2 * MAX_RECORD_LENGTH];
        int[] x = new int[2];
        int offset = 0;
        _check_mtime();
        for (int depth = 127; depth >= 0; depth--) {
            readNode(buf, x, offset);

            int bnum = 127 - depth;
            int idx = bnum >> 3;
            int bMask = 1 << (bnum & 7 ^ 7);
            if ((v6vec[idx] & bMask) > 0) {
                if (x[1] >= databaseSegments[0]) {
                    last_netmask = 128 - depth;
                    return x[1];
                }
                offset = x[1];
            } else {
                if (x[0] >= databaseSegments[0]) {
                    last_netmask = 128 - depth;
                    return x[0];
                }
                offset = x[0];
            }
        }

        throw new InvalidDatabaseException("Error seeking country while searching for "
                + addr.getHostAddress());
    }
316884
def traceroute6(target, dport=80, minttl=1, maxttl=30, sport=RandShort(), 
                l4 = None, timeout=2, verbose=None, **kargs):
    
    if verbose is None:
        verbose = conf.verb

    if l4 is None:
        a,b = sr(IPv6(dst=target, hlim=(minttl,maxttl))/TCP(seq=RandInt(),sport=sport, dport=dport),
                 timeout=timeout, filter="icmp6 or tcp", verbose=verbose, **kargs)
    else:
        a,b = sr(IPv6(dst=target, hlim=(minttl,maxttl))/l4,
                 timeout=timeout, verbose=verbose, **kargs)

    a = TracerouteResult6(a.res)

    if verbose:
        a.display()

    return a,b
315500
def set_neighbor_in_filter(neigh_ip_address, filters):
    """"""
    core = CORE_MANAGER.get_core_service()
    peer = core.peer_manager.get_by_addr(neigh_ip_address)
    peer.in_filters = filters
    return True
662375
def _get_real_instance_if_mismatch(vpc_info, ipaddr, instance, eni):
    
    # Careful! A route may be a black-hole route, which still has instance and
    # ENI information for an instance that doesn't exist anymore. If a host was
    # terminated and a new host got the same IP then this route won't be
    # updated and will keep pointing to a non-existing node. So we find the
    # instance by IP and check that the route really points to this instance.
    inst_id = instance.id if instance else ""
    eni_id  = eni.id if eni else ""
    if ipaddr:
        real_instance, real_eni = \
                        find_instance_and_eni_by_ip(vpc_info, ipaddr)
        if real_instance.id != inst_id  or real_eni.id != eni_id:
            return real_instance
    return None
783044
def first_ipv6(self) -> Optional[AddressInfo]:
        ''''''
        for info in self._address_infos:
            if info.family == socket.AF_INET6:
                return info
1047019
def send_community
      val = config_get('bgp_neighbor_af', 'send_community', @get_args)
      return default_send_community if val.nil? || val.empty?
      platform == :nexus ? send_community_nexus(val) : send_community_xr(val)
    end
153821
def add_vrf(self):
        

        v = VRF()
        if 'rt' in request.json:
            v.rt = validate_string(request.json, 'rt')
        if 'name' in request.json:
            v.name = validate_string(request.json, 'name')
        if 'description' in request.json:
            v.description = validate_string(request.json, 'description')
        if 'tags' in request.json:
            v.tags = request.json['tags']
        if 'avps' in request.json:
            v.avps = request.json['avps']

        try:
            v.save()
        except NipapError, e:
            return json.dumps({'error': 1, 'message': e.args, 'type': type(e).__name__})

        return json.dumps(v, cls=NipapJSONEncoder)
130189
def update_bgp_peer(self, bgp_peer_id, body=None):
        """"""
        return self.put(self.bgp_peer_path % bgp_peer_id, body=body)
533678
def get_host_ipv6addr_info(ipv6addr=None, mac=None,
                                        discovered_data=None,
                                        return_fields=None, **api_opts):
    '''
    
    '''
    infoblox = _get_infoblox(**api_opts)
    return infoblox.get_host_ipv6addr_object(ipv6addr, mac, discovered_data, return_fields)
391716
def _is_ipv4(self, ip):
        
        try:
            p = IPy.IP(ip)
        except ValueError:
            return False

        if p.version() == 4:
            return True
        return False
5167
def _supported_rule(protocol, ethertype):
        """"""
        if not protocol or protocol not in utils.SUPPORTED_SG_PROTOCOLS:
            return False

        if ethertype != n_const.IPv4:
            return False

        return True
237736
def ip4_address(self):
        
        if self._ip4_address is None and self.network is not None:
            self._ip4_address = self._get_ip_address(
                libvirt.VIR_IP_ADDR_TYPE_IPV4)

        return self._ip4_address
201326
def ip_v6_network_validator(v: Any) -> IPv6Network:
    
    if isinstance(v, IPv6Network):
        return v

    with change_exception(errors.IPv6NetworkError, ValueError):
        return IPv6Network(v)
1259152
def get_bgp_config(self, group="", neighbor=""):
        

        bgp_config = {}

        def build_prefix_limit(af_table, limit, prefix_percent, prefix_timeout):
            prefix_limit = {}
            inet = False
            inet6 = False
            preifx_type = "inet"
            if isinstance(af_table, list):
                af_table = str(af_table)
            if "ipv4" in af_table.lower():
                inet = True
            if "ipv6" in af_table.lower():
                inet6 = True
                preifx_type = "inet6"
            if len(af_table.split()) == 2:
                safi = "unicast"
            else:
                safi = af_table.split()[-1]
            if inet or inet6:
                prefix_limit = {
                    preifx_type: {
                        safi: {
                            "limit": limit,
                            "teardown": {
                                "threshold": prefix_percent,
                                "timeout": prefix_timeout,
                            },
                        }
                    }
                }
            return prefix_limit

        # Get BGP config using ciscoconfparse because some old devices dont support "| sec bgp"
        cfg = self.get_config(retrieve="running")
        cfg = cfg["running"].splitlines()
        bgp_config_text = napalm.base.helpers.cisco_conf_parse_objects(
            "router bgp", cfg
        )
        bgp_asn = napalm.base.helpers.regex_find_txt(
            r"router bgp (\d+)", bgp_config_text, default=0
        )
        # Get a list of all neighbors and groups in the config
        all_neighbors = set()
        all_groups = set()
        bgp_group_neighbors = {}
        all_groups.add("_")
        for line in bgp_config_text:
            if " neighbor " in line:
                if re.search(IP_ADDR_REGEX, line) is not None:
                    all_neighbors.add(re.search(IP_ADDR_REGEX, line).group())
                elif re.search(IPV6_ADDR_REGEX_2, line) is not None:
                    all_neighbors.add(re.search(IPV6_ADDR_REGEX_2, line).group())
                else:
                    bgp_group = re.search(r" neighbor [^\s]+", line).group()
                    bgp_group = bgp_group.split()[1]
                    all_groups.add(bgp_group)

        # Get the neighrbor level config for each neighbor
        for bgp_neighbor in all_neighbors:
            # If neighbor_filter is passed in, only continue for that neighbor
            if neighbor:
                if bgp_neighbor != neighbor:
                    continue
            afi_list = napalm.base.helpers.cisco_conf_parse_parents(
                r"\s+address-family.*", bgp_neighbor, bgp_config_text
            )
            afi = afi_list[0]
            # Skipping neighbors in VRFs for now
            if "vrf" in str(afi_list):
                continue
            else:
                neighbor_config = napalm.base.helpers.cisco_conf_parse_objects(
                    bgp_neighbor, bgp_config_text
                )
            # For group_name- use peer-group name, else VRF name, else "_" for no group
            group_name = napalm.base.helpers.regex_find_txt(
                " peer-group ([^']+)", neighbor_config, default="_"
            )
            # Start finding attributes for the neighbor config
            description = napalm.base.helpers.regex_find_txt(
                r" description ([^\']+)\'", neighbor_config
            )
            peer_as = napalm.base.helpers.regex_find_txt(
                r" remote-as (\d+)", neighbor_config, default=0
            )
            prefix_limit = napalm.base.helpers.regex_find_txt(
                r"maximum-prefix (\d+) \d+ \w+ \d+", neighbor_config, default=0
            )
            prefix_percent = napalm.base.helpers.regex_find_txt(
                r"maximum-prefix \d+ (\d+) \w+ \d+", neighbor_config, default=0
            )
            prefix_timeout = napalm.base.helpers.regex_find_txt(
                r"maximum-prefix \d+ \d+ \w+ (\d+)", neighbor_config, default=0
            )
            export_policy = napalm.base.helpers.regex_find_txt(
                r"route-map ([^\s]+) out", neighbor_config
            )
            import_policy = napalm.base.helpers.regex_find_txt(
                r"route-map ([^\s]+) in", neighbor_config
            )
            local_address = napalm.base.helpers.regex_find_txt(
                r" update-source (\w+)", neighbor_config
            )
            local_as = napalm.base.helpers.regex_find_txt(
                r"local-as (\d+)", neighbor_config, default=0
            )
            password = napalm.base.helpers.regex_find_txt(
                r"password (?:[0-9] )?([^\']+\')", neighbor_config
            )
            nhs = bool(
                napalm.base.helpers.regex_find_txt(r" next-hop-self", neighbor_config)
            )
            route_reflector_client = bool(
                napalm.base.helpers.regex_find_txt(
                    r"route-reflector-client", neighbor_config
                )
            )

            # Add the group name to bgp_group_neighbors if its not there already
            if group_name not in bgp_group_neighbors.keys():
                bgp_group_neighbors[group_name] = {}

            # Build the neighbor dict of attributes
            bgp_group_neighbors[group_name][bgp_neighbor] = {
                "description": description,
                "remote_as": peer_as,
                "prefix_limit": build_prefix_limit(
                    afi, prefix_limit, prefix_percent, prefix_timeout
                ),
                "export_policy": export_policy,
                "import_policy": import_policy,
                "local_address": local_address,
                "local_as": local_as,
                "authentication_key": password,
                "nhs": nhs,
                "route_reflector_client": route_reflector_client,
            }

        # Get the peer-group level config for each group
        for group_name in bgp_group_neighbors.keys():
            # If a group is passed in params, only continue on that group
            if group:
                if group_name != group:
                    continue
            # Default no group
            if group_name == "_":
                bgp_config["_"] = {
                    "apply_groups": [],
                    "description": "",
                    "local_as": 0,
                    "type": "",
                    "import_policy": "",
                    "export_policy": "",
                    "local_address": "",
                    "multipath": False,
                    "multihop_ttl": 0,
                    "remote_as": 0,
                    "remove_private_as": False,
                    "prefix_limit": {},
                    "neighbors": bgp_group_neighbors.get("_", {}),
                }
                continue
            neighbor_config = napalm.base.helpers.cisco_conf_parse_objects(
                group_name, bgp_config_text
            )
            multipath = False
            afi_list = napalm.base.helpers.cisco_conf_parse_parents(
                r"\s+address-family.*", group_name, neighbor_config
            )
            for afi in afi_list:
                afi_config = napalm.base.helpers.cisco_conf_parse_objects(
                    afi, bgp_config_text
                )
                multipath = bool(
                    napalm.base.helpers.regex_find_txt(r" multipath", str(afi_config))
                )
                if multipath:
                    break
            description = napalm.base.helpers.regex_find_txt(
                r" description ([^\']+)\'", neighbor_config
            )
            local_as = napalm.base.helpers.regex_find_txt(
                r"local-as (\d+)", neighbor_config, default=0
            )
            import_policy = napalm.base.helpers.regex_find_txt(
                r"route-map ([^\s]+) in", neighbor_config
            )
            export_policy = napalm.base.helpers.regex_find_txt(
                r"route-map ([^\s]+) out", neighbor_config
            )
            local_address = napalm.base.helpers.regex_find_txt(
                r" update-source (\w+)", neighbor_config
            )
            multihop_ttl = napalm.base.helpers.regex_find_txt(
                r"ebgp-multihop {\d+}", neighbor_config, default=0
            )
            peer_as = napalm.base.helpers.regex_find_txt(
                r" remote-as (\d+)", neighbor_config, default=0
            )
            remove_private_as = bool(
                napalm.base.helpers.regex_find_txt(
                    r"remove-private-as", neighbor_config
                )
            )
            prefix_limit = napalm.base.helpers.regex_find_txt(
                r"maximum-prefix (\d+) \d+ \w+ \d+", neighbor_config, default=0
            )
            prefix_percent = napalm.base.helpers.regex_find_txt(
                r"maximum-prefix \d+ (\d+) \w+ \d+", neighbor_config, default=0
            )
            prefix_timeout = napalm.base.helpers.regex_find_txt(
                r"maximum-prefix \d+ \d+ \w+ (\d+)", neighbor_config, default=0
            )
            bgp_type = "external"
            if local_as:
                if local_as == peer_as:
                    bgp_type = "internal"
            elif bgp_asn == peer_as:
                bgp_type = "internal"

            bgp_config[group_name] = {
                "apply_groups": [],  # on IOS will always be empty list!
                "description": description,
                "local_as": local_as,
                "type": bgp_type,
                "import_policy": import_policy,
                "export_policy": export_policy,
                "local_address": local_address,
                "multipath": multipath,
                "multihop_ttl": multihop_ttl,
                "remote_as": peer_as,
                "remove_private_as": remove_private_as,
                "prefix_limit": build_prefix_limit(
                    afi, prefix_limit, prefix_percent, prefix_timeout
                ),
                "neighbors": bgp_group_neighbors.get(group_name, {}),
            }
        return bgp_config
975934
def list_bgp_speaker_on_dragent(self, bgp_dragent, **_params):
        """"""
        return self.get((self.agent_path + self.BGP_DRINSTANCES)
                        % bgp_dragent, params=_params)
185576
def create_api_vrf(self):
        """"""
        return ApiVrf(
            self.networkapi_url,
            self.user,
            self.password,
            self.user_ldap)