summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Cholasta <jcholast@redhat.com>2013-10-31 16:55:07 +0000
committerPetr Viktorin <pviktori@redhat.com>2014-01-24 20:29:31 +0100
commit97c1c95f20762055932a83cb7ac08a408437a661 (patch)
tree45fe75881605384be220c4fab7d226f42d3077ce
parent08051f16516a3978494ae94032d55cc8b1426df9 (diff)
downloadfreeipa-97c1c95f20762055932a83cb7ac08a408437a661.zip
freeipa-97c1c95f20762055932a83cb7ac08a408437a661.tar.gz
freeipa-97c1c95f20762055932a83cb7ac08a408437a661.tar.xz
Convert remaining update code to LDAPEntry API.
-rw-r--r--ipaserver/install/plugins/adtrust.py4
-rw-r--r--ipaserver/install/plugins/dns.py2
-rw-r--r--ipaserver/install/plugins/fix_replica_agreements.py4
-rw-r--r--ipaserver/install/plugins/rename_managed.py10
-rw-r--r--ipaserver/install/plugins/update_anonymous_aci.py4
-rw-r--r--ipaserver/install/plugins/update_idranges.py16
-rw-r--r--ipaserver/install/plugins/update_services.py11
-rw-r--r--ipaserver/install/plugins/upload_cacrt.py2
8 files changed, 25 insertions, 28 deletions
diff --git a/ipaserver/install/plugins/adtrust.py b/ipaserver/install/plugins/adtrust.py
index 2835858..d567aea 100644
--- a/ipaserver/install/plugins/adtrust.py
+++ b/ipaserver/install/plugins/adtrust.py
@@ -46,7 +46,7 @@ class update_default_range(PostUpdate):
dn = DN(('cn', 'admins'), api.env.container_group, api.env.basedn)
try:
- (dn, admins_entry) = ldap.get_entry(dn, ['gidnumber'])
+ admins_entry = ldap.get_entry(dn, ['gidnumber'])
except errors.NotFound:
root_logger.error("default_range: No local ID range and no admins "
"group found. Cannot create default ID range")
@@ -88,7 +88,7 @@ class update_default_range(PostUpdate):
else:
masters = set()
remaining_values_sum = 0
- for entry_dn, entry in entries:
+ for entry in entries:
hostname = entry.get('dnahostname', [None])[0]
if hostname is None or hostname in masters:
continue
diff --git a/ipaserver/install/plugins/dns.py b/ipaserver/install/plugins/dns.py
index b875ff0..6e6c52f 100644
--- a/ipaserver/install/plugins/dns.py
+++ b/ipaserver/install/plugins/dns.py
@@ -160,7 +160,7 @@ class update_dns_limits(PostUpdate):
self.env.basedn)
try:
- (dn, entry) = ldap.get_entry(dns_service_dn, self.limit_attributes)
+ entry = ldap.get_entry(dns_service_dn, self.limit_attributes)
except errors.NotFound:
# this host may not have DNS service set
root_logger.debug("DNS: service %s not found, no need to update limits" % dns_service_dn)
diff --git a/ipaserver/install/plugins/fix_replica_agreements.py b/ipaserver/install/plugins/fix_replica_agreements.py
index bfd6356..a5ff481 100644
--- a/ipaserver/install/plugins/fix_replica_agreements.py
+++ b/ipaserver/install/plugins/fix_replica_agreements.py
@@ -89,7 +89,7 @@ class update_replica_attribute_lists(PreUpdate):
replica[attribute] = [template % " ".join(values)]
try:
- repl.conn.update_entry(replica.dn, replica)
+ repl.conn.update_entry(replica)
self.log.debug("Updated")
except Exception, e:
self.log.error("Error caught updating replica: %s", str(e))
@@ -107,7 +107,7 @@ class update_replica_attribute_lists(PreUpdate):
'%s %s' % (attrlist, ' '.join(missing))]
try:
- repl.conn.update_entry(replica.dn, replica)
+ repl.conn.update_entry(replica)
self.log.debug("Updated %s", attribute)
except Exception, e:
self.log.error("Error caught updating %s: %s",
diff --git a/ipaserver/install/plugins/rename_managed.py b/ipaserver/install/plugins/rename_managed.py
index dad9259..13e6dae 100644
--- a/ipaserver/install/plugins/rename_managed.py
+++ b/ipaserver/install/plugins/rename_managed.py
@@ -77,15 +77,15 @@ class GenerateUpdateMixin(object):
old_dn = entry['managedtemplate'][0]
assert isinstance(old_dn, DN)
try:
- (old_dn, entry) = ldap.get_entry(old_dn, ['*'])
+ entry = ldap.get_entry(old_dn, ['*'])
except errors.NotFound, e:
pass
else:
# Compute the new dn by replacing the old container with the new container
- new_dn = EditableDN(old_dn)
+ new_dn = EditableDN(entry.dn)
if new_dn.replace(old_template_container, new_template_container) != 1:
self.error("unable to replace '%s' with '%s' in '%s'",
- old_template_container, new_template_container, old_dn)
+ old_template_container, new_template_container, entry.dn)
continue
new_dn = DN(new_dn)
@@ -95,10 +95,10 @@ class GenerateUpdateMixin(object):
'default': entry_to_update(entry)}
# Delete the old entry
- old_update = {'dn': old_dn, 'deleteentry': None}
+ old_update = {'dn': entry.dn, 'deleteentry': None}
# Add the delete and replacement updates to the list of all updates
- update_list.append({old_dn: old_update, new_dn: new_update})
+ update_list.append({entry.dn: old_update, new_dn: new_update})
else:
# Update the template dn by replacing the old containter with the new container
diff --git a/ipaserver/install/plugins/update_anonymous_aci.py b/ipaserver/install/plugins/update_anonymous_aci.py
index 2e01217..0425754 100644
--- a/ipaserver/install/plugins/update_anonymous_aci.py
+++ b/ipaserver/install/plugins/update_anonymous_aci.py
@@ -38,7 +38,7 @@ class update_anonymous_aci(PostUpdate):
targetfilter = '(&(!(objectClass=ipaToken))(!(objectClass=ipatokenTOTP))(!(objectClass=ipatokenRadiusConfiguration)))'
filter = None
- (dn, entry_attrs) = ldap.get_entry(api.env.basedn, ['aci'])
+ entry_attrs = ldap.get_entry(api.env.basedn, ['aci'])
acistrs = entry_attrs.get('aci', [])
acilist = aci._convert_strings_to_acis(entry_attrs.get('aci', []))
@@ -87,7 +87,7 @@ class update_anonymous_aci(PostUpdate):
entry_attrs['aci'] = acistrs
try:
- ldap.update_entry(dn, entry_attrs)
+ ldap.update_entry(entry_attrs)
except Exception, e:
root_logger.error("Failed to update Anonymous ACI: %s" % e)
diff --git a/ipaserver/install/plugins/update_idranges.py b/ipaserver/install/plugins/update_idranges.py
index c3df98a..9e97c9f 100644
--- a/ipaserver/install/plugins/update_idranges.py
+++ b/ipaserver/install/plugins/update_idranges.py
@@ -71,27 +71,25 @@ class update_idrange_type(PostUpdate):
error = False
# Set the range type
- for dn, entry in entries:
- update = {}
-
+ for entry in entries:
objectclasses = [o.lower() for o
in entry.get('objectclass', [])]
if 'ipatrustedaddomainrange' in objectclasses:
# NOTICE: assumes every AD range does not use POSIX
# attributes
- update['ipaRangeType'] = 'ipa-ad-trust'
+ entry['ipaRangeType'] = ['ipa-ad-trust']
elif 'ipadomainidrange' in objectclasses:
- update['ipaRangeType'] = 'ipa-local'
+ entry['ipaRangeType'] = ['ipa-local']
else:
- update['ipaRangeType'] = 'unknown'
+ entry['ipaRangeType'] = ['unknown']
root_logger.error("update_idrange_type: could not detect "
- "range type for entry: %s" % str(dn))
+ "range type for entry: %s" % str(entry.dn))
root_logger.error("update_idrange_type: ID range type set "
- "to 'unknown' for entry: %s" % str(dn))
+ "to 'unknown' for entry: %s" % str(entry.dn))
try:
- ldap.update_entry(dn, update)
+ ldap.update_entry(entry)
except (errors.EmptyModlist, errors.NotFound):
pass
except errors.ExecutionError, e:
diff --git a/ipaserver/install/plugins/update_services.py b/ipaserver/install/plugins/update_services.py
index c384af5..2122abb 100644
--- a/ipaserver/install/plugins/update_services.py
+++ b/ipaserver/install/plugins/update_services.py
@@ -66,13 +66,12 @@ class update_service_principalalias(PostUpdate):
len(entries), truncated)
error = False
- for dn, entry in entries:
- update = {}
- update['objectclass'] = (entry['objectclass'] +
- ['ipakrbprincipal'])
- update['ipakrbprincipalalias'] = entry['krbprincipalname']
+ for entry in entries:
+ entry['objectclass'] = (entry['objectclass'] +
+ ['ipakrbprincipal'])
+ entry['ipakrbprincipalalias'] = entry['krbprincipalname']
try:
- ldap.update_entry(dn, update)
+ ldap.update_entry(entry)
except (errors.EmptyModlist, errors.NotFound):
pass
except errors.ExecutionError, e:
diff --git a/ipaserver/install/plugins/upload_cacrt.py b/ipaserver/install/plugins/upload_cacrt.py
index a82fc36..1da8e88 100644
--- a/ipaserver/install/plugins/upload_cacrt.py
+++ b/ipaserver/install/plugins/upload_cacrt.py
@@ -33,7 +33,7 @@ class update_upload_cacrt(PostUpdate):
def execute(self, **options):
ldap = self.obj.backend
- (cdn, ipa_config) = ldap.get_ipa_config()
+ ipa_config = ldap.get_ipa_config()
subject_base = ipa_config.get('ipacertificatesubjectbase', [None])[0]
dirname = config_dirname(realm_to_serverid(api.env.realm))
certdb = certs.CertDB(api.env.realm, nssdir=dirname, subject_base=subject_base)