Exemplo n.º 1
0
    def create_pool(self, service, bigips):
        """Create a pool on set of BIG-IPs.

        Creates a BIG-IP pool to represent an LBaaS pool object.

        :param service: Dictionary which contains a both a pool
        and load balancer definition.
        :param bigips: Array of BigIP class instances to create pool.
        """
        pool = self.service_adapter.get_pool(service)
        error = None

        for bigip in bigips:
            try:
                self.pool_helper.create(bigip, pool)
            except HTTPError as err:
                if err.response.status_code == 409:
                    LOG.debug("Pool already exists...updating")
                    try:
                        self.pool_helper.update(bigip, pool)
                    except Exception as err:
                        error = f5_ex.PoolUpdateException(err.message)
                        LOG.error("Failed to assure pool %s on %s: %s",
                                  pool['name'], bigip, error.message)
                else:
                    error = f5_ex.PoolCreationException(err.message)
                    LOG.error("Failed to assure pool %s on %s: %s",
                              pool['name'], bigip, error.message)
            except Exception as err:
                error = f5_ex.PoolCreationException(err.message)
                LOG.error("Failed to assure pool %s on %s: %s", pool['name'],
                          bigip, error.message)

        return error
    def _assure_pools_created(self, service):
        if "pools" not in service:
            return

        pools = service["pools"]
        loadbalancer = service["loadbalancer"]

        bigips = self.driver.get_config_bigips()

        for pool in pools:
            if pool['provisioning_status'] != plugin_const.PENDING_DELETE:
                svc = {"loadbalancer": loadbalancer, "pool": pool}
                svc['members'] = self._get_pool_members(service, pool['id'])

                try:
                    # create or update pool
                    if pool['provisioning_status'] \
                            != plugin_const.PENDING_UPDATE:
                        self.pool_builder.create_pool(svc, bigips)
                    else:
                        self.pool_builder.update_pool(svc, bigips)
                except HTTPError as err:
                    if err.response.status_code != 409:
                        pool['provisioning_status'] = plugin_const.ERROR
                        loadbalancer['provisioning_status'] = \
                            plugin_const.ERROR
                        raise f5_ex.PoolCreationException(err.message)
                except Exception as err:
                    pool['provisioning_status'] = plugin_const.ERROR
                    loadbalancer['provisioning_status'] = \
                        plugin_const.ERROR
                    raise f5_ex.PoolCreationException(str(err))
Exemplo n.º 3
0
    def _assure_pools_created(self, service):
        if "pools" not in service:
            return

        pools = service["pools"]
        loadbalancer = service["loadbalancer"]

        bigips = self.driver.get_config_bigips()

        for pool in pools:
            if pool['provisioning_status'] != plugin_const.PENDING_DELETE:
                svc = {"loadbalancer": loadbalancer,
                       "pool": pool}

                # get associated listener for pool
                self.add_listener_pool(service, svc)

                try:
                    # create pool
                    self.pool_builder.create_pool(svc, bigips)

                    # assign pool name to virtual
                    pool_name = self.service_adapter.init_pool_name(
                        loadbalancer, pool)
                    self.listener_builder.update_listener_pool(
                        svc, pool_name["name"], bigips)

                    # update virtual sever pool name, session persistence
                    self.listener_builder.update_session_persistence(
                        svc, bigips)

                except Exception as err:
                    pool['provisioning_status'] = plugin_const.ERROR
                    raise f5_ex.PoolCreationException(err.message)
    def _assure_pools_configured(self, service):
        if "pools" not in service:
            return

        pools = service["pools"]
        loadbalancer = service["loadbalancer"]

        bigips = self.driver.get_config_bigips()

        for pool in pools:
            if pool['provisioning_status'] != plugin_const.PENDING_DELETE and \
                    self._is_not_error(pool):
                svc = {"loadbalancer": loadbalancer, "pool": pool}
                svc['members'] = self._get_pool_members(service, pool['id'])
                try:
                    # assign pool name to virtual
                    pool_name = self.service_adapter.init_pool_name(
                        loadbalancer, pool)

                    # get associated listeners for pool
                    listeners = self._get_pool_listeners(service, pool['id'])
                    for listener in listeners:
                        svc['listener'] = listener
                        self.listener_builder.update_listener_pool(
                            svc, pool_name["name"], bigips)

                        # update virtual sever pool name, session persistence
                        self.listener_builder.update_session_persistence(
                            svc, bigips)
                    self._set_status_as_active(pool)
                except Exception as err:
                    pool['provisioning_status'] = plugin_const.ERROR
                    loadbalancer['provisioning_status'] = plugin_const.ERROR
                    raise f5_ex.PoolCreationException(err.message)
    def _assure_pools_created(self, service):
        if "pools" not in service:
            return

        pools = service["pools"]
        loadbalancer = service["loadbalancer"]

        bigips = self.driver.get_config_bigips()

        for pool in pools:
            if pool['provisioning_status'] != plugin_const.PENDING_DELETE:
                svc = {"loadbalancer": loadbalancer, "pool": pool}
                svc['members'] = self._get_pool_members(service, pool['id'])

                try:
                    # create or update pool
                    if pool['provisioning_status'] == \
                            plugin_const.PENDING_CREATE:
                        self.pool_builder.create_pool(svc, bigips)
                    else:
                        self.pool_builder.update_pool(svc, bigips)

                    # assign pool name to virtual
                    pool_name = self.service_adapter.init_pool_name(
                        loadbalancer, pool)

                    # get associated listeners for pool
                    listeners = self._get_pool_listeners(service, pool['id'])
                    for listener in listeners:
                        svc['listener'] = listener
                        self.listener_builder.update_listener_pool(
                            svc, pool_name["name"], bigips)

                        # update virtual sever pool name, session persistence
                        self.listener_builder.update_session_persistence(
                            svc, bigips)
                except HTTPError as err:
                    if err.response.status_code != 409:
                        pool['provisioning_status'] = plugin_const.ERROR
                        loadbalancer['provisioning_status'] = (
                            plugin_const.ERROR)
                        raise f5_ex.PoolCreationException(err.message)

                except Exception as err:
                    pool['provisioning_status'] = plugin_const.ERROR
                    loadbalancer['provisioning_status'] = plugin_const.ERROR
                    raise f5_ex.PoolCreationException(err.message)