def purge_orphaned_l7_policy(self, tenant_id=None, l7_policy_id=None,
                                 hostnames=list(), listener_id=None):
        """Purge all l7_policys that exist on the BIG-IP but not in Neutron"""
        for bigip in self.get_all_bigips():
            if bigip.hostname in hostnames:
                error = None
                try:
                    l7_policy_name = l7_policy_id
                    partition = self.service_adapter.prefix + tenant_id
                    if listener_id and partition:
                        if self.service_adapter.prefix not in listener_id:
                            listener_id = \
                                self.service_adapter.prefix + listener_id
                        li_resource = resource_helper.BigIPResourceHelper(
                            resource_helper.ResourceType.virtual).load(
                                bigip, listener_id, partition)
                        li_resource.update(policies=[])
                    l7_policy = resource_helper.BigIPResourceHelper(
                        resource_helper.ResourceType.l7policy).load(
                            bigip, l7_policy_name, partition)
                    l7_policy.delete()
                except HTTPError as err:
                    if err.response.status_code == 404:
                        LOG.debug('l7_policy %s not on BIG-IP %s.'
                                  % (l7_policy_id, bigip.hostname))
                    else:
                        error = err
                except Exception as exc:
                    error = err
                if error:
                    kwargs = dict(
                        tenant_id=tenant_id, l7_policy_id=l7_policy_id,
                        hostname=bigip.hostname, listener_id=listener_id)
                    LOG.exception('Exception: purge_orphaned_l7_policy({}) '
                                  '"{}"'.format(kwargs, exc))