This patch enhances the APIs of BGPSpeaker class which call
'operator.show' APIs.

Note: This patch renames the following argument for the consistency
of APIs.
 - argument 'family' of rib_get() to 'route_family'
 - argument 'routetype' of neighbor_get() to 'neighbor_get'

Signed-off-by: IWASE Yusuke <[email protected]>
---
 ryu/services/protocols/bgp/bgpspeaker.py | 49 ++++++++++++++++++++++++++------
 1 file changed, 41 insertions(+), 8 deletions(-)

diff --git a/ryu/services/protocols/bgp/bgpspeaker.py 
b/ryu/services/protocols/bgp/bgpspeaker.py
index 2243ecb..b4fe7ca 100644
--- a/ryu/services/protocols/bgp/bgpspeaker.py
+++ b/ryu/services/protocols/bgp/bgpspeaker.py
@@ -663,9 +663,23 @@ class BGPSpeaker(object):
 
         call('vrf.delete', **vrf)
 
-    def vrfs_get(self, format='json'):
+    def vrfs_get(self, subcommand='routes', route_dist=None,
+                 route_family='all', format='json'):
         """ This method returns the existing vrfs.
 
+        ``subcommand`` specifies the subcommand.
+
+          'routes': shows routes present for vrf
+
+          'summary': shows configuration and summary of vrf
+
+        ``route_dist`` specifies a route distinguisher value.
+        If route_family is 'all', this value is ignored.
+
+        ``route_family`` specifies route family of the VRF.
+        This parameter must be RF_VPN_V4, RF_VPN_V6 or RF_L2_EVPN
+        or 'all'.
+
         ``format`` specifies the format of the response.
         This parameter must be 'json' or 'cli'.
         """
@@ -673,30 +687,36 @@ class BGPSpeaker(object):
             'params': ['vrf', 'routes', 'all'],
             'format': format,
         }
+        if route_family in SUPPORTED_VRF_RF:
+            assert route_dist is not None
+            show['params'] = ['vrf', subcommand, route_dist, route_family]
+        else:
+            show['params'] = ['vrf', subcommand, 'all']
 
         return call('operator.show', **show)
 
-    def rib_get(self, family='ipv4', format='json'):
+    def rib_get(self, route_family='all', format='json'):
         """ This method returns the BGP routing information in a json
         format. This will be improved soon.
 
-        ``family`` specifies the address family of the RIB.
+        ``route_family`` specifies the address family of the RIB
+        (e.g. 'ipv4').
 
         ``format`` specifies the format of the response.
         This parameter must be 'json' or 'cli'.
         """
         show = {
-            'params': ['rib', family],
+            'params': ['rib', route_family],
             'format': format
         }
 
         return call('operator.show', **show)
 
-    def neighbor_get(self, routetype, address, format='json'):
+    def neighbor_get(self, route_type, 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
+        ``route_type`` This parameter is necessary for only received-routes
         and sent-routes.
 
           received-routes : paths received and not withdrawn by given peer
@@ -712,13 +732,26 @@ class BGPSpeaker(object):
         show = {
             'format': format,
         }
-        if routetype == 'sent-routes' or routetype == 'received-routes':
-            show['params'] = ['neighbor', routetype, address, 'all']
+        if route_type == 'sent-routes' or route_type == 'received-routes':
+            show['params'] = ['neighbor', route_type, address, 'all']
         else:
             show['params'] = ['neighbor', 'received-routes', address, 'all']
 
         return call('operator.show', **show)
 
+    def neighbors_get(self, format='json'):
+        """ This method returns a list of the BGP neighbors.
+
+        ``format`` specifies the format of the response.
+        This parameter must be 'json' or 'cli'.
+        """
+        show = {
+            'params': ['neighbor'],
+            '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\''
-- 
2.7.4


------------------------------------------------------------------------------
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to