summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Zuna <pzuna@redhat.com>2009-06-24 15:18:34 +0200
committerRob Crittenden <rcritten@redhat.com>2009-07-02 13:33:03 -0400
commit57123f2a9993be9e9ea83c1203f0670e67986de9 (patch)
tree295b2cc697f4d4eee150a9f647673a4df772141e
parent341a47f5a3786f96602bcc0c0ecd12aa86f5b9c1 (diff)
downloadfreeipa-57123f2a9993be9e9ea83c1203f0670e67986de9.tar.gz
freeipa-57123f2a9993be9e9ea83c1203f0670e67986de9.tar.xz
freeipa-57123f2a9993be9e9ea83c1203f0670e67986de9.zip
Fix minor bugs, typos, etc. discovered by unit tests in plugins.
-rw-r--r--ipalib/plugins/basegroup.py2
-rw-r--r--ipalib/plugins/baseldap.py6
-rw-r--r--ipalib/plugins/group.py17
-rw-r--r--ipalib/plugins/host.py10
-rw-r--r--ipalib/plugins/hostgroup.py12
-rw-r--r--ipalib/plugins/netgroup.py21
-rw-r--r--ipalib/plugins/service.py2
-rw-r--r--ipalib/plugins/taskgroup.py12
8 files changed, 51 insertions, 31 deletions
diff --git a/ipalib/plugins/basegroup.py b/ipalib/plugins/basegroup.py
index d0b0bd5f9..e4f784c72 100644
--- a/ipalib/plugins/basegroup.py
+++ b/ipalib/plugins/basegroup.py
@@ -238,7 +238,7 @@ class basegroup_mod(crud.Update):
ldap = self.api.Backend.ldap2
(dn, entry_attrs) = ldap.find_entry_by_attr(
- 'cn', cn, self.filter_class, [''], self.container_dn
+ 'cn', cn, self.filter_class, [''], self.container
)
entry_attrs = self.args_options_2_entry(cn, **kw)
diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py
index b7766cea7..d2270aefd 100644
--- a/ipalib/plugins/baseldap.py
+++ b/ipalib/plugins/baseldap.py
@@ -277,7 +277,7 @@ class LDAPDelete(crud.Delete):
None, [''], dn, ldap.SCOPE_ONELEVEL
)
except errors.NotFound:
- pass
+ break
else:
for (dn_, entry_attrs) in subentries:
ldap.delete_entry(dn_)
@@ -367,7 +367,7 @@ class LDAPSearch(crud.Search):
except errors.NotFound:
(entries, truncated) = (tuple(), False)
- self.post_callback(self, ldap, entries, *args, **options)
+ self.post_callback(self, ldap, entries, truncated, *args, **options)
return (entries, truncated)
@@ -393,6 +393,6 @@ class LDAPSearch(crud.Search):
def pre_callback(self, ldap, filter, attrs_list, base_dn, *args, **options):
return filter
- def post_callback(self, ldap, entries, *args, **options):
+ def post_callback(self, ldap, entries, truncated, *args, **options):
pass
diff --git a/ipalib/plugins/group.py b/ipalib/plugins/group.py
index 1a5e0ef6f..db2462d15 100644
--- a/ipalib/plugins/group.py
+++ b/ipalib/plugins/group.py
@@ -105,14 +105,16 @@ class group_del(basegroup_del):
:param kw: Unused
"""
ldap = self.api.Backend.ldap2
- dn = get_dn_by_attr(ldap, 'cn', cn, self.filter_class, self.container)
+ (dn, entry_attrs) = ldap.find_entry_by_attr(
+ 'cn', cn, self.filter_class, [''], self.container
+ )
# Don't allow the default user group to be removed
try:
config = ldap.get_ipa_config()[1]
def_group_cn = config.get('ipadefaultprimarygroup')
- def_group_dn = get_dn_by_attr(
- ldap, 'cn', def_group_cn, self.filter_class, self.container
+ (def_group_dn, entry_attrs) = ldap.find_entry_by_attr(
+ 'cn', def_group_cn, self.filter_class, [''], self.container
)
if dn == def_group_dn:
raise errors.DefaultGroup()
@@ -154,8 +156,9 @@ class group_mod(basegroup_mod):
ldap = self.api.Backend.ldap2
if kw['posix'] or 'gidnumber' in kw:
- dn = get_dn_by_attr(ldap, 'cn', cn, self.filter_class, self.container)
- (dn, entry_attrs) = ldap.get_entry(dn, ['objectclass'])
+ (dn, entry_attrs) = ldap.find_entry_by_attr(
+ 'cn', cn, self.filter_class, ['objectclass'], self.container
+ )
if 'posixgroup' in entry_attrs['objectclass']:
if kw['posix'] in entry_attrs['objectclass']:
raise errors.AlreadyPosixGroup()
@@ -176,8 +179,8 @@ class group_find(basegroup_find):
container = _container_dn
filter_class = _default_class
- def execute(self, cn, **kw):
- return super(group_find, self).execute(cn, **kw)
+ def execute(self, term, **kw):
+ return super(group_find, self).execute(term, **kw)
api.register(group_find)
diff --git a/ipalib/plugins/host.py b/ipalib/plugins/host.py
index 9d8df1dbf..472f82626 100644
--- a/ipalib/plugins/host.py
+++ b/ipalib/plugins/host.py
@@ -212,10 +212,10 @@ class host_del(crud.Delete):
dn = get_host(ldap, hostname)
# Remove all service records for this host
- services = api.Command['service2_find'](hostname)
+ (services, truncated) = api.Command['service_find'](hostname)
for (dn, entry_attrs) in services:
principal = entry_attrs['krbprincipalname']
- api.Command['service2_del'](principal)
+ api.Command['service_del'](principal)
ldap.delete_entry(dn)
@@ -298,6 +298,10 @@ class host_find(crud.Search):
search_kw[a] = term
term_filter = ldap.make_filter(search_kw, exact=False)
+ filter = ldap.combine_filters(
+ (filter, term_filter), rules=ldap.MATCH_ALL
+ )
+
if kw['all']:
attrs_list = ['*']
else:
@@ -310,7 +314,7 @@ class host_find(crud.Search):
except errors.NotFound:
(entries, truncated) = (tuple(), False)
- return entries
+ return (entries, truncated)
def output_for_cli(self, textui, result, term, **options):
(entries, truncated) = result
diff --git a/ipalib/plugins/hostgroup.py b/ipalib/plugins/hostgroup.py
index f2966e3c1..272d5720d 100644
--- a/ipalib/plugins/hostgroup.py
+++ b/ipalib/plugins/hostgroup.py
@@ -80,8 +80,8 @@ class hostgroup_find(basegroup_find):
"""
container = _container_dn
- def execute(self, cn, **kw):
- return super(hostgroup_find, self).execute(cn, **kw)
+ def execute(self, term, **kw):
+ return super(hostgroup_find, self).execute(term, **kw)
api.register(hostgroup_find)
@@ -132,7 +132,9 @@ class hostgroup_add_member(basegroup_add_member):
"""
assert self.container
ldap = self.api.Backend.ldap2
- dn = get_dn_by_attr(ldap, 'cn', cn, self.filter_class, self.container)
+ (dn, entry_attrs) = ldap.find_entry_by_attr(
+ 'cn', cn, self.filter_class, [''], self.container
+ )
to_add = []
add_failed = []
completed = 0
@@ -202,7 +204,9 @@ class hostgroup_del_member(basegroup_del_member):
"""
assert self.container
ldap = self.api.Backend.ldap2
- dn = get_dn_by_attr(ldap, 'cn', cn, self.filter_class, self.container)
+ (dn, entry_attrs) = ldap.find_entry_by_attr(
+ 'cn', cn, self.filter_class, [''], self.container
+ )
to_remove = []
remove_failed = []
completed = 0
diff --git a/ipalib/plugins/netgroup.py b/ipalib/plugins/netgroup.py
index 28b275956..a80913d08 100644
--- a/ipalib/plugins/netgroup.py
+++ b/ipalib/plugins/netgroup.py
@@ -115,8 +115,8 @@ class netgroup_find(basegroup_find):
container = _container_dn
filter_class = _default_class
- def execute(self, cn, **kw):
- return super(netgroup_find, self).execute(cn, **kw)
+ def execute(self, term, **kw):
+ return super(netgroup_find, self).execute(term, **kw)
api.register(netgroup_find)
@@ -160,7 +160,7 @@ class netgroup_add_member(basegroup_add_member):
def _add_external(self, ldap, completed, members, group_dn):
add_failed = []
- entry_attrs = ldap.get_entry(group_dn, ['externalhost'])
+ (dn, entry_attrs) = ldap.get_entry(group_dn, ['externalhost'])
external_hosts = entry_attrs.get('externalhost', [])
for m in members:
@@ -172,7 +172,7 @@ class netgroup_add_member(basegroup_add_member):
add_failed.append(m)
try:
- ldap.update_entry(group_dn, **{'externalhost': external_hosts})
+ ldap.update_entry(group_dn, {'externalhost': external_hosts})
except errors.EmptyModlist:
pass
@@ -192,7 +192,9 @@ class netgroup_add_member(basegroup_add_member):
"""
assert self.container
ldap = self.api.Backend.ldap2
- dn = get_dn_by_attr(ldap, 'cn', cn, self.filter_class, self.container)
+ (dn, entry_attrs) = ldap.find_entry_by_attr(
+ 'cn', cn, self.filter_class, [''], self.container
+ )
to_add = []
add_failed = []
completed = 0
@@ -215,6 +217,7 @@ class netgroup_add_member(basegroup_add_member):
ldap, completed, to_add, add_failed, dn, 'member'
)
+ add_failed = []
members = kw.get('hosts', [])
(to_add, add_failed) = find_members(
ldap, add_failed, members, 'cn', 'ipahost',
@@ -278,7 +281,7 @@ class netgroup_del_member(basegroup_del_member):
def _del_external(self, ldap, completed, members, group_dn):
rem_failed = []
- entry_attrs = ldap.get_entry(group_dn, ['externalhost'])
+ (dn, entry_attrs) = ldap.get_entry(group_dn, ['externalhost'])
external_hosts = entry_attrs.get('externalhost', [])
for m in members:
@@ -290,7 +293,7 @@ class netgroup_del_member(basegroup_del_member):
rem_failed.append(m)
try:
- ldap.update_entry(group_dn, **{'externalhost': external_hosts})
+ ldap.update_entry(group_dn, {'externalhost': external_hosts})
except errors.EmptyModlist:
pass
@@ -310,7 +313,9 @@ class netgroup_del_member(basegroup_del_member):
"""
assert self.container
ldap = self.api.Backend.ldap2
- dn = get_dn_by_attr(ldap, 'cn', cn, self.filter_class, self.container)
+ (dn, entry_attrs) = ldap.find_entry_by_attr(
+ 'cn', cn, self.filter_class, [''], self.container
+ )
to_rem = []
rem_failed = []
completed = 0
diff --git a/ipalib/plugins/service.py b/ipalib/plugins/service.py
index 81d71ee47..2f42a2b70 100644
--- a/ipalib/plugins/service.py
+++ b/ipalib/plugins/service.py
@@ -294,7 +294,7 @@ class service_find(crud.Search):
except errors.NotFound:
(entries, truncated) = (tuple(), False)
- return entries
+ return (entries, truncated)
def output_for_cli(self, textui, result, principal, **options):
(entries, truncated) = result
diff --git a/ipalib/plugins/taskgroup.py b/ipalib/plugins/taskgroup.py
index d22ac8229..380f18618 100644
--- a/ipalib/plugins/taskgroup.py
+++ b/ipalib/plugins/taskgroup.py
@@ -107,7 +107,9 @@ class taskgroup_add_member(basegroup_add_member):
"""
assert self.container
ldap = self.api.Backend.ldap2
- dn = get_dn_by_attr(ldap, 'cn', cn, self.filter_class, self.container)
+ (dn, entry_attrs) = ldap.find_entry_by_attr(
+ 'cn', cn, self.filter_class, [''], self.container
+ )
to_add = []
add_failed = []
completed = 0
@@ -133,7 +135,7 @@ class taskgroup_add_member(basegroup_add_member):
members = kw.get('rolegroups', [])
(to_add, add_failed) = find_members(
ldap, add_failed, members, 'cn', self.filter_class,
- self.api.env.container_rolegroups
+ self.api.env.container_rolegroup
)
(completed, add_failed) = add_members(
ldap, completed, to_add, add_failed, dn, 'member'
@@ -169,7 +171,9 @@ class taskgroup_del_member(basegroup_del_member):
"""
assert self.container
ldap = self.api.Backend.ldap2
- dn = get_dn_by_attr(ldap, 'cn', cn, self.filter_class, self.container)
+ (dn, entry_attrs) = ldap.find_entry_by_attr(
+ 'cn', cn, self.filter_class, [''], self.container
+ )
to_remove = []
remove_failed = []
completed = 0
@@ -195,7 +199,7 @@ class taskgroup_del_member(basegroup_del_member):
members = kw.get('rolegroups', [])
(to_remove, remove_failed) = find_members(
ldap, remove_failed, members, 'cn', self.filter_class,
- self.api.env.container_rolegroups
+ self.api.env.container_rolegroup
)
(completed, remove_failed) = del_members(
ldap, completed, to_remove, remove_failed, dn, 'member'