コード例 #1
0
ファイル: load_balancer.py プロジェクト: xinhuoxing/octavia
    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
コード例 #2
0
    def _lookup(self, lb_id, *remainder):
        """Overriden 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.
        """
        session = db_api.get_session()
        if lb_id and len(remainder) and remainder[0] == 'listeners':
            remainder = remainder[1:]
            db_lb = self.repositories.load_balancer.get(session, id=lb_id)
            if not db_lb:
                LOG.info(_LI("Load Balancer %s was not found."), lb_id)
                raise exceptions.NotFound(
                    resource=data_models.LoadBalancer._name(), id=lb_id)
            return listener.ListenersController(
                load_balancer_id=db_lb.id), remainder