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_ERROR
4 from ryu.services.protocols.bgp.operator.command import STATUS_OK
5 from ryu.services.protocols.bgp.operator.commands.responses import \
8 from ryu.services.protocols.bgp.operator.views.bgp import CoreServiceDetailView
11 class Importmap(Command):
12 help_msg = 'show importmaps'
13 param_help_msg = 'all | <name>'
16 def __init__(self, *args, **kwargs):
17 super(Importmap, self).__init__(*args, **kwargs)
19 def action(self, params):
21 return WrongParamResp()
23 core_service = self.api.get_core_service()
24 core_service_view = CoreServiceDetailView(core_service)
25 importmap_manager = core_service_view.rel('importmap_manager')
26 importmaps_view = importmap_manager.rel('importmaps')
28 importmap_name = params[0]
29 if importmap_name == 'all':
30 encoded = importmaps_view.encode()
32 encoded = importmaps_view.encode().get(importmap_name)
34 return CommandsResponse(
36 'Wrong importmap name.'
39 return CommandsResponse(