summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2013-01-31 09:02:01 -0500
committerMartin Kosek <mkosek@redhat.com>2013-03-13 12:36:34 +0100
commitcf4b52111d384e8baa250aefe57f21ebda4dad7e (patch)
tree4069d1af85b0a8dd91f57e13bb95aad841d8521c
parent664248d5b846321f61e0776b646cca82c5a17884 (diff)
downloadfreeipa-cf4b52111d384e8baa250aefe57f21ebda4dad7e.tar.gz
freeipa-cf4b52111d384e8baa250aefe57f21ebda4dad7e.tar.xz
freeipa-cf4b52111d384e8baa250aefe57f21ebda4dad7e.zip
Remove unneeded python-ldap imports
Part of the work for: https://fedorahosted.org/freeipa/ticket/2660
-rw-r--r--ipa-client/ipaclient/ipadiscovery.py2
-rw-r--r--ipalib/plugins/automount.py8
-rw-r--r--ipalib/plugins/migration.py11
-rw-r--r--tests/test_install/test_updates.py38
4 files changed, 28 insertions, 31 deletions
diff --git a/ipa-client/ipaclient/ipadiscovery.py b/ipa-client/ipaclient/ipadiscovery.py
index d62430be4..2259b7de0 100644
--- a/ipa-client/ipaclient/ipadiscovery.py
+++ b/ipa-client/ipaclient/ipadiscovery.py
@@ -20,8 +20,6 @@
import socket
import os
import tempfile
-import ldap
-from ldap import LDAPError
from ipapython.ipa_log_manager import root_logger
from dns import resolver, rdatatype
diff --git a/ipalib/plugins/automount.py b/ipalib/plugins/automount.py
index 22017fb57..a7596b475 100644
--- a/ipalib/plugins/automount.py
+++ b/ipalib/plugins/automount.py
@@ -18,13 +18,13 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+import os
+
from ipalib import api, errors
from ipalib import Object, Command
from ipalib import Flag, Str, IA5Str
from ipalib.plugins.baseldap import *
from ipalib import _, ngettext
-import ldap as _ldap
-import os
__doc__ = _("""
Automount
@@ -726,8 +726,8 @@ class automountkey(LDAPObject):
('cn', parent_keys[0]), self.container_dn,
api.env.basedn)
attrs_list = ['*']
- (entries, truncated) = ldap.find_entries(sfilter, attrs_list,
- basedn, _ldap.SCOPE_ONELEVEL)
+ entries, truncated = ldap.find_entries(
+ sfilter, attrs_list, basedn, ldap.SCOPE_ONELEVEL)
if len(entries) > 1:
raise errors.NotFound(reason=_('More than one entry with key %(key)s found, use --info to select specific entry.') % dict(key=pkey))
if truncated:
diff --git a/ipalib/plugins/migration.py b/ipalib/plugins/migration.py
index 7884e08cf..f57f0957e 100644
--- a/ipalib/plugins/migration.py
+++ b/ipalib/plugins/migration.py
@@ -18,7 +18,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import re
-import ldap as _ldap
from ipalib import api, errors, output
from ipalib import Command, Password, Str, Flag, StrEnum, DNParam
@@ -286,7 +285,7 @@ def _update_default_group(ldap, pkey, config, ctx, force):
searchfilter = "(&(objectclass=posixAccount)(!(memberof=%s)))" % group_dn
try:
(result, truncated) = ldap.find_entries(searchfilter,
- [''], api.env.container_user, scope=_ldap.SCOPE_SUBTREE,
+ [''], api.env.container_user, scope=ldap.SCOPE_SUBTREE,
time_limit = -1)
except errors.NotFound:
return
@@ -701,9 +700,9 @@ can use their Kerberos accounts.''')
failed[ldap_obj_name] = {}
try:
- (entries, truncated) = ds_ldap.find_entries(
+ entries, truncated = ds_ldap.find_entries(
search_filter, ['*'], search_bases[ldap_obj_name],
- _ldap.SCOPE_ONELEVEL,
+ ds_ldap.SCOPE_ONELEVEL,
time_limit=0, size_limit=-1,
search_refs=True # migrated DS may contain search references
)
@@ -872,9 +871,9 @@ can use their Kerberos accounts.''')
if not ds_base_dn:
# retrieve base DN from remote LDAP server
- (entries, truncated) = ds_ldap.find_entries(
+ entries, truncated = ds_ldap.find_entries(
'', ['namingcontexts', 'defaultnamingcontext'], DN(''),
- _ldap.SCOPE_BASE, size_limit=-1, time_limit=0,
+ ds_ldap.SCOPE_BASE, size_limit=-1, time_limit=0,
)
if 'defaultnamingcontext' in entries[0][1]:
ds_base_dn = DN(entries[0][1]['defaultnamingcontext'][0])
diff --git a/tests/test_install/test_updates.py b/tests/test_install/test_updates.py
index ffd6ee6d0..b974aa397 100644
--- a/tests/test_install/test_updates.py
+++ b/tests/test_install/test_updates.py
@@ -22,9 +22,9 @@ Test the `ipaserver/install/ldapupdate.py` module.
import unittest
import os
-import ldap
import nose
+
from ipalib import api
from ipalib import errors
from ipaserver.install.ldapupdate import LDAPUpdate, BadSyntax
@@ -89,11 +89,11 @@ class test_update(unittest.TestCase):
with self.assertRaises(errors.NotFound):
entries = self.ld.get_entries(
- self.container_dn, ldap.SCOPE_BASE, 'objectclass=*', ['*'])
+ self.container_dn, self.ld.SCOPE_BASE, 'objectclass=*', ['*'])
with self.assertRaises(errors.NotFound):
entries = self.ld.get_entries(
- self.user_dn, ldap.SCOPE_BASE, 'objectclass=*', ['*'])
+ self.user_dn, self.ld.SCOPE_BASE, 'objectclass=*', ['*'])
def test_1_add(self):
"""
@@ -104,7 +104,7 @@ class test_update(unittest.TestCase):
self.assertTrue(modified)
entries = self.ld.get_entries(
- self.container_dn, ldap.SCOPE_BASE, 'objectclass=*', ['*'])
+ self.container_dn, self.ld.SCOPE_BASE, 'objectclass=*', ['*'])
self.assertEqual(len(entries), 1)
entry = entries[0]
@@ -115,7 +115,7 @@ class test_update(unittest.TestCase):
self.assertEqual(entry.single_value('cn'), 'test')
entries = self.ld.get_entries(
- self.user_dn, ldap.SCOPE_BASE, 'objectclass=*', ['*'])
+ self.user_dn, self.ld.SCOPE_BASE, 'objectclass=*', ['*'])
self.assertEqual(len(entries), 1)
entry = entries[0]
@@ -137,7 +137,7 @@ class test_update(unittest.TestCase):
self.assertTrue(modified)
entries = self.ld.get_entries(
- self.user_dn, ldap.SCOPE_BASE, 'objectclass=*', ['*'])
+ self.user_dn, self.ld.SCOPE_BASE, 'objectclass=*', ['*'])
self.assertEqual(len(entries), 1)
entry = entries[0]
self.assertEqual(entry.single_value('gecos'), 'Test User')
@@ -150,7 +150,7 @@ class test_update(unittest.TestCase):
self.assertTrue(modified)
entries = self.ld.get_entries(
- self.user_dn, ldap.SCOPE_BASE, 'objectclass=*', ['*'])
+ self.user_dn, self.ld.SCOPE_BASE, 'objectclass=*', ['*'])
self.assertEqual(len(entries), 1)
entry = entries[0]
self.assertEqual(entry.single_value('gecos'), 'Test User New')
@@ -163,7 +163,7 @@ class test_update(unittest.TestCase):
self.assertTrue(modified)
entries = self.ld.get_entries(
- self.user_dn, ldap.SCOPE_BASE, 'objectclass=*', ['*'])
+ self.user_dn, self.ld.SCOPE_BASE, 'objectclass=*', ['*'])
self.assertEqual(len(entries), 1)
entry = entries[0]
self.assertEqual(entry.single_value('gecos'), 'Test User New2')
@@ -176,7 +176,7 @@ class test_update(unittest.TestCase):
self.assertTrue(modified)
entries = self.ld.get_entries(
- self.user_dn, ldap.SCOPE_BASE, 'objectclass=*', ['*'])
+ self.user_dn, self.ld.SCOPE_BASE, 'objectclass=*', ['*'])
self.assertEqual(len(entries), 1)
entry = entries[0]
self.assertEqual(sorted(entry.get('cn')), sorted(['Test User', 'Test User New']))
@@ -189,7 +189,7 @@ class test_update(unittest.TestCase):
self.assertTrue(modified)
entries = self.ld.get_entries(
- self.user_dn, ldap.SCOPE_BASE, 'objectclass=*', ['*'])
+ self.user_dn, self.ld.SCOPE_BASE, 'objectclass=*', ['*'])
self.assertEqual(len(entries), 1)
entry = entries[0]
self.assertEqual(sorted(entry.get('cn')), sorted(['Test User']))
@@ -202,7 +202,7 @@ class test_update(unittest.TestCase):
self.assertFalse(modified)
entries = self.ld.get_entries(
- self.user_dn, ldap.SCOPE_BASE, 'objectclass=*', ['*'])
+ self.user_dn, self.ld.SCOPE_BASE, 'objectclass=*', ['*'])
self.assertEqual(len(entries), 1)
entry = entries[0]
self.assertEqual(sorted(entry.get('cn')), sorted(['Test User']))
@@ -221,11 +221,11 @@ class test_update(unittest.TestCase):
with self.assertRaises(errors.NotFound):
entries = self.ld.get_entries(
- self.container_dn, ldap.SCOPE_BASE, 'objectclass=*', ['*'])
+ self.container_dn, self.ld.SCOPE_BASE, 'objectclass=*', ['*'])
with self.assertRaises(errors.NotFound):
entries = self.ld.get_entries(
- self.user_dn, ldap.SCOPE_BASE, 'objectclass=*', ['*'])
+ self.user_dn, self.ld.SCOPE_BASE, 'objectclass=*', ['*'])
def test_8_badsyntax(self):
"""
@@ -251,11 +251,11 @@ class test_update(unittest.TestCase):
# First make sure we're clean
with self.assertRaises(errors.NotFound):
entries = self.ld.get_entries(
- self.container_dn, ldap.SCOPE_BASE, 'objectclass=*', ['*'])
+ self.container_dn, self.ld.SCOPE_BASE, 'objectclass=*', ['*'])
with self.assertRaises(errors.NotFound):
entries = self.ld.get_entries(
- self.user_dn, ldap.SCOPE_BASE, 'objectclass=*', ['*'])
+ self.user_dn, self.ld.SCOPE_BASE, 'objectclass=*', ['*'])
update = {
@@ -288,7 +288,7 @@ class test_update(unittest.TestCase):
self.assertTrue(modified)
entries = self.ld.get_entries(
- self.container_dn, ldap.SCOPE_BASE, 'objectclass=*', ['*'])
+ self.container_dn, self.ld.SCOPE_BASE, 'objectclass=*', ['*'])
self.assertEqual(len(entries), 1)
entry = entries[0]
@@ -299,7 +299,7 @@ class test_update(unittest.TestCase):
self.assertEqual(entry.single_value('cn'), 'test')
entries = self.ld.get_entries(
- self.user_dn, ldap.SCOPE_BASE, 'objectclass=*', ['*'])
+ self.user_dn, self.ld.SCOPE_BASE, 'objectclass=*', ['*'])
self.assertEqual(len(entries), 1)
entry = entries[0]
@@ -330,8 +330,8 @@ class test_update(unittest.TestCase):
with self.assertRaises(errors.NotFound):
entries = self.ld.get_entries(
- self.container_dn, ldap.SCOPE_BASE, 'objectclass=*', ['*'])
+ self.container_dn, self.ld.SCOPE_BASE, 'objectclass=*', ['*'])
with self.assertRaises(errors.NotFound):
entries = self.ld.get_entries(
- self.user_dn, ldap.SCOPE_BASE, 'objectclass=*', ['*'])
+ self.user_dn, self.ld.SCOPE_BASE, 'objectclass=*', ['*'])