def bgp_table_parser(bgp_table):
    """Generator that parses a line of bgp summary table and returns a dict compatible with NAPALM

    Example line:
    10.2.1.14       4    10  472516  472238      361    0    0     3w1d 9
    """
    bgp_table = bgp_table.strip()
    for bgp_entry in bgp_table.splitlines():
        bgp_table_fields = bgp_entry.split()

        try:
            if re.search(r"Shut.*Admin", bgp_entry):
                (
                    peer_ip,
                    bgp_version,
                    remote_as,
                    msg_rcvd,
                    msg_sent,
                    _,
                    _,
                    _,
                    uptime,
                    state_1,
                    state_2,
                ) = bgp_table_fields
                state_pfxrcd = "{} {}".format(state_1, state_2)
            else:
                (
                    peer_ip,
                    bgp_version,
                    remote_as,
                    msg_rcvd,
                    msg_sent,
                    _,
                    _,
                    _,
                    uptime,
                    state_pfxrcd,
                ) = bgp_table_fields
        except ValueError:
            raise ValueError(
                "Unexpected entry ({}) in BGP summary table".format(bgp_table_fields)
            )

        is_enabled = True
        try:
            received_prefixes = int(state_pfxrcd)
            is_up = True
        except ValueError:
            received_prefixes = -1
            is_up = False
            if re.search(r"Shut.*Admin", state_pfxrcd):
                is_enabled = False

        if not is_up:
            uptime = -1
        if uptime != -1:
            uptime = bgp_time_conversion(uptime)

        yield {
            peer_ip: {
                "is_enabled": is_enabled,
                "uptime": uptime,
                "remote_as": helpers.as_number(remote_as),
                "is_up": is_up,
                "description": "",
                "received_prefixes": received_prefixes,
            }
        }
Generator that parses a line of bgp summary table and returns a dict compatible with NAPALM

    Example line:
    10.2.1.14       4    10  472516  472238      361    0    0     3w1d 9