Exemple #1
0
    def _lookup(self, listener_id, *remainder):
        """Overridden pecan _lookup method for custom routing.

        Verifies that the listener passed in the url exists, and if so decides
        which controller, if any, should control be passed.
        """
        context = pecan.request.context.get('octavia_context')
        if listener_id and len(remainder) and (remainder[0] == 'pools'
                                               or remainder[0] == 'l7policies'
                                               or remainder[0] == 'stats'):
            controller = remainder[0]
            remainder = remainder[1:]
            db_listener = self.repositories.listener.get(context.session,
                                                         id=listener_id)
            if not db_listener:
                LOG.info(_LI("Listener %s not found."), listener_id)
                raise exceptions.NotFound(
                    resource=data_models.Listener._name(), id=listener_id)
            if controller == 'pools':
                return pool.PoolsController(
                    load_balancer_id=self.load_balancer_id,
                    listener_id=db_listener.id), remainder
            elif controller == 'l7policies':
                return l7policy.L7PolicyController(
                    load_balancer_id=self.load_balancer_id,
                    listener_id=db_listener.id), remainder
            elif controller == 'stats':
                return listener_statistics.ListenerStatisticsController(
                    listener_id=db_listener.id), remainder
Exemple #2
0
    def _lookup(self, lb_id, *remainder):
        """Overridden pecan _lookup method for custom routing.

        Verifies that the load balancer passed in the url exists, and if so
        decides which controller, if any, should control be passed.
        """
        context = pecan.request.context.get('octavia_context')

        possible_remainder = ('listeners', 'pools', 'delete_cascade', 'stats')
        if lb_id and len(remainder) and (remainder[0] in possible_remainder):
            controller = remainder[0]
            remainder = remainder[1:]
            db_lb = self.repositories.load_balancer.get(context.session,
                                                        id=lb_id)
            if not db_lb:
                LOG.info("Load Balancer %s was not found.", lb_id)
                raise exceptions.NotFound(
                    resource=data_models.LoadBalancer._name(), id=lb_id)
            if controller == 'listeners':
                return listener.ListenersController(
                    load_balancer_id=db_lb.id), remainder
            elif controller == 'pools':
                return pool.PoolsController(
                    load_balancer_id=db_lb.id), remainder
            elif (controller == 'delete_cascade'):
                return LBCascadeDeleteController(db_lb.id), ''
            elif (controller == 'stats'):
                return lb_stats.LoadBalancerStatisticsController(
                    loadbalancer_id=db_lb.id), remainder
Exemple #3
0
    def _lookup(self, listener_id, *remainder):
        """Overriden pecan _lookup method for custom routing.

        Verifies that the listener passed in the url exists, and if so decides
        which controller, if any, should control be passed.
        """
        session = db_api.get_session()
        if listener_id and len(remainder) and remainder[0] == 'pools':
            remainder = remainder[1:]
            db_listener = self.repositories.listener.get(session,
                                                         id=listener_id)
            if not db_listener:
                LOG.info(_LI("Listener %s not found."), listener_id)
                raise exceptions.NotFound(
                    resource=data_models.Listener._name(), id=listener_id)
            return pool.PoolsController(load_balancer_id=self.load_balancer_id,
                                        listener_id=db_listener.id), remainder