3 from ryu.services.protocols.bgp.operator.command import Command
4 from ryu.services.protocols.bgp.operator.command import CommandsResponse
5 from ryu.services.protocols.bgp.operator.command import STATUS_ERROR
6 from ryu.services.protocols.bgp.operator.command import STATUS_OK
7 from ryu.services.protocols.bgp.operator.commands.responses import \
10 LOG = logging.getLogger('bgpspeaker.operator.commands.show.count')
14 help_msg = 'show counters'
15 param_help_msg = '<vpn-name> <route-family>{ipv4, ipv6}'
17 cli_resp_line_template = 'BGP route count for VPN {0} is {1}\n'
19 def __init__(self, *args, **kwargs):
20 super(Count, self).__init__(*args, **kwargs)
25 def action(self, params):
27 return CommandsResponse(STATUS_ERROR, 'Not enough params')
35 from ryu.services.protocols.bgp.operator.internal_api import \
38 return CommandsResponse(
40 self.api.count_single_vrf_routes(vrf_name, vrf_rf)
42 except WrongParamError as e:
43 return WrongParamResp(e)
46 help_msg = 'shows number of routes for all VRFs'
48 cli_resp_line_template = 'BGP route count for VPN {0} is {1}\n'
50 def action(self, params):
52 return WrongParamResp()
53 return CommandsResponse(STATUS_OK, self.api.count_all_vrf_routes())