From a486f49a3726934f99763cc6ae93a41dafc40deb Mon Sep 17 00:00:00 2001 From: Martin Kosek Date: Wed, 26 Oct 2011 11:12:38 +0200 Subject: Create pkey-only option for find commands New option --pkey-only is available for all LDAPSearch based classes with primary key visible in the output. This option makes LDAPSearch commands search for primary attribute only. This may be useful when manipulating large data sets. User can at first retrieve all primary keys in a relatively small data package and then run further commands with retrieved primary keys. https://fedorahosted.org/freeipa/ticket/1262 --- ipalib/plugins/baseldap.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'ipalib/plugins/baseldap.py') diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py index 20f23c2e..88f31299 100644 --- a/ipalib/plugins/baseldap.py +++ b/ipalib/plugins/baseldap.py @@ -1465,6 +1465,13 @@ class LDAPSearch(CallbackInterface, crud.Search): def get_options(self): for option in super(LDAPSearch, self).get_options(): yield option + if self.obj.primary_key and \ + 'no_output' not in self.obj.primary_key.flags: + yield Flag('pkey_only?', + label=_('Primary key only'), + doc=_('Results should contain primary key attribute only ("%s")') \ + % to_cli(self.obj.primary_key.cli_name), + ) for attr in self.member_attributes: for ldap_obj_name in self.obj.attribute_members[attr]: ldap_obj = self.api.Object[ldap_obj_name] @@ -1539,7 +1546,10 @@ class LDAPSearch(CallbackInterface, crud.Search): defattrs = self.obj.search_display_attributes else: defattrs = self.obj.default_attributes - if options.get('all', False): + + if options.get('pkey_only', False): + attrs_list = [self.obj.primary_key.name] + elif options.get('all', False): attrs_list = ['*'] + defattrs else: attrs_list = list( -- cgit