diff options
author | Martin Kosek <mkosek@redhat.com> | 2011-10-26 11:12:38 +0200 |
---|---|---|
committer | Endi S. Dewata <edewata@redhat.com> | 2011-10-27 14:17:51 +0000 |
commit | a486f49a3726934f99763cc6ae93a41dafc40deb (patch) | |
tree | 23063e2a18b0fa2ff0a6aeafaee22d642cb759f6 /ipalib/plugins/baseldap.py | |
parent | 52981883aba2a2ce7a0152c50ad94201f327f411 (diff) | |
download | freeipa-a486f49a3726934f99763cc6ae93a41dafc40deb.tar.gz freeipa-a486f49a3726934f99763cc6ae93a41dafc40deb.tar.xz freeipa-a486f49a3726934f99763cc6ae93a41dafc40deb.zip |
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
Diffstat (limited to 'ipalib/plugins/baseldap.py')
-rw-r--r-- | ipalib/plugins/baseldap.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py index 20f23c2e0..88f312998 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( |