"""
Query BGP neighbor table on a Juniper network device.
"""

import sys
from jnpr.junos import Device
from jnpr.junos.factory import loadyaml

def juniper_bgp_state(dev, bgp_neighbor):
    """
    This function queries the BGP neighbor table on a Juniper network device.

    dev = Juniper device connection
    bgp_neighbor = IP address of BGP neighbor
    return = Returns state of BGP neighbor
    """
    try:
        globals().update(loadyaml('yaml/bgp_neighbor.yml'))
        bgp_ni = bgp_neighbor_info(dev).get(neighbor_address=bgp_neighbor)

        return bgp_ni

    except Exception as err:
        print(err)
        dev.close()
        sys.exit(1)
        return

    return

[((18, 25, 18, 58), 'jnpr.junos.factory.loadyaml', 'loadyaml', ({(18, 34, 18, 57): '"""yaml/bgp_neighbor.yml"""'}, {}), "('yaml/bgp_neighbor.yml')", False, 'from jnpr.junos.factory import loadyaml\n'), ((26, 8, 26, 19), 'sys.exit', 'sys.exit', ({(26, 17, 26, 18): '(1)'}, {}), '(1)', False, 'import sys\n')]