diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-01-20 16:02:32 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-01-20 16:02:32 +0900 |
commit | 355e5790dfd4a5941cd5c93586473819cc7e3bbd (patch) | |
tree | f478c5b8500fa404125beaf6a903e5c4943071b5 /cli/gobgpcli | |
parent | b27eed1b8670ed7612129263741ef48ae2bfa1b4 (diff) |
table: remove Path's best
Path can be shared in multiple local ribs so having "best" in Path is
wrong. The info "best" path is stored in Destination so CLI uses it.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'cli/gobgpcli')
-rwxr-xr-x | cli/gobgpcli | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/cli/gobgpcli b/cli/gobgpcli index c2bac48f..77cd4849 100755 --- a/cli/gobgpcli +++ b/cli/gobgpcli @@ -236,33 +236,35 @@ class Show(object): print r.json() return 0 - print(" Network Next Hop AS_PATH Attrs") - if self.args[2] =="local-rib": + f = "{:2s} {:18s} {:15s} {:10s} {:s}" + print(f.format("", "Network", "Next Hop", "AS_PATH", "Attrs")) + if self.args[2] == "local-rib": for d in r.json()["Destinations"]: - self.show_routes(d["Paths"]) + d["Paths"][d["BestPathIdx"]]["Best"] = True + self.show_routes(f, d["Paths"], True) 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) - + self.show_routes(f, paths) return 0 - def show_routes(self, paths): + def show_routes(self, f, paths, showBest=False): 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 = "*>" + if showBest: + if "Best" in p: + header = "*>" + else: + header = "*" else: - header = "*" - print("{:s} {:s} {:s} {:s} {:s}".format(header, p["Network"], - p["Nexthop"], AS, self._format_attrs(p["Attrs"]))) - + header = "" + print(f.format(header, p["Network"], p["Nexthop"], AS, self._format_attrs(p["Attrs"]))) def main(): |