diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-03-11 15:31:31 +0000 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-03-20 22:26:48 +0900 |
commit | 444d48662ea7b2f8dcd56a5590d7b820552ad21a (patch) | |
tree | 08bc445bd773c2a16e577db85279b5d582ad384f /cli/gobgpcli | |
parent | 9355715ea394cb232d933ca20e8365b126ae6302 (diff) |
api/cli: add show global command
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'cli/gobgpcli')
-rwxr-xr-x | cli/gobgpcli | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/cli/gobgpcli b/cli/gobgpcli index 553d8121..b2130f2d 100755 --- a/cli/gobgpcli +++ b/cli/gobgpcli @@ -82,6 +82,31 @@ class Show(object): return f[1]() return 1 + def do_global(self): + if len(self.args) != 1 and len(self.args) != 2: + return 1 + + url = self.base_url + "/global/rib" + if len(self.args) == 2: + url += "/" + self.args[1] + else: + url += "/ipv4" + + try: + r = requests.get(url) + except: + print "Failed to connect to gobgpd. It runs?" + sys.exit(1) + + f = "{:2s} {:18s} {:15s} {:10s} {:10s} {:s}" + print(f.format("", "Network", "Next Hop", "AS_PATH", "Age", "Attrs")) + + for d in r.json()["Destinations"]: + d["Paths"][d["BestPathIdx"]]["Best"] = True + self.show_routes(f, d["Paths"], True, True) + + return 0 + def _neighbor(self, neighbor=None): capdict = {1: "MULTIPROTOCOL", 2: "ROUTE_REFRESH", |