diff options
author | Rob Crittenden <rcritten@redhat.com> | 2010-11-04 15:19:14 -0400 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2010-11-08 15:23:41 -0500 |
commit | 537f4074d1606e9608773868ea630ca58effa61f (patch) | |
tree | 2144ef4df6a8d8eae4bf70becd79c25ece7d7489 /ipalib/plugins/netgroup.py | |
parent | a874d5f8e5b432f699362730a994e838594735ec (diff) | |
download | freeipa-537f4074d1606e9608773868ea630ca58effa61f.tar.gz freeipa-537f4074d1606e9608773868ea630ca58effa61f.tar.xz freeipa-537f4074d1606e9608773868ea630ca58effa61f.zip |
Add usercategory and hostcategory and fix displaying members in netgroup_show
ticket 443
Diffstat (limited to 'ipalib/plugins/netgroup.py')
-rw-r--r-- | ipalib/plugins/netgroup.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/ipalib/plugins/netgroup.py b/ipalib/plugins/netgroup.py index 199b4868a..e79aca2ad 100644 --- a/ipalib/plugins/netgroup.py +++ b/ipalib/plugins/netgroup.py @@ -42,8 +42,10 @@ EXAMPLES: """ from ipalib import api, errors +from ipalib import Str, StrEnum from ipalib.plugins.baseldap import * from ipalib import _, ngettext +from ipalib.plugins.hbac import is_all output_params = ( @@ -72,6 +74,7 @@ class netgroup(LDAPObject): default_attributes = [ 'cn', 'description', 'memberof', 'externalhost', 'nisdomainname', 'memberuser', 'memberhost', 'member', 'memberindirect', + 'usercategory', 'hostcategory', ] uuid_attribute = 'ipauniqueid' rdn_attribute = 'ipauniqueid' @@ -107,6 +110,18 @@ class netgroup(LDAPObject): doc=_('IPA unique ID'), flags=['no_create', 'no_update'], ), + StrEnum('usercategory?', + cli_name='usercat', + label=_('User category'), + doc=_('User category the rule applies to'), + values=(u'all', ), + ), + StrEnum('hostcategory?', + cli_name='hostcat', + label=_('Host category'), + doc=_('Host category the rule applies to'), + values=(u'all', ), + ), ) api.register(netgroup) @@ -141,6 +156,14 @@ class netgroup_mod(LDAPUpdate): has_output_params = LDAPUpdate.has_output_params + output_params msg_summary = _('Modified netgroup "%(value)s"') + def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options): + (dn, entry_attrs) = ldap.get_entry(dn, attrs_list) + if is_all(options, 'usercategory') and 'memberuser' in entry_attrs: + raise errors.MutuallyExclusiveError(reason="user category cannot be set to 'all' while there are allowed users") + if is_all(options, 'hostcategory') and 'memberhost' in entry_attrs: + raise errors.MutuallyExclusiveError(reason="host category cannot be set to 'all' while there are allowed hosts") + return dn + api.register(netgroup_mod) @@ -160,6 +183,7 @@ class netgroup_show(LDAPRetrieve): """ Display information about a netgroup. """ + has_output_params = LDAPRetrieve.has_output_params + output_params api.register(netgroup_show) |