backing up
[vsorcdistro/.git] / ryu / build / lib.linux-armv7l-2.7 / ryu / services / protocols / bgp / operator / commands / clear.py
1 from ryu.services.protocols.bgp.operator.command import Command
2 from ryu.services.protocols.bgp.operator.command import CommandsResponse
3 from ryu.services.protocols.bgp.operator.command import STATUS_OK
4 from ryu.services.protocols.bgp.operator.commands.responses import \
5     WrongParamResp
6
7
8 class BGPCmd(Command):
9     help_msg = ('reset bgp connections, no afi/safi is '
10                 'treated as - all supported address-families')
11     param_help_msg = '<peer_ip> [<afi> <safi>]'
12     command = 'bgp'
13
14     def __init__(self, *args, **kwargs):
15         super(BGPCmd, self).__init__(*args, **kwargs)
16
17         self.subcommands = {'all': self.All}
18
19     def action(self, params):
20         if len(params) == 0:
21             return WrongParamResp()
22         peer = afi = safi = None
23         try:
24             peer = params[0]
25             afi = params[1]
26             safi = params[2]
27         except IndexError:
28             pass
29
30         self.api.route_refresh(peer, afi, safi)
31         return CommandsResponse(STATUS_OK, '')
32
33     class All(Command):
34         help_msg = 'reset all connections'
35         param_help_msg = '[<afi=> <safi=>]'
36         command = 'all'
37
38         def action(self, params):
39             peer = afi = safi = None
40             try:
41                 afi = params[0]
42                 safi = params[1]
43             except IndexError:
44                 pass
45
46             self.api.route_refresh(peer, afi, safi)
47             return CommandsResponse(STATUS_OK, '')
48
49
50 class ClearCmd(Command):
51     help_msg = 'allows to reset BGP connections'
52     command = 'clear'
53
54     subcommands = {'bgp': BGPCmd}