diff options
author | Martin Kosek <mkosek@redhat.com> | 2012-01-26 13:41:39 +0100 |
---|---|---|
committer | Endi S. Dewata <edewata@redhat.com> | 2012-01-26 10:17:39 -0600 |
commit | 0b9279a30a04de447b324eeb87e7a9e3b288bb1d (patch) | |
tree | ac2633d9c3c3e65908c56c883c1045f82c36032b /ipalib/plugins/baseldap.py | |
parent | 4277253b837f1485a900abee2b5fd0c246fa8d50 (diff) | |
download | freeipa.git-0b9279a30a04de447b324eeb87e7a9e3b288bb1d.tar.gz freeipa.git-0b9279a30a04de447b324eeb87e7a9e3b288bb1d.tar.xz freeipa.git-0b9279a30a04de447b324eeb87e7a9e3b288bb1d.zip |
Add missing managing hosts filtering options
Host object has a virtual attribute "managing" containing all hosts
it manages (governed by managedBy attribute). This patch also adds
standard membership filtering options:
--man-hosts=HOSTS: Only hosts managing _all_ HOSTS are returned
--not-man-hosts=HOSTS: Only hosts which do not manage _any_ host
in HOSTS are returned
https://fedorahosted.org/freeipa/ticket/1675
Diffstat (limited to 'ipalib/plugins/baseldap.py')
-rw-r--r-- | ipalib/plugins/baseldap.py | 50 |
1 files changed, 27 insertions, 23 deletions
diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py index 3d648045..f59a0d41 100644 --- a/ipalib/plugins/baseldap.py +++ b/ipalib/plugins/baseldap.py @@ -1595,6 +1595,31 @@ class LDAPSearch(BaseLDAPCommand, crud.Search): for arg in super(crud.Search, self).get_args(): yield arg + def get_member_options(self, attr): + for ldap_obj_name in self.obj.attribute_members[attr]: + ldap_obj = self.api.Object[ldap_obj_name] + relationship = self.obj.relationships.get( + attr, ['member', '', 'no_'] + ) + doc = self.member_param_incl_doc % ( + self.obj.object_name_plural, relationship[0].lower(), + ldap_obj.object_name_plural + ) + name = '%s%s' % (relationship[1], to_cli(ldap_obj_name)) + yield Str( + '%s*' % name, cli_name='%ss' % name, doc=doc, + label=ldap_obj.object_name, csv=True + ) + doc = self.member_param_excl_doc % ( + self.obj.object_name_plural, relationship[0].lower(), + ldap_obj.object_name_plural + ) + name = '%s%s' % (relationship[2], to_cli(ldap_obj_name)) + yield Str( + '%s*' % name, cli_name='%ss' % name, doc=doc, + label=ldap_obj.object_name, csv=True + ) + def get_options(self): for option in super(LDAPSearch, self).get_options(): yield option @@ -1602,29 +1627,8 @@ class LDAPSearch(BaseLDAPCommand, crud.Search): 'no_output' not in self.obj.primary_key.flags: yield gen_pkey_only_option(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] - relationship = self.obj.relationships.get( - attr, ['member', '', 'no_'] - ) - doc = self.member_param_incl_doc % ( - self.obj.object_name_plural, relationship[0].lower(), - ldap_obj.object_name_plural - ) - name = '%s%s' % (relationship[1], to_cli(ldap_obj_name)) - yield Str( - '%s*' % name, cli_name='%ss' % name, doc=doc, - label=ldap_obj.object_name, csv=True - ) - doc = self.member_param_excl_doc % ( - self.obj.object_name_plural, relationship[0].lower(), - ldap_obj.object_name_plural - ) - name = '%s%s' % (relationship[2], to_cli(ldap_obj_name)) - yield Str( - '%s*' % name, cli_name='%ss' % name, doc=doc, - label=ldap_obj.object_name, csv=True - ) + for option in self.get_member_options(attr): + yield option def get_member_filter(self, ldap, **options): filter = '' |