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_OK
6 from ryu.services.protocols.bgp.operator.command import STATUS_ERROR
7 from ryu.services.protocols.bgp.operator.commands.responses import \
11 class LoggingCmd(Command):
13 help_msg = 'turn on/off logging at current level'
15 def __init__(self, *args, **kwargs):
16 super(LoggingCmd, self).__init__(*args, **kwargs)
23 def action(self, params):
24 return CommandsResponse(STATUS_ERROR, 'Command incomplete')
28 help_msg = 'turn-on the logging at the current level'
30 def action(self, params):
31 logging.getLogger('bgpspeaker').addHandler(self.api.log_handler)
32 return CommandsResponse(STATUS_OK, True)
36 help_msg = 'turn-off the logging'
38 def action(self, params):
39 logging.getLogger('bgpspeaker').removeHandler(self.api.log_handler)
40 return CommandsResponse(STATUS_OK, True)
44 help_msg = 'set logging level'
45 param_help_msg = '[debug/info/error]'
47 def action(self, params):
49 'debug': logging.DEBUG,
50 'error': logging.ERROR,
53 if len(params) == 1 and params[0] in lvls:
54 self.api.log_handler.setLevel(
55 lvls.get(params[0], logging.ERROR)
57 return CommandsResponse(STATUS_OK, True)
59 return WrongParamResp()
62 class SetCmd(Command):
63 help_msg = 'set runtime settings'
66 subcommands = {'logging': LoggingCmd}
68 def action(self, params):
69 return CommandsResponse(STATUS_ERROR, 'Command incomplete')