mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Populate shared tree with replica related values
Fixes: https://fedorahosted.org/freeipa/ticket/820
This commit is contained in:
@@ -445,6 +445,7 @@ def main():
|
||||
print "ipa-client-install returned: " + str(e)
|
||||
raise RuntimeError("Failed to configure the client")
|
||||
|
||||
ds.replica_populate()
|
||||
ds.init_memberof()
|
||||
|
||||
try:
|
||||
|
||||
@@ -737,3 +737,25 @@ class DsInstance(service.Service):
|
||||
def __root_autobind(self):
|
||||
self._ldap_mod("root-autobind.ldif")
|
||||
|
||||
def replica_populate(self):
|
||||
self.ldap_connect()
|
||||
|
||||
dn = "cn=default,ou=profile,%s" % self.suffix
|
||||
try:
|
||||
ret = self.admin_conn.search_s(dn, ldap.SCOPE_BASE,
|
||||
'(objectclass=*)')[0]
|
||||
srvlist = ret.data.get('defaultServerList')
|
||||
if len(srvlist) > 0:
|
||||
srvlist = srvlist[0].split()
|
||||
if not self.fqdn in srvlist:
|
||||
srvlist.append(self.fqdn)
|
||||
attr = ' '.join(srvlist)
|
||||
mod = [(ldap.MOD_REPLACE, 'defaultServerList', attr)]
|
||||
self.admin_conn.modify_s(dn, mod)
|
||||
except ldap.NO_SUCH_OBJECT:
|
||||
pass
|
||||
except ldap.TYPE_OR_VALUE_EXISTS:
|
||||
pass
|
||||
|
||||
self.ldap_disconnect()
|
||||
|
||||
|
||||
@@ -730,6 +730,11 @@ class ReplicationManager:
|
||||
return IPA_REPLICA
|
||||
|
||||
def replica_cleanup(self, replica, realm, force=False):
|
||||
"""
|
||||
This function removes information about the replica in parts
|
||||
of the shared tree that expose it, so clients stop trying to
|
||||
use this replica.
|
||||
"""
|
||||
|
||||
err = None
|
||||
|
||||
@@ -789,6 +794,30 @@ class ReplicationManager:
|
||||
pass
|
||||
except errors.NotFound:
|
||||
pass
|
||||
except Exception, e:
|
||||
if not force:
|
||||
raise e
|
||||
elif not err:
|
||||
err = e
|
||||
|
||||
try:
|
||||
dn = 'cn=default,ou=profile,%s' % self.suffix
|
||||
ret = self.conn.search_s(dn, ldap.SCOPE_BASE,
|
||||
'(objectclass=*)')[0]
|
||||
srvlist = ret.data.get('defaultServerList')
|
||||
if len(srvlist) > 0:
|
||||
srvlist = srvlist[0].split()
|
||||
if replica in srvlist:
|
||||
srvlist.remove(replica)
|
||||
attr = ' '.join(srvlist)
|
||||
mod = [(ldap.MOD_REPLACE, 'defaultServerList', attr)]
|
||||
self.conn.modify_s(dn, mod)
|
||||
except ldap.NO_SUCH_OBJECT:
|
||||
pass
|
||||
except ldap.NO_SUCH_ATTRIBUTE:
|
||||
pass
|
||||
except ldap.TYPE_OR_VALUE_EXISTS:
|
||||
pass
|
||||
except Exception, e:
|
||||
if force and err:
|
||||
raise err
|
||||
|
||||
Reference in New Issue
Block a user