Esempio n. 1
0
 def action(self, params):
     if len(params) != 1 or params[0] not in self.supported_families:
         return WrongParamResp()
     from ryu.services.protocols.bgp.operator.internal_api \
         import WrongParamError
     try:
         return CommandsResponse(STATUS_OK,
                                 self.api.get_single_rib_routes(params[0]))
     except WrongParamError as e:
         return WrongParamResp(e)
Esempio n. 2
0
 def action(self, params):
     if len(params) != 0:
         return WrongParamResp()
     ret = {}
     for family in self.supported_families:
         ret[family] = self.api.get_single_rib_routes(family)
     return CommandsResponse(STATUS_OK, ret)
Esempio n. 3
0
File: vrf.py Progetto: yakirl/ryu
    def action(self, params):
        if len(params) != 2:
            return WrongParamResp()
        vrf_name = params[0]
        vrf_rf = params[1]
        if vrf_rf not in ('ipv4', 'ipv6'):
            return WrongParamResp('route-family not one of (ipv4, ipv6)')

        from ryu.services.protocols.bgp.operator.internal_api import \
            WrongParamError

        try:
            return CommandsResponse(
                STATUS_OK, self.api.get_single_vrf_routes(vrf_name, vrf_rf))
        except WrongParamError as e:
            return CommandsResponse(STATUS_ERROR,
                                    'wrong parameters: %s' % str(e))
Esempio n. 4
0
 def action(self, params):
     if len(params) != 0:
         return WrongParamResp()
     ret = {}
     try:
         for family in self.supported_families:
             ret[family] = self.api.get_single_rib_routes(family)
         return CommandsResponse(STATUS_OK, ret)
     except ActivityException as e:
         return CommandsResponse(STATUS_ERROR, e)
Esempio n. 5
0
File: vrf.py Progetto: yakirl/ryu
    def action(self, params):
        if len(params) == 0:
            return WrongParamResp('Not enough params')

        vrf_confs = self.api.get_vrfs_conf()
        if len(params) < 2:
            vrf_rf = 'ipv4'
        else:
            vrf_rf = params[1]

        vrf_key = params[0], vrf_rf

        if vrf_key in vrf_confs:
            view = ConfDetailView(vrf_confs[vrf_key])
            encoded = view.encode()
            encoded['routes_count'] = self._count_routes(params[0], vrf_rf)
        else:
            return WrongParamResp('No vrf matched by %s' % str(vrf_key))

        return CommandsResponse(STATUS_OK, encoded)
Esempio n. 6
0
    def action(self, params):
        if len(params) != 2:
            return WrongParamResp()
        ip_addr, addr_family = params

        if addr_family == 'ipv4':
            rf = RF_IPv4_UC
        elif addr_family == 'ipv6':
            rf = RF_IPv6_UC
        elif addr_family == 'vpnv4':
            rf = RF_IPv4_VPN
        elif addr_family == 'vpnv6':
            rf = RF_IPv6_VPN
        elif addr_family == 'all':
            rf = None
        else:
            return WrongParamResp('wrong addr_family name')

        ret = self._retrieve_paths(addr_family, rf, ip_addr).encode()
        return CommandsResponse(STATUS_OK, ret)
Esempio n. 7
0
 def action(self, params):
     lvls = {
         'debug': logging.DEBUG,
         'error': logging.ERROR,
         'info': logging.INFO
     }
     if len(params) == 1 and params[0] in lvls:
         self.api.log_handler.setLevel(
             lvls.get(params[0], logging.ERROR))
         return CommandsResponse(STATUS_OK, True)
     else:
         return WrongParamResp()
Esempio n. 8
0
    def action(self, params):
        if len(params) == 0:
            return WrongParamResp()
        peer = afi = safi = None
        try:
            peer = params[0]
            afi = params[1]
            safi = params[2]
        except IndexError:
            pass

        self.api.route_refresh(peer, afi, safi)
        return CommandsResponse(STATUS_OK, '')
Esempio 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)
Esempio n. 10
0
    def action(self, params):
        if len(params) < 1:
            return CommandsResponse(STATUS_ERROR, 'Not enough params')
        else:
            vrf_name = params[0]
            if len(params) == 2:
                vrf_rf = params[1]
            else:
                vrf_rf = 'ipv4'

            from ryu.services.protocols.bgp.operator.internal_api import \
                WrongParamError
            try:
                return CommandsResponse(
                    STATUS_OK,
                    self.api.count_single_vrf_routes(vrf_name, vrf_rf))
            except WrongParamError as e:
                return WrongParamResp(e)
Esempio n. 11
0
File: vrf.py Progetto: yakirl/ryu
 def action(self, params):
     if len(params) != 0:
         return WrongParamResp()
     return CommandsResponse(STATUS_OK, self.api.get_all_vrf_routes())