def update_l7rule(self, l7rule, service_object, bigips):
        LOG.debug("L7PolicyService:update_l7rule")

        # get l7policy for rule
        lbaas_service = LbaasServiceObject(service_object)
        l7policy = lbaas_service.get_l7policy(l7rule.get('policy_id', ''))
        if l7policy:
            # re-create policy with updated rule
            self.update_l7policy(l7policy, service_object, bigips)
    def update_l7rule(self, l7rule, service_object, bigips):
        LOG.debug("L7PolicyService:update_l7rule")

        # get l7policy for rule
        lbaas_service = LbaasServiceObject(service_object)
        l7policy = lbaas_service.get_l7policy(l7rule.get('policy_id', ''))
        if l7policy:
            # re-create policy with updated rule
            self.update_l7policy(l7policy, service_object, bigips)
    def get_listener_policies(self, service):
        """Return a map of listener L7 policy ids to a list of L7 rules."""
        lbaas_service = LbaasServiceObject(service)
        listener_policies = list()

        listener = service.get('listener', None)
        if not listener:
            return listener_policies

        listener_l7policy_ids = listener.get('l7_policies', list())
        LOG.debug("L7 debug: listener policies: %s", listener_l7policy_ids)
        for policy in listener_l7policy_ids:
            if self.is_esd(policy.get('name')):
                continue

            listener_policy = lbaas_service.get_l7policy(policy['id'])
            LOG.debug("L7 debug: listener policy: %s", listener_policy)
            if not listener_policy:
                LOG.warning(
                    "Referenced L7 policy %s for listener %s not "
                    "found in service.", policy['id'], listener['id'])
                continue

            listener_l7policy_rules = list()
            rules = listener_policy.get('rules', list())
            for rule in rules:
                l7policy_rule = lbaas_service.get_l7rule(rule['id'])
                if not l7policy_rule:
                    LOG.warning(
                        "Referenced L7 rule %s for policy %s not "
                        "found in service.", rule['id'], policy['id'])
                    continue

                if l7policy_rule['provisioning_status'] != "PENDING_DELETE":
                    listener_l7policy_rules.append(l7policy_rule)

            listener_policy['l7policy_rules'] = listener_l7policy_rules
            listener_policies.append(listener_policy)

        return listener_policies
    def get_listener_policies(self, service):
        """Return a map of listener L7 policy ids to a list of L7 rules."""
        lbaas_service = LbaasServiceObject(service)
        listener_policies = list()

        listener = service.get('listener', None)
        if not listener:
            return listener_policies

        listener_l7policy_ids = listener.get('l7_policies', list())
        LOG.debug("L7 debug: listener policies: %s", listener_l7policy_ids)
        for policy in listener_l7policy_ids:
            if self.is_esd(policy.get('name')):
                continue

            listener_policy = lbaas_service.get_l7policy(policy['id'])
            LOG.debug("L7 debug: listener policy: %s", listener_policy)
            if not listener_policy:
                LOG.warning("Referenced L7 policy %s for listener %s not "
                            "found in service.", policy['id'], listener['id'])
                continue

            listener_l7policy_rules = list()
            rules = listener_policy.get('rules', list())
            for rule in rules:
                l7policy_rule = lbaas_service.get_l7rule(rule['id'])
                if not l7policy_rule:
                    LOG.warning("Referenced L7 rule %s for policy %s not "
                                "found in service.", rule['id'], policy['id'])
                    continue

                if l7policy_rule['provisioning_status'] != "PENDING_DELETE":
                    listener_l7policy_rules.append(l7policy_rule)

            listener_policy['l7policy_rules'] = listener_l7policy_rules
            listener_policies.append(listener_policy)

        return listener_policies