From ef0c72c5bf0633598caebb61793eac95db8fbedf Mon Sep 17 00:00:00 2001 From: Toshiki Tsuboi Date: Fri, 6 Feb 2015 16:30:49 +0900 Subject: bgp: support of new api for "show neighbor" You can understand adj-RIB-in information through new api. - received-routes : paths received and not withdrawn by given peer - sent-routes : paths sent and not withdrawn to given peer (sample log of show neighbor) INFO:bgpspeaker.api.base:API method operator.show called with args: {'params': ['neighbor', 'received-routes', '192.168.101.101', 'all'], 'format': 'cli'} Status codes: x filtered Origin codes: i - IGP, e - EGP, ? - incomplete Timestamp Network Labels Next Hop Metric LocPrf Path 2015/02/06 06:52:04 192.168.1.0/30 None 192.168.101.101 100 None [65010] i 2015/02/06 06:52:04 192.168.2.0/30 None 192.168.101.101 100 None [65010] i 2015/02/06 06:52:04 0.0.0.0/0 None 192.168.101.101 100 None [65010, 65001] i Signed-off-by: Toshiki Tsuboi Signed-off-by: FUJITA Tomonori --- ryu/services/protocols/bgp/bgpspeaker.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/ryu/services/protocols/bgp/bgpspeaker.py b/ryu/services/protocols/bgp/bgpspeaker.py index 2f904a65..e38fe590 100644 --- a/ryu/services/protocols/bgp/bgpspeaker.py +++ b/ryu/services/protocols/bgp/bgpspeaker.py @@ -491,6 +491,29 @@ class BGPSpeaker(object): show['format'] = format return call('operator.show', **show) + def neighbor_get(self, routetype, address, format='json'): + """ This method returns the BGP adj-RIB-in information in a json + format. + + ``routetype`` This parameter is necessary for only received-routes + and sent-routes. + + received-routes : paths received and not withdrawn by given peer + + sent-routes : paths sent and not withdrawn to given peer + + ``address`` specifies the IP address of the peer. It must be + the string representation of an IP address. + + """ + show = {} + if routetype == 'sent-routes' or routetype == 'received-routes': + show['params'] = ['neighbor', routetype, address, 'all'] + else: + show['params'] = ['neighbor', 'received-routes', address, 'all'] + show['format'] = format + return call('operator.show', **show) + def _set_filter(self, filter_type, address, filters): assert filter_type in ('in', 'out'),\ 'filter type must be \'in\' or \'out\'' -- cgit v1.2.3