Example #1
0
    def delete_l7policy(self, f5_l7policy, bigips):
        LOG.debug("L7PolicyService:delete_l7policy")

        error = False
        for bigip in bigips:
            try:
                self.policy_helper.delete(bigip, f5_l7policy['name'],
                                          f5_l7policy['partition'])
            except HTTPError as err:
                status_code = err.response.status_code
                if status_code == 404:
                    LOG.warn("Deleting L7 policy failed...not found: %s",
                             err.message)
                elif status_code == 400:
                    LOG.debug(
                        "Deleting L7 policy failed...unknown "
                        "client error: %s", err.message)
                    error = f5_ex.L7PolicyDeleteException(err.message)
                else:
                    error = f5_ex.L7PolicyDeleteException(err.message)
            except Exception as err:
                LOG.exception(err)
                error = f5_ex.L7PolicyDeleteException(err.message)

            if error:
                LOG.error("L7 Policy deletion error: %s", error.message)

        return error
Example #2
0
    def delete_irule(self, delete_irules, bigips):
        LOG.debug("L7PolicyService:delete_iRule")

        error = False
        for bigip in bigips:
            for rule in delete_irules:
                try:
                    self.rule_helper.delete(bigip,
                                            name=rule.get('name'),
                                            partition=rule.get('partition'))
                except HTTPError as err:
                    status_code = err.response.status_code
                    if status_code == 404:
                        LOG.warn(
                            "Deleting L7 policy (iRule) " +
                            "failed...not found: %s", err.message)
                    elif status_code == 400:
                        LOG.debug(
                            "Deleting L7 policy (iRule) failed...unknown "
                            "client error: %s", err.message)
                        error = f5_ex.L7PolicyDeleteException(err.message)
                    else:
                        error = f5_ex.L7PolicyDeleteException(err.message)
                except Exception as err:
                    LOG.exception(err)
                    error = f5_ex.L7PolicyDeleteException(err.message)

                if error:
                    LOG.error("L7 Policy (iRule) deletion error: %s",
                              error.message)

        return error
    def _assure_l7rules_deleted(self, service):
        if 'l7policy_rules' not in service:
            return

        bigips = self.driver.get_config_bigips()
        l7rules = service['l7policy_rules']
        for l7rule in l7rules:
            if l7rule['provisioning_status'] == plugin_const.PENDING_DELETE:
                try:
                    self.l7service.bigips = self.driver.get_config_bigips()
                    self.l7service.delete_l7rule(l7rule, service, bigips)
                except Exception as err:
                    l7rule['provisioning_status'] = plugin_const.ERROR
                    raise f5_ex.L7PolicyDeleteException(err.message)
    def _assure_l7policies_deleted(self, service):
        if 'l7policies' not in service:
            return

        bigips = self.driver.get_config_bigips()
        l7policies = service['l7policies']
        for l7policy in l7policies:
            if l7policy['provisioning_status'] == plugin_const.PENDING_DELETE:
                try:
                    # Note: use update_l7policy because a listener can have
                    # multiple policies
                    self.l7service.update_l7policy(l7policy, service, bigips)
                except Exception as err:
                    l7policy['provisioning_status'] = plugin_const.ERROR
                    raise f5_ex.L7PolicyDeleteException(err.message)
    def _assure_l7rules_deleted(self, service):
        if 'l7policy_rules' not in service:
            return

        bigips = self.driver.get_config_bigips()
        l7rules = service['l7policy_rules']
        for l7rule in l7rules:
            if l7rule['provisioning_status'] == plugin_const.PENDING_DELETE:
                try:
                    # ignore L7 rule if its policy is really an ESD
                    l7policy = self.get_l7policy_for_rule(
                        service['l7policies'], l7rule)
                    name = l7policy.get('name', None)
                    if name and self.is_esd(name):
                        continue
                    self.l7service.bigips = self.driver.get_config_bigips()
                    self.l7service.delete_l7rule(l7rule, service, bigips)
                except Exception as err:
                    l7rule['provisioning_status'] = plugin_const.ERROR
                    service['loadbalancer']['provisioning_status'] = \
                        plugin_const.ERROR
                    raise f5_ex.L7PolicyDeleteException(err.message)
    def _assure_l7policies_deleted(self, service):
        if 'l7policies' not in service:
            return

        bigips = self.driver.get_config_bigips()
        l7policies = service['l7policies']
        for l7policy in l7policies:
            if l7policy['provisioning_status'] == plugin_const.PENDING_DELETE:
                try:
                    name = l7policy.get('name', None)
                    if name and self.is_esd(name):
                        listener = self.get_listener_by_id(
                            service, l7policy.get('listener_id', ''))
                        svc = {
                            "loadbalancer": service["loadbalancer"],
                            "listener": listener
                        }

                        # pool is needed to reset session persistence
                        if listener['default_pool_id']:
                            pool = self.get_pool_by_id(
                                service, listener.get('default_pool_id', ''))
                            if pool:
                                svc['pool'] = pool
                        esd = self.get_esd(name)
                        self.listener_builder.remove_esd(svc, esd, bigips)
                    else:
                        # Note: use update_l7policy because a listener can have
                        # multiple policies
                        self.l7service.update_l7policy(l7policy, service,
                                                       bigips)
                except Exception as err:
                    l7policy['provisioning_status'] = plugin_const.ERROR
                    service['loadbalancer']['provisioning_status'] = \
                        plugin_const.ERROR
                    raise f5_ex.L7PolicyDeleteException(err.message)