diff options
author | Rob Crittenden <rcritten@redhat.com> | 2009-02-18 16:38:30 -0500 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2009-02-19 10:07:39 -0500 |
commit | fb3f86f7037fff463b8b54e50f6bccaaffb5373c (patch) | |
tree | 6bf5483b82b0a6a7228855202bbd1eae847864dd /ipalib | |
parent | 5ce463104161d4400f891d898f322959bf48c3c8 (diff) | |
download | freeipa-fb3f86f7037fff463b8b54e50f6bccaaffb5373c.tar.gz freeipa-fb3f86f7037fff463b8b54e50f6bccaaffb5373c.tar.xz freeipa-fb3f86f7037fff463b8b54e50f6bccaaffb5373c.zip |
Add --all option to show/find, add default attrs to show, cleanup output
Diffstat (limited to 'ipalib')
-rw-r--r-- | ipalib/plugins/f_group.py | 31 | ||||
-rw-r--r-- | ipalib/plugins/f_host.py | 1 | ||||
-rw-r--r-- | ipalib/plugins/f_service.py | 20 |
3 files changed, 32 insertions, 20 deletions
diff --git a/ipalib/plugins/f_group.py b/ipalib/plugins/f_group.py index 99a8e1324..b172f513e 100644 --- a/ipalib/plugins/f_group.py +++ b/ipalib/plugins/f_group.py @@ -23,7 +23,7 @@ Frontend plugins for group (Identity). from ipalib import api, crud, errors, errors2 from ipalib import Object, Command # Plugin base classes -from ipalib import Str, Int # Parameter types +from ipalib import Str, Int, Flag # Parameter types def get_members(members): @@ -39,6 +39,8 @@ def get_members(members): return members +default_attributes = ['cn','description','gidnumber', 'member'] + class group(Object): """ Group object. @@ -213,6 +215,9 @@ api.register(group_find) class group_show(crud.Get): 'Examine an existing group.' + takes_options = ( + Flag('all', doc='Retrieve all attributes'), + ) def execute(self, cn, **kw): """ Execute the group-show operation. @@ -227,27 +232,15 @@ class group_show(crud.Get): """ ldap = self.api.Backend.ldap dn = ldap.find_entry_dn("cn", cn, "posixGroup") + # FIXME: should kw contain the list of attributes to display? - return ldap.retrieve(dn) + if kw.get('all', False): + return ldap.retrieve(dn) + else: + return ldap.retrieve(dn, default_attributes) def output_for_cli(self, textui, result, *args, **options): - counter = result[0] - groups = result[1:] - if counter == 0 or len(groups) == 0: - textui.print_plain("No entries found") - return - if len(groups) == 1: - textui.print_entry(groups[0]) - return - textui.print_name(self.name) - for u in groups: - textui.print_plain('%(givenname)s %(sn)s:' % u) - textui.print_entry(u) - textui.print_plain('') - if counter == -1: - textui.print_plain('These results are truncated.') - textui.print_plain('Please refine your search and try again.') - textui.print_count(groups, '%d groups matched') + textui.print_entry(result) api.register(group_show) diff --git a/ipalib/plugins/f_host.py b/ipalib/plugins/f_host.py index 17bec9774..33cc98f4c 100644 --- a/ipalib/plugins/f_host.py +++ b/ipalib/plugins/f_host.py @@ -139,6 +139,7 @@ class host_add(crud.Add): if 'krbprincipalaux' not in kw.get('objectclass'): kw['objectclass'].append('krbprincipalaux') + kw['objectclass'].append('krbprincipal') else: if 'krbprincipalaux' in kw.get('objectclass'): kw['objectclass'].remove('krbprincipalaux') diff --git a/ipalib/plugins/f_service.py b/ipalib/plugins/f_service.py index 99446b598..918eef903 100644 --- a/ipalib/plugins/f_service.py +++ b/ipalib/plugins/f_service.py @@ -26,6 +26,7 @@ from ipalib import api, crud, errors2 from ipalib import Object # Plugin base classes from ipalib import Str, Flag # Parameter types +default_attributes = ['krbprincipalname'] class service(Object): """ @@ -149,6 +150,9 @@ api.register(service_del) class service_find(crud.Find): 'Search the existing services.' + takes_options = ( + Flag('all', doc='Retrieve all attributes'), + ) def execute(self, principal, **kw): ldap = self.api.Backend.ldap @@ -160,6 +164,11 @@ class service_find(crud.Find): if object_type and not kw.get('objectclass'): search_kw['objectclass'] = object_type + if kw.get('all', False): + search_kw['attributes'] = ['*'] + else: + search_kw['attributes'] = default_attributes + return ldap.search(**search_kw) def output_for_cli(self, textui, result, *args, **options): @@ -182,6 +191,9 @@ api.register(service_find) class service_show(crud.Get): 'Examine an existing service.' + takes_options = ( + Flag('all', doc='Display all service attributes'), + ) def execute(self, principal, **kw): """ Execute the service-show operation. @@ -197,7 +209,13 @@ class service_show(crud.Get): ldap = self.api.Backend.ldap dn = ldap.find_entry_dn("krbprincipalname", principal) # FIXME: should kw contain the list of attributes to display? - return ldap.retrieve(dn) + if kw.get('all', False): + return ldap.retrieve(dn) + else: + value = ldap.retrieve(dn, default_attributes) + del value['dn'] + return value + def output_for_cli(self, textui, result, *args, **options): textui.print_entry(result) |