Skip to content
This repository has been archived by the owner on Jun 24, 2021. It is now read-only.

[FR] Update the parser to use FRRouting JSON as data-source instead of screen-scraping #1

Closed
netravnen opened this issue Feb 28, 2020 · 2 comments

Comments

@netravnen
Copy link

Disclaimer: duplicate of thatmattlove/hyperglass-frr/issues/1

FRRouting support for getting a Command Line Interface command output in JSON format is getting better and better over time.

E.g. for hyperglass-frr is show bgp [ ipv4 | ipv6 ] unicast [ prefix | route ] json

Will avoid screen-scraping and well-known data-format is used as data-source when querying FRRouting for information.


frrouting-A# show bgp ipv4 unicast 172.20.230.0/25
BGP routing table entry for 172.20.230.0/25
Paths: (1 available, best #1, table default)
  Local
    0.0.0.0 from 0.0.0.0 (192.0.2.10)
      Origin IGP, metric 0, localpref 0, weight 32768, valid, sourced, local, bestpath-from-AS Local, best (First path received)
      Community: graceful-shutdown
      AddPath ID: RX 0, TX-All 2 TX-Best-Per-AS 0
      Advertised to: 192.0.2.11
      Last update: Sat Feb 22 03:43:28 2020


frrouting-A# show bgp ipv4 unicast 172.20.230.0/25 json 
{
  "prefix":"172.20.230.0\/25",
  "paths":[
    {
      "aspath":{
        "string":"Local",
        "segments":[
        ],
        "length":0
      },
      "origin":"IGP",
      "med":0,
      "metric":0,
      "localpref":0,
      "weight":32768,
      "valid":true,
      "sourced":true,
      "local":true,
      "bestpath":{
        "bestpathFromAs":0,
        "overall":true,
        "selectionReason":"First path received"
      },
      "community":{
        "string":"graceful-shutdown",
        "list":[
          "gracefulShutdown"
        ]
      },
      "addpathRxId":0,
      "addpathTxId":2,
      "addpathTxIdAll":2,
      "addpathTxIdBestPerAS":0,
      "advertisedTo":{
        "192.0.2.11":{
          "hostname":"frrouting-B"
        }
      },
      "lastUpdate":{
        "epoch":1582343008,
        "string":"Sat Feb 22 03:43:28 2020\n"
      },
      "nexthops":[
        {
          "ip":"0.0.0.0",
          "afi":"ipv4",
          "metric":0,
          "accessible":true,
          "used":true
        }
      ],
      "peer":{
        "peerId":"0.0.0.0",
        "routerId":"192.0.2.10"
      }
    }
  ]
}

frrouting-A# find json 
<snip>
  (view)  show [ip] bgp <view|vrf> all [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast|flowspec>]] [json]
  (view)  show [ip] bgp [<ipv4|ipv6> [unicast]] neighbors <A.B.C.D|X:X::X:X|WORD> received prefix-filter [json]
  (view)  show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> [<unicast|multicast|vpn>]] route-leak  [json]
  (view)  show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast|flowspec>]]          [cidr-only          |dampening <flap-statistics|dampened-paths>          |community [AA:NN|local-AS|no-advertise|no-export          ]
  (view)  show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast|flowspec>]] neighbors <A.B.C.D|X:X::X:X|WORD> <advertised-routes|received-routes|filtered-routes> [route-map WORD] [json]
  (view)  show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast|flowspec>]] neighbors <A.B.C.D|X:X::X:X|WORD> <flap-statistics|dampened-routes|routes> [json]
  (view)  show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast|flowspec>]] large-community [<AA:BB:CC> [exact-match]] [json]
  (view)  show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast|flowspec>]] large-community-list <(1-500)|WORD> [exact-match] [json]
  (view)  show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast|flowspec>]] summary [failed] [json]
  (view)  show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast|flowspec>]]<A.B.C.D|A.B.C.D/M|X:X::X:X|X:X::X:X/M> [<bestpath|multipath>] [json]
  (view)  show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> flowspec] detail [json]
  (view)  show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]
</snip>

@netravnen netravnen changed the title [FR] Update the parser to use FRRouting JSON as data-source instead of screen-scraping #1 [FR] Update the parser to use FRRouting JSON as data-source instead of screen-scraping Feb 28, 2020
@thatmattlove
Copy link
Owner

Hello,

My plan is to do this ASAP, but I have not yet built any UI components to handled structured data output, so doing this now would just print a big JSON blob to the screen, which would be less readable than the CLI output. I’ve put off writing said UI components until I can at least get structured data out of Cisco IOS, IOS-XR, and JunOS as those are the most widely used platforms.

I’m finally almost ready to release v1.0.0-beta.1 of hyperglass, so this shouldn’t be too far behind.

@thatmattlove
Copy link
Owner

Hi there,

Really sorry for not responding to this sooner.

Starting in hyperglass v1.0.0-beta.76, I've started deprecating hyperglass-agent. Moving forward, FRR & BIRD can be interacted with in the same manner as any other device, i.e. via SSH. See here for details/caveats). Everything will still work as-is for now, but I'd encourage you to try moving to frr_ssh/bird_ssh as the nos (and of course, let me know of any problems via a new hyperglass issue).

I'm going to go ahead and close this issue out.

Thanks,
Matt

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants