mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-23 15:40:01 -06:00
Use api.env.container_masters
Replace occurences of ('cn', 'masters'), ('cn', 'ipa'), ('cn', 'etc') with api.env.container_masters. Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
This commit is contained in:
parent
52e5ef81a5
commit
d76dccc0b6
@ -898,8 +898,7 @@ class BindInstance(service.Service):
|
||||
|
||||
def __add_others(self):
|
||||
entries = api.Backend.ldap2.get_entries(
|
||||
DN(('cn', 'masters'), ('cn', 'ipa'), ('cn', 'etc'),
|
||||
self.suffix),
|
||||
DN(api.env.container_masters, self.suffix),
|
||||
api.Backend.ldap2.SCOPE_ONELEVEL, None, ['dn'])
|
||||
|
||||
for entry in entries:
|
||||
|
@ -1167,8 +1167,8 @@ class CAInstance(DogtagInstance):
|
||||
if fqdn is None:
|
||||
fqdn = api.env.host
|
||||
|
||||
dn = DN(('cn', 'CA'), ('cn', fqdn), ('cn', 'masters'), ('cn', 'ipa'),
|
||||
('cn', 'etc'), api.env.basedn)
|
||||
dn = DN(('cn', 'CA'), ('cn', fqdn), api.env.container_masters,
|
||||
api.env.basedn)
|
||||
renewal_filter = '(ipaConfigString=caRenewalMaster)'
|
||||
try:
|
||||
api.Backend.ldap2.get_entries(base_dn=dn, filter=renewal_filter,
|
||||
@ -1182,8 +1182,7 @@ class CAInstance(DogtagInstance):
|
||||
if fqdn is None:
|
||||
fqdn = api.env.host
|
||||
|
||||
base_dn = DN(('cn', 'masters'), ('cn', 'ipa'), ('cn', 'etc'),
|
||||
api.env.basedn)
|
||||
base_dn = DN(api.env.container_masters, api.env.basedn)
|
||||
filter = '(&(cn=CA)(ipaConfigString=caRenewalMaster))'
|
||||
try:
|
||||
entries = api.Backend.ldap2.get_entries(
|
||||
|
@ -98,8 +98,8 @@ def _disable_dnssec():
|
||||
api.env.basedn)
|
||||
|
||||
conn = api.Backend.ldap2
|
||||
dn = DN(('cn', 'DNSSEC'), ('cn', api.env.host), ('cn', 'masters'),
|
||||
('cn', 'ipa'), ('cn', 'etc'), api.env.basedn)
|
||||
dn = DN(('cn', 'DNSSEC'), ('cn', api.env.host),
|
||||
api.env.container_masters, api.env.basedn)
|
||||
try:
|
||||
entry = conn.get_entry(dn)
|
||||
except errors.NotFound:
|
||||
|
@ -583,7 +583,8 @@ class Backup(admintool.AdminTool):
|
||||
config.set('ipa', 'ipa_version', str(version.VERSION))
|
||||
config.set('ipa', 'version', '1')
|
||||
|
||||
dn = DN(('cn', api.env.host), ('cn', 'masters'), ('cn', 'ipa'), ('cn', 'etc'), api.env.basedn)
|
||||
dn = DN(('cn', api.env.host), api.env.container_masters,
|
||||
api.env.basedn)
|
||||
services_cns = []
|
||||
try:
|
||||
conn = self.get_connection()
|
||||
|
@ -519,7 +519,8 @@ class Restore(admintool.AdminTool):
|
||||
master, e)
|
||||
continue
|
||||
|
||||
master_dn = DN(('cn', master), ('cn', 'masters'), ('cn', 'ipa'), ('cn', 'etc'), api.env.basedn)
|
||||
master_dn = DN(('cn', master), api.env.container_masters,
|
||||
api.env.basedn)
|
||||
try:
|
||||
services = repl.conn.get_entries(master_dn,
|
||||
repl.conn.SCOPE_ONELEVEL)
|
||||
|
@ -486,11 +486,7 @@ class KrbInstance(service.Service):
|
||||
unadvertise enabled PKINIT feature in master's KDC entry in LDAP
|
||||
"""
|
||||
ldap = api.Backend.ldap2
|
||||
dn = DN(('cn', 'KDC'),
|
||||
('cn', self.fqdn),
|
||||
('cn', 'masters'),
|
||||
('cn', 'ipa'),
|
||||
('cn', 'etc'),
|
||||
dn = DN(('cn', 'KDC'), ('cn', self.fqdn), api.env.container_masters,
|
||||
self.suffix)
|
||||
|
||||
entry = ldap.get_entry(dn, ['ipaConfigString'])
|
||||
|
@ -47,8 +47,7 @@ class update_ca_renewal_master(Updater):
|
||||
return False, []
|
||||
|
||||
ldap = self.api.Backend.ldap2
|
||||
base_dn = DN(('cn', 'masters'), ('cn', 'ipa'), ('cn', 'etc'),
|
||||
self.api.env.basedn)
|
||||
base_dn = DN(self.api.env.container_masters, self.api.env.basedn)
|
||||
dn = DN(('cn', 'CA'), ('cn', self.api.env.host), base_dn)
|
||||
filter = '(&(cn=CA)(ipaConfigString=caRenewalMaster))'
|
||||
try:
|
||||
|
@ -1408,8 +1408,7 @@ class ReplicationManager:
|
||||
|
||||
# delete master entry with all active services
|
||||
try:
|
||||
dn = DN(('cn', replica), ('cn', 'masters'), ('cn', 'ipa'),
|
||||
('cn', 'etc'), self.suffix)
|
||||
dn = DN(('cn', replica), api.env.container_masters, self.suffix)
|
||||
entries = self.conn.get_entries(dn, ldap.SCOPE_SUBTREE)
|
||||
if entries:
|
||||
entries.sort(key=lambda x: len(x.dn), reverse=True)
|
||||
|
@ -1261,8 +1261,8 @@ def uninstall_dogtag_9(ds, http):
|
||||
logger.debug('Dogtag is version 10 or above')
|
||||
return
|
||||
|
||||
dn = DN(('cn', 'CA'), ('cn', api.env.host), ('cn', 'masters'),
|
||||
('cn', 'ipa'), ('cn', 'etc'), api.env.basedn)
|
||||
dn = DN(('cn', 'CA'), ('cn', api.env.host), api.env.container_masters,
|
||||
api.env.basedn)
|
||||
try:
|
||||
api.Backend.ldap2.delete_entry(dn)
|
||||
except ipalib.errors.PublicError as e:
|
||||
|
@ -134,8 +134,7 @@ def set_service_entry_config(name, fqdn, config_values,
|
||||
assert isinstance(ldap_suffix, DN)
|
||||
|
||||
entry_name = DN(
|
||||
('cn', name), ('cn', fqdn), ('cn', 'masters'),
|
||||
('cn', 'ipa'), ('cn', 'etc'), ldap_suffix)
|
||||
('cn', name), ('cn', fqdn), api.env.container_masters, ldap_suffix)
|
||||
|
||||
# enable disabled service
|
||||
try:
|
||||
@ -618,8 +617,8 @@ class Service:
|
||||
def ldap_disable(self, name, fqdn, ldap_suffix):
|
||||
assert isinstance(ldap_suffix, DN)
|
||||
|
||||
entry_dn = DN(('cn', name), ('cn', fqdn), ('cn', 'masters'),
|
||||
('cn', 'ipa'), ('cn', 'etc'), ldap_suffix)
|
||||
entry_dn = DN(('cn', name), ('cn', fqdn), api.env.container_masters,
|
||||
ldap_suffix)
|
||||
search_kw = {'ipaConfigString': ENABLED_SERVICE}
|
||||
filter = api.Backend.ldap2.make_filter(search_kw)
|
||||
try:
|
||||
@ -652,8 +651,8 @@ class Service:
|
||||
logger.debug("service %s startup entry disabled", name)
|
||||
|
||||
def ldap_remove_service_container(self, name, fqdn, ldap_suffix):
|
||||
entry_dn = DN(('cn', name), ('cn', fqdn), ('cn', 'masters'),
|
||||
('cn', 'ipa'), ('cn', 'etc'), ldap_suffix)
|
||||
entry_dn = DN(('cn', name), ('cn', fqdn),
|
||||
self.api.env.container_masters, ldap_suffix)
|
||||
try:
|
||||
api.Backend.ldap2.delete_entry(entry_dn)
|
||||
except errors.NotFound:
|
||||
|
@ -497,7 +497,7 @@ def host_is_master(ldap, fqdn):
|
||||
|
||||
Raises an exception if a master, otherwise returns nothing.
|
||||
"""
|
||||
master_dn = DN(('cn', fqdn), ('cn', 'masters'), ('cn', 'ipa'), ('cn', 'etc'), api.env.basedn)
|
||||
master_dn = DN(('cn', fqdn), api.env.container_masters, api.env.basedn)
|
||||
try:
|
||||
ldap.get_entry(master_dn, ['objectclass'])
|
||||
raise errors.ValidationError(name='hostname', error=_('An IPA master host cannot be deleted or disabled'))
|
||||
|
@ -73,25 +73,18 @@ def check_conflict_entries(ldap, api, desired_value):
|
||||
except errors.NotFound:
|
||||
pass
|
||||
|
||||
|
||||
def get_master_entries(ldap, api):
|
||||
"""
|
||||
Returns list of LDAPEntries representing IPA masters.
|
||||
"""
|
||||
|
||||
container_masters = DN(
|
||||
('cn', 'masters'),
|
||||
('cn', 'ipa'),
|
||||
('cn', 'etc'),
|
||||
api.env.basedn
|
||||
)
|
||||
|
||||
dn = DN(api.env.container_masters, api.env.basedn)
|
||||
masters, _dummy = ldap.find_entries(
|
||||
filter="(cn=*)",
|
||||
base_dn=container_masters,
|
||||
base_dn=dn,
|
||||
scope=ldap.SCOPE_ONELEVEL,
|
||||
paged_search=True, # we need to make sure to get all of them
|
||||
)
|
||||
|
||||
return masters
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user