예제 #1
0
    def delete(self, id):
        """Deletes a pool from a load balancer."""
        context = pecan.request.context.get('octavia_context')
        db_pool = self._get_db_pool(context.session, id, show_deleted=False)
        if db_pool.l7policies:
            raise exceptions.PoolInUseByL7Policy(
                id=db_pool.id, l7policy_id=db_pool.l7policies[0].id)

        project_id, provider = self._get_lb_project_id_provider(
            context.session, db_pool.load_balancer_id)

        self._auth_validate_action(context, project_id, constants.RBAC_DELETE)

        # Load the driver early as it also provides validation
        driver = driver_factory.get_driver(provider)

        with db_api.get_lock_session() as lock_session:
            self._test_lb_and_listener_statuses(
                lock_session,
                lb_id=db_pool.load_balancer_id,
                listener_ids=self._get_affected_listener_ids(db_pool))
            self.repositories.pool.update(
                lock_session,
                db_pool.id,
                provisioning_status=constants.PENDING_DELETE)

            LOG.info("Sending delete Pool %s to provider %s", id, driver.name)
            provider_pool = (driver_utils.db_pool_to_provider_pool(db_pool))
            driver_utils.call_provider(driver.name, driver.pool_delete,
                                       provider_pool)
예제 #2
0
파일: pool.py 프로젝트: greatbn/octavia
    def delete(self, id):
        """Deletes a pool from a load balancer."""
        context = pecan.request.context.get('octavia_context')
        db_pool = self._get_db_pool(context.session, id)
        if len(db_pool.l7policies) > 0:
            raise exceptions.PoolInUseByL7Policy(
                id=db_pool.id, l7policy_id=db_pool.l7policies[0].id)

        self._auth_validate_action(context, db_pool.project_id,
                                   constants.RBAC_DELETE)

        if db_pool.provisioning_status == constants.DELETED:
            return

        self._test_lb_and_listener_statuses(
            context.session,
            lb_id=db_pool.load_balancer_id,
            listener_ids=self._get_affected_listener_ids(db_pool))
        self.repositories.pool.update(
            context.session,
            db_pool.id,
            provisioning_status=constants.PENDING_DELETE)

        try:
            LOG.info("Sending Deletion of Pool %s to handler", db_pool.id)
            self.handler.delete(db_pool)
        except Exception:
            with excutils.save_and_reraise_exception(
                    reraise=False), db_api.get_lock_session() as lock_session:
                self._reset_lb_and_listener_statuses(
                    lock_session,
                    lb_id=db_pool.load_balancer_id,
                    listener_ids=self._get_affected_listener_ids(db_pool))
                # Pool now goes to ERROR
                self.repositories.pool.update(
                    lock_session,
                    db_pool.id,
                    provisioning_status=constants.ERROR)
예제 #3
0
    def delete(self, id):
        """Deletes a pool from a load balancer."""
        context = pecan.request.context.get('octavia_context')
        db_pool = self._get_db_pool(context.session, id)
        if len(db_pool.l7policies) > 0:
            raise exceptions.PoolInUseByL7Policy(
                id=db_pool.id, l7policy_id=db_pool.l7policies[0].id)
        self._test_lb_and_listener_statuses(context.session, pool=db_pool)

        try:
            LOG.info("Sending Deletion of Pool %s to handler", db_pool.id)
            self.handler.delete(db_pool)
        except Exception:
            with excutils.save_and_reraise_exception(reraise=False):
                for listener in db_pool.listeners:
                    self.repositories.listener.update(
                        context.session, listener.id,
                        operating_status=constants.ERROR)
                self.repositories.pool.update(
                    context.session, db_pool.id,
                    operating_status=constants.ERROR)
        db_pool = self.repositories.pool.get(context.session, id=db_pool.id)
        return self._convert_db_to_type(db_pool, pool_types.PoolResponse)