Ejemplo n.º 1
0
Archivo: v1.py Proyecto: xinwu/yabgp
def get_adj_rib_out(afi_safi, peer_ip):
    """
    Try to get BGP adj rib out
    :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_out(peer_ip, afi_safi, prefix)})
    return flask.jsonify(
        {'prefixes': api_utils.get_adj_rib_out(peer_ip, afi_safi)})
Ejemplo n.º 2
0
Archivo: v1.py Proyecto: c0ns0le/yabgp
def get_adj_rib_out(afi_safi, peer_ip):
    """
    Try to get BGP adj rib out
    :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_out(peer_ip, afi_safi, prefix)
            })
    return flask.jsonify({
        'prefixes': api_utils.get_adj_rib_out(peer_ip, afi_safi)}
    )
Ejemplo n.º 3
0
def search_adj_rib_out(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_out(prefix_list, afi_safi))
Ejemplo n.º 4
0
def get_adj_rib_out(afi_safi, peer_ip):
    return flask.jsonify({
        'prefix': api_utils.get_adj_rib_out(peer_ip, afi_safi)}
    )
Ejemplo n.º 5
0
def get_adj_rib_out(afi_safi, peer_ip):
    return flask.jsonify(
        {'prefix': api_utils.get_adj_rib_out(peer_ip, afi_safi)})
Ejemplo n.º 6
0
Archivo: v1.py Proyecto: Dipsingh/yabgp
def get_adj_rib_out(afi_safi, peer_ip):
    """
    Try to get BGP adj rib out

    **Example request**

    .. sourcecode:: http

      GET /v1/adj-rib-out/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": [
          "4.4.4.4/32",
          "5.5.5.5/32",
          "6.6.6.6/32"
        ]
      }

    **Example request**

    .. sourcecode:: http

      GET /v1/adj-rib-out/ipv4/10.75.44.242?prefix=4.4.4.4/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.75.44.225",
            "5": 100,
            "8": [
              "NO_EXPORT"
            ]
          }
      }

    :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_out(peer_ip, afi_safi, prefix)
            })
    return flask.jsonify({
        'prefixes': api_utils.get_adj_rib_out(peer_ip, afi_safi)}
    )