diff options
author | Pavel Zuna <pzuna@redhat.com> | 2009-08-27 15:53:01 +0200 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2009-10-07 10:00:04 -0400 |
commit | cbbfd16e9f9775ae6579a262df4c771c9d7b3558 (patch) | |
tree | b6ce4be8561ce44ea713818c6db6ca3434d3d3b7 | |
parent | 8f29e416be42a23723f554f4db3420fbb36f2476 (diff) | |
download | freeipa-cbbfd16e9f9775ae6579a262df4c771c9d7b3558.tar.gz freeipa-cbbfd16e9f9775ae6579a262df4c771c9d7b3558.tar.xz freeipa-cbbfd16e9f9775ae6579a262df4c771c9d7b3558.zip |
Make the taskgroup plugin use baseldap classes.
-rw-r--r-- | ipalib/plugins/taskgroup.py | 175 |
1 files changed, 40 insertions, 135 deletions
diff --git a/ipalib/plugins/taskgroup.py b/ipalib/plugins/taskgroup.py index fcb928e98..be182f90d 100644 --- a/ipalib/plugins/taskgroup.py +++ b/ipalib/plugins/taskgroup.py @@ -17,27 +17,53 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - """ Taskgroups """ from ipalib import api -from ipalib.plugins.basegroup import * +from ipalib.plugins.baseldap import * -_container_dn = api.env.container_taskgroup -_default_attributes = ['cn', 'description', 'member', 'memberOf'] -class taskgroup(basegroup): +class taskgroup(LDAPObject): """ Taskgroup object. """ - container = _container_dn + container_dn = api.env.container_taskgroup + object_name = 'taskgroup' + object_name_plural = 'taskgroups' + object_class = ['ipaobject', 'groupofnames'] + default_attributes = ['cn', 'description', 'memberof'] + uuid_attribute = 'ipauniqueid' + attribute_names = { + 'cn': 'name', + 'member user': 'member users', + 'member group': 'member groups', + 'member rolegroup': 'member rolegroups', + # FIXME: 'memberof ???': 'member of ???' + } + attribute_members = { + 'member': ['user', 'group', 'rolegroup'], + # FIXME: taskgroup can be member of ??? + } + + takes_params = ( + Str('cn', + cli_name='name', + doc='taskgroup name', + primary_key=True, + normalizer=lambda value: value.lower(), + ), + Str('description', + cli_name='desc', + doc='taskgroup description', + ), + ) api.register(taskgroup) -class taskgroup_add(basegroup_add): +class taskgroup_add(LDAPCreate): """ Create new taskgroup. """ @@ -45,171 +71,50 @@ class taskgroup_add(basegroup_add): api.register(taskgroup_add) -class taskgroup_del(basegroup_del): +class taskgroup_del(LDAPDelete): """ Delete taskgroup. """ - container = _container_dn api.register(taskgroup_del) -class taskgroup_mod(basegroup_mod): +class taskgroup_mod(LDAPUpdate): """ - Edit taskgroup. + Modify taskgroup. """ - container = _container_dn api.register(taskgroup_mod) -class taskgroup_find(basegroup_find): +class taskgroup_find(LDAPSearch): """ Search for taskgroups. """ - container = _container_dn api.register(taskgroup_find) -class taskgroup_show(basegroup_show): +class taskgroup_show(LDAPRetrieve): """ Display taskgroup. """ - default_attributes = _default_attributes - container = _container_dn api.register(taskgroup_show) -class taskgroup_add_member(basegroup_add_member): +class taskgroup_add_member(LDAPAddMember): """ Add member to taskgroup. """ - container = _container_dn - takes_options = basegroup_add_member.takes_options + ( - List('rolegroups?', - cli_name='rolegroups', - doc='comma-separated list of role groups to add' - ), - ) - - def execute(self, cn, **kw): - """ - Execute the group-add-member operation. - - Returns the updated group entry - - :param cn: The group name to add new members to. - :param kw: groups is a comma-separated list of groups to add - :param kw: users is a comma-separated list of users to add - :param kw: rolegroups is a comma-separated list of rolegroups to add - """ - assert self.container - ldap = self.api.Backend.ldap2 - (dn, entry_attrs) = ldap.find_entry_by_attr( - 'cn', cn, self.filter_class, [''], self.container - ) - to_add = [] - add_failed = {} - completed = 0 - - members = kw.get('groups', []) - (to_add, add_failed) = find_members( - ldap, add_failed, members, 'cn', 'ipaUserGroup', - self.api.env.container_group - ) - (completed, add_failed) = add_members( - ldap, completed, to_add, add_failed, dn, 'member' - ) - - members = kw.get('hosts', []) - (to_add, add_failed) = find_members( - ldap, add_failed, members, 'cn', 'ipaHost', - self.api.env.container_host - ) - (completed, add_failed) = add_members( - ldap, completed, to_add, add_failed, dn, 'member' - ) - - members = kw.get('rolegroups', []) - (to_add, add_failed) = find_members( - ldap, add_failed, members, 'cn', self.filter_class, - self.api.env.container_rolegroup - ) - (completed, add_failed) = add_members( - ldap, completed, to_add, add_failed, dn, 'member' - ) - - return ( - completed, add_failed, ldap.get_entry(dn, _default_attributes) - ) api.register(taskgroup_add_member) -class taskgroup_remove_member(basegroup_remove_member): +class taskgroup_remove_member(LDAPRemoveMember): """ Remove member from taskgroup. """ - container = _container_dn - takes_options = basegroup_remove_member.takes_options + ( - List('rolegroups?', - cli_name='rolegroups', - doc='comma-separated list of role groups to remove' - ), - ) - - def execute(self, cn, **kw): - """ - Execute the group-remove-member operation. - - Returns the updated group entry - - :param cn: The group name to remove new members from. - :param kw: groups is a comma-separated list of groups to remove - :param kw: users is a comma-separated list of users to remove - :param kw: rolegroups is a comma-separated list of rolegroups to remove - """ - assert self.container - ldap = self.api.Backend.ldap2 - (dn, entry_attrs) = ldap.find_entry_by_attr( - 'cn', cn, self.filter_class, [''], self.container - ) - to_remove = [] - rem_failed = {} - completed = 0 - - members = kw.get('groups', []) - (to_remove, rem_failed) = find_members( - ldap, rem_failed, members, 'cn', 'ipaUserGroup', - self.api.env.container_group - ) - (completed, rem_failed) = del_members( - ldap, completed, to_remove, rem_failed, dn, 'member' - ) - - members = kw.get('hosts', []) - (to_remove, rem_failed) = find_members( - ldap, rem_failed, members, 'cn', 'ipaHost', - self.api.env.container_host - ) - (completed, rem_failed) = del_members( - ldap, completed, to_remove, rem_failed, dn, 'member' - ) - - members = kw.get('rolegroups', []) - (to_remove, rem_failed) = find_members( - ldap, rem_failed, members, 'cn', self.filter_class, - self.api.env.container_rolegroup - ) - (completed, rem_failed) = del_members( - ldap, completed, to_remove, rem_failed, dn, 'member' - ) - - return ( - completed, rem_failed, ldap.get_entry(dn, _default_attributes) - ) api.register(taskgroup_remove_member) |