mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2026-10-25 14:40:16 -05:00
Listing and cleaning RUV extended for CA suffix
https://fedorahosted.org/freeipa/ticket/5411 Reviewed-By: Martin Basti <mbasti@redhat.com>
This commit is contained in:
1 parent
aa30199e0b
commit
bb7887140d
2 files changed
+30
-16
No files matched your search
@@ -345,7 +345,7 @@ def del_link(realm, replica1, replica2, dirman_passwd, force=False):
|
||||
|
||||
return True
|
||||
|
||||
def get_ruv(realm, host, dirman_passwd, nolookup=False):
|
||||
def get_ruv(realm, host, dirman_passwd, nolookup=False, ca=False):
|
||||
"""
|
||||
Return the RUV entries as a list of tuples: (hostname, rid)
|
||||
"""
|
||||
@@ -354,7 +354,10 @@ def get_ruv(realm, host, dirman_passwd, nolookup=False):
|
||||
enforce_host_existence(host)
|
||||
|
||||
try:
|
||||
thisrepl = replication.ReplicationManager(realm, host, dirman_passwd)
|
||||
if ca:
|
||||
thisrepl = replication.get_cs_replication_manager(realm, host, dirman_passwd)
|
||||
else:
|
||||
thisrepl = replication.ReplicationManager(realm, host, dirman_passwd)
|
||||
except Exception as e:
|
||||
print("Failed to connect to server %s: %s" % (host, e))
|
||||
sys.exit(1)
|
||||
@@ -362,7 +365,7 @@ def get_ruv(realm, host, dirman_passwd, nolookup=False):
|
||||
search_filter = '(&(nsuniqueid=ffffffff-ffffffff-ffffffff-ffffffff)(objectclass=nstombstone))'
|
||||
try:
|
||||
entries = thisrepl.conn.get_entries(
|
||||
api.env.basedn, thisrepl.conn.SCOPE_SUBTREE, search_filter,
|
||||
thisrepl.db_suffix, thisrepl.conn.SCOPE_SUBTREE, search_filter,
|
||||
['nsds50ruv'])
|
||||
except errors.NotFound:
|
||||
print("No RUV records found.")
|
||||
@@ -402,7 +405,7 @@ def get_rid_by_host(realm, sourcehost, host, dirman_passwd, nolookup=False):
|
||||
if '%s:389' % host == netloc:
|
||||
return int(rid)
|
||||
|
||||
def clean_ruv(realm, ruv, options):
|
||||
def clean_ruv(realm, ruv, options, ca=False):
|
||||
"""
|
||||
Given an RID create a CLEANALLRUV task to clean it up.
|
||||
"""
|
||||
@@ -412,7 +415,7 @@ def clean_ruv(realm, ruv, options):
|
||||
sys.exit("Replica ID must be an integer: %s" % ruv)
|
||||
|
||||
servers = get_ruv(realm, options.host, options.dirman_passwd,
|
||||
options.nolookup)
|
||||
options.nolookup, ca=ca)
|
||||
found = False
|
||||
for (netloc, rid) in servers:
|
||||
if ruv == int(rid):
|
||||
@@ -423,16 +426,27 @@ def clean_ruv(realm, ruv, options):
|
||||
if not found:
|
||||
sys.exit("Replica ID %s not found" % ruv)
|
||||
|
||||
print("Clean the Replication Update Vector for %s" % hostname)
|
||||
print()
|
||||
print("Cleaning the wrong replica ID will cause that server to no")
|
||||
print("longer replicate so it may miss updates while the process")
|
||||
print("is running. It would need to be re-initialized to maintain")
|
||||
print("consistency. Be very careful.")
|
||||
if not options.force and not ipautil.user_input("Continue to clean?", False):
|
||||
sys.exit("Aborted")
|
||||
thisrepl = replication.ReplicationManager(realm, options.host,
|
||||
options.dirman_passwd)
|
||||
if ca:
|
||||
print("Clean the Certificate Server Replication Update Vector for %s"
|
||||
% hostname)
|
||||
else:
|
||||
print("Clean the Replication Update Vector for %s" % hostname)
|
||||
|
||||
if not options.force:
|
||||
print()
|
||||
print("Cleaning the wrong replica ID will cause that server to no")
|
||||
print("longer replicate so it may miss updates while the process")
|
||||
print("is running. It would need to be re-initialized to maintain")
|
||||
print("consistency. Be very careful.")
|
||||
if not ipautil.user_input("Continue to clean?", False):
|
||||
sys.exit("Aborted")
|
||||
|
||||
if ca:
|
||||
thisrepl = replication.get_cs_replication_manager(realm, options.host,
|
||||
options.dirman_passwd)
|
||||
else:
|
||||
thisrepl = replication.ReplicationManager(realm, options.host,
|
||||
options.dirman_passwd)
|
||||
thisrepl.cleanallruv(ruv)
|
||||
print("Cleanup task created")
|
||||
|
||||
|
||||
@@ -1351,7 +1351,7 @@ class ReplicationManager(object):
|
||||
{
|
||||
'objectclass': ['top', 'extensibleObject'],
|
||||
'cn': ['clean %d' % replicaId],
|
||||
'replica-base-dn': [api.env.basedn],
|
||||
'replica-base-dn': [self.db_suffix],
|
||||
'replica-id': [replicaId],
|
||||
}
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user