idviews: Display the list of hosts when using --all

Enumerating hosts is a potentially expensive operation (uses paged
search to list all the hosts the ID view applies to). Show the list
of the hosts only if explicitly asked for (or asked for --all).
Do not display with --raw, since this attribute does not exist in
LDAP.

Part of: https://fedorahosted.org/freeipa/ticket/3979

Reviewed-By: Petr Viktorin <pviktori@redhat.com>
Reviewed-By: Petr Vobornik <pvoborni@redhat.com>
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
This commit is contained in:
Tomas Babej 2014-09-29 19:23:35 +02:00 committed by Martin Kosek
parent 47268575c9
commit 902655da59

View File

@ -205,7 +205,14 @@ class idview_show(LDAPRetrieve):
def post_callback(self, ldap, dn, entry_attrs, *keys, **options): def post_callback(self, ldap, dn, entry_attrs, *keys, **options):
self.show_id_overrides(dn, entry_attrs) self.show_id_overrides(dn, entry_attrs)
if options.get('show_hosts', False): # Enumerating hosts is a potentially expensive operation (uses paged
# search to list all the hosts the ID view applies to). Show the list
# of the hosts only if explicitly asked for (or asked for --all).
# Do not display with --raw, since this attribute does not exist in
# LDAP.
if ((options.get('show_hosts') or options.get('all'))
and not options.get('raw')):
self.enumerate_hosts(dn, entry_attrs) self.enumerate_hosts(dn, entry_attrs)
return dn return dn