looks like, bgpd> show neighbor IP Address AS Number BGP State 10.0.0.1 64514 Established
Signed-off-by: ISHIDA Wataru <ishida.wat...@lab.ntt.co.jp> --- .../bgp/operator/commands/show/neighbor.py | 31 ++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/ryu/services/protocols/bgp/operator/commands/show/neighbor.py b/ryu/services/protocols/bgp/operator/commands/show/neighbor.py index bd3fda7..9f3f5ed 100644 --- a/ryu/services/protocols/bgp/operator/commands/show/neighbor.py +++ b/ryu/services/protocols/bgp/operator/commands/show/neighbor.py @@ -133,3 +133,34 @@ class Neighbor(Command): 'sent-routes': SentRoutes, 'received-routes': ReceivedRoutes } + + fmtstr = ' {0:<12s} {1:<12s} {2:<}\n' + + def action(self, params): + core_service = self.api.get_core_service() + core_service_view = CoreServiceDetailView(core_service) + peers_view = core_service_view.rel('peer_manager').rel('peers') + + ret = peers_view.encode() + return CommandsResponse(STATUS_OK, + [{'ip_addr': k, + 'as_num': str(v['remote_as']), + 'bgp_state': v['stats']['bgp_state']} + for k, v in ret.iteritems()]) + + @classmethod + def cli_resp_formatter(cls, resp): + if resp.status == STATUS_ERROR: + return Command.cli_resp_formatter(resp) + return cls._format_header() + cls._format_value(resp.value) + + @classmethod + def _format_header(cls): + return cls.fmtstr.format('IP Address', 'AS Number', 'BGP State') + + @classmethod + def _format_value(cls, value): + ret = '' + for v in value: + ret += cls.fmtstr.format(v['ip_addr'], v['as_num'], v['bgp_state']) + return ret -- 1.7.10.4 ------------------------------------------------------------------------------ Infragistics Professional Build stunning WinForms apps today! Reboot your WinForms applications with our WinForms controls. Build a bridge from your legacy apps to the future. http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk _______________________________________________ Ryu-devel mailing list Ryu-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ryu-devel