mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-23 15:40:01 -06:00
Convert remaining update code to LDAPEntry API.
This commit is contained in:
parent
08051f1651
commit
97c1c95f20
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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",
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user