Ejemplo n.º 1
0
Archivo: v1.py Proyecto: xinwu/yabgp
def get_adj_rib_in(afi_safi, peer_ip):
    """
    Try to get BGP adj rib in
    :param afi_safi: address and sub address family, now only suport ipv4
    :param peer_ip: peer ip address
    :status 200: the api can work, otherwise the peer is not established maybe.
    """
    prefix = flask.request.args.get('prefix')
    community = flask.request.args.get('community')
    if prefix or community:
        if prefix:
            return flask.jsonify(
                {'attr': api_utils.get_adj_rib_in(peer_ip, afi_safi, prefix)})
    else:
        return flask.jsonify(
            {'prefixes': api_utils.get_adj_rib_in(peer_ip, afi_safi)})
Ejemplo n.º 2
0
Archivo: v1.py Proyecto: c0ns0le/yabgp
def get_adj_rib_in(afi_safi, peer_ip):
    """
    Try to get BGP adj rib in
    :param afi_safi: address and sub address family, now only suport ipv4
    :param peer_ip: peer ip address
    :status 200: the api can work, otherwise the peer is not established maybe.
    """
    prefix = flask.request.args.get('prefix')
    community = flask.request.args.get('community')
    if prefix or community:
        if prefix:
            return flask.jsonify({
                'attr': api_utils.get_adj_rib_in(peer_ip, afi_safi, prefix)
            })
    else:
        return flask.jsonify({
            'prefixes': api_utils.get_adj_rib_in(peer_ip, afi_safi)}
        )
Ejemplo n.º 3
0
def search_adj_rib_in(peer_ip):
    json_request = flask.request.get_json()
    prefix_list = json_request.get('data')
    afi_safi = dict(request.args.items()).get('afi_safi') or 'ipv4'
    return flask.jsonify(api_utils.get_adj_rib_in(prefix_list, afi_safi))
Ejemplo n.º 4
0
def get_adj_rib_in(afi_safi, peer_ip):
    return flask.jsonify({
        'prefix': api_utils.get_adj_rib_in(peer_ip, afi_safi)}
    )
Ejemplo n.º 5
0
def get_adj_rib_in(afi_safi, peer_ip):
    return flask.jsonify(
        {'prefix': api_utils.get_adj_rib_in(peer_ip, afi_safi)})
Ejemplo n.º 6
0
Archivo: v1.py Proyecto: Dipsingh/yabgp
def get_adj_rib_in(afi_safi, peer_ip):
    """
    Try to get BGP adj rib in

    **Example request**

    .. sourcecode:: http

      GET /v1/adj-rib-in/ipv4/10.75.44.242  HTTP/1.1
      Host: example.com
      Accept: application/json

    **Example response**:

    .. sourcecode:: http

      HTTP/1.1 200 OK
      Vary: Accept
      Content-Type: text/json
      {
        "prefixes": [
          "1.1.1.1/32",
          "2.2.2.2/32",
          "3.3.3.3/32"
        ]
      }

    **Example request**

    .. sourcecode:: http

      GET /v1/adj-rib-in/ipv4/10.75.44.242?prefix=1.1.1.1/32  HTTP/1.1
      Host: example.com
      Accept: application/json

    **Example response**:

    .. sourcecode:: http

      HTTP/1.1 200 OK
      Vary: Accept
      Content-Type: text/json
      {
          "attr": {
            "1": 0,
            "2": [],
            "3": "10.124.1.221",
            "4": 0,
            "5": 100
          }
      }

    :param afi_safi: address and sub address family, now only suport ipv4
    :param peer_ip: peer ip address
    :status 200: the api can work, otherwise the peer is not established maybe.
    """
    prefix = flask.request.args.get('prefix')
    community = flask.request.args.get('community')
    if prefix or community:
        if prefix:
            return flask.jsonify({
                'attr': api_utils.get_adj_rib_in(peer_ip, afi_safi, prefix)
            })
    else:
        return flask.jsonify({
            'prefixes': api_utils.get_adj_rib_in(peer_ip, afi_safi)}
        )