Ejemplo n.º 1
0
 def _retrieve_global_tables_view(self, addr_family, route_family):
     core_service = self.api.get_core_service()
     core_sv = CoreServiceDetailView(core_service)
     table_manager_view = core_sv.rel('table_manager')
     global_tables_view = table_manager_view.rel('global_tables')
     global_tables_view.apply_filter(
         lambda k, v: addr_family == 'all' or k == route_family)
     return global_tables_view
Ejemplo n.º 2
0
 def _retrieve_global_tables_view(self, addr_family, route_family):
     core_service = self.api.get_core_service()
     core_sv = CoreServiceDetailView(core_service)
     table_manager_view = core_sv.rel('table_manager')
     global_tables_view = table_manager_view.rel('global_tables')
     global_tables_view.apply_filter(
         lambda k, v: addr_family == 'all' or k == route_family
     )
     return global_tables_view
Ejemplo n.º 3
0
    def action(self, params):
        core_service = self.api.get_core_service()
        core_service_view = CoreServiceDetailView(core_service)
        peers_view = core_service_view.rel('peer_manager').rel('peers')

        ret = peers_view.encode()
        return CommandsResponse(STATUS_OK,
                                [{'ip_addr': k,
                                  'as_num': str(v['remote_as']),
                                  'bgp_state': v['stats']['bgp_state']}
                                 for k, v in ret.iteritems()])
Ejemplo n.º 4
0
    def action(self, params):
        core_service = self.api.get_core_service()
        core_service_view = CoreServiceDetailView(core_service)
        peers_view = core_service_view.rel('peer_manager').rel('peers')

        ret = peers_view.encode()
        return CommandsResponse(STATUS_OK,
                                [{'ip_addr': k,
                                  'as_num': str(v['remote_as']),
                                  'bgp_state': v['stats']['bgp_state']}
                                 for k, v in ret.iteritems()])
Ejemplo n.º 5
0
    def action(self, params):
        core_service = self.api.get_core_service()
        core_service_view = CoreServiceDetailView(core_service)
        peers_view = core_service_view.rel("peer_manager").rel("peers")

        ret = peers_view.encode()
        return CommandsResponse(
            STATUS_OK,
            [
                {"ip_addr": k, "as_num": str(v["remote_as"]), "bgp_state": v["stats"]["bgp_state"]}
                for k, v in ret.iteritems()
            ],
        )
Ejemplo n.º 6
0
    def action(self, params):
        requested_peers = []
        if len(params) > 0:
            requested_peers = [str(p) for p in params]

        core_service = self.api.get_core_service()
        core_service_view = CoreServiceDetailView(core_service)
        peers_view = core_service_view.rel('peer_manager').rel('peers_summary')

        def filter_requested(peer_id, peer_obj):
            return not requested_peers or peer_id in requested_peers

        peers_view.apply_filter(filter_requested)
        ret = peers_view.encode()
        return CommandsResponse(STATUS_OK, ret)
Ejemplo n.º 7
0
    def action(self, params):
        requested_peers = []
        if len(params) > 0:
            requested_peers = [str(p) for p in params]

        core_service = self.api.get_core_service()
        core_service_view = CoreServiceDetailView(core_service)
        peers_view = core_service_view.rel('peer_manager').rel('peers_summary')

        def filter_requested(peer_id, peer_obj):
            return not requested_peers or peer_id in requested_peers

        peers_view.apply_filter(filter_requested)
        ret = peers_view.encode()
        return CommandsResponse(STATUS_OK, ret)
Ejemplo n.º 8
0
    def action(self, params):
        if len(params) != 1:
            return WrongParamResp()

        core_service = self.api.get_core_service()
        core_service_view = CoreServiceDetailView(core_service)
        importmap_manager = core_service_view.rel('importmap_manager')
        importmaps_view = importmap_manager.rel('importmaps')

        importmap_name = params[0]
        if importmap_name == 'all':
            encoded = importmaps_view.encode()
        else:
            encoded = importmaps_view.encode().get(importmap_name)
            if encoded is None:
                return CommandsResponse(STATUS_ERROR, 'Wrong importmap name.')

        return CommandsResponse(STATUS_OK, encoded)
Ejemplo n.º 9
0
    def action(self, params):
        if len(params) != 1:
            return WrongParamResp()

        core_service = self.api.get_core_service()
        core_service_view = CoreServiceDetailView(core_service)
        importmap_manager = core_service_view.rel('importmap_manager')
        importmaps_view = importmap_manager.rel('importmaps')

        importmap_name = params[0]
        if importmap_name == 'all':
            encoded = importmaps_view.encode()
        else:
            encoded = importmaps_view.encode().get(importmap_name)
            if encoded is None:
                return CommandsResponse(
                    STATUS_ERROR,
                    'Wrong importmap name.'
                )

        return CommandsResponse(
            STATUS_OK,
            encoded
        )
Ejemplo n.º 10
0
 def _retrieve_peer_view(self, ip_addr):
     core_service = self.api.get_core_service()
     core_sv = CoreServiceDetailView(core_service)
     peers_view = core_sv.rel('peer_manager').rel('peers')
     peers_view.apply_filter(lambda k, v: v.ip_address == ip_addr)
     return peers_view
Ejemplo n.º 11
0
 def _retrieve_peer_view(self, ip_addr):
     core_service = self.api.get_core_service()
     core_sv = CoreServiceDetailView(core_service)
     peers_view = core_sv.rel('peer_manager').rel('peers')
     peers_view.apply_filter(lambda k, v: v.ip_address == ip_addr)
     return peers_view