summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorHiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp>2015-01-19 21:20:53 +0900
committerHiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp>2015-01-19 21:40:56 +0900
commitb27eed1b8670ed7612129263741ef48ae2bfa1b4 (patch)
treee28d96d51f111313ef55466230311944609cdf6d
parent3ff14a50f135a1d169e76999a7ea86826a0308a9 (diff)
cli: support adj-rib-in/out. sub-command: received-routes/advertised-routes
-rwxr-xr-xcli/gobgpcli44
1 files changed, 31 insertions, 13 deletions
diff --git a/cli/gobgpcli b/cli/gobgpcli
index bbb70503..c2bac48f 100755
--- a/cli/gobgpcli
+++ b/cli/gobgpcli
@@ -226,26 +226,44 @@ class Show(object):
return self._neighbor(neighbor=self.args[1])
if self.args[2] == "local":
self.args[2] = "local-rib"
+ if self.args[2] == "received-routes":
+ self.args[2] = "adj-rib-in"
+ if self.args[2] == "advertised-routes":
+ self.args[2] = "adj-rib-out"
+
r = requests.get(self.base_url + "/neighbor/" + self.args[1] + "/" + self.args[2])
if self.options.debug:
print r.json()
return 0
+
print(" Network Next Hop AS_PATH Attrs")
- for d in r.json()["Destinations"]:
- for p in d["Paths"]:
- nexthop = ""
- AS = ""
- for a in p["Attrs"]:
- if a["Type"] == "BGP_ATTR_TYPE_AS_PATH":
- AS = a["AsPath"]
- if p["Best"] == "true":
- header = "*>"
- else:
- header = "*"
- print("{:s} {:s} {:s} {:s} {:s}".format(header, p["Network"],
- p["Nexthop"], AS, self._format_attrs(p["Attrs"])))
+ if self.args[2] =="local-rib":
+ for d in r.json()["Destinations"]:
+ self.show_routes(d["Paths"])
+
+ elif self.args[2] == "adj-rib-in" or self.args[2] == "adj-rib-out":
+ rfs = ["RF_IPv4_UC", "RF_IPv6_UC"]
+ for rf in rfs:
+ paths = r.json()[rf]
+ self.show_routes(paths)
+
return 0
+ def show_routes(self, paths):
+ for p in paths:
+ nexthop = ""
+ AS = ""
+ for a in p["Attrs"]:
+ if a["Type"] == "BGP_ATTR_TYPE_AS_PATH":
+ AS = a["AsPath"]
+ if p["Best"] == "true":
+ header = "*>"
+ else:
+ header = "*"
+ print("{:s} {:s} {:s} {:s} {:s}".format(header, p["Network"],
+ p["Nexthop"], AS, self._format_attrs(p["Attrs"])))
+
+
def main():
usage = "gobpgcli [options] <command> <args>"