mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Run the CLEANALLRUV task when deleting a replication agreement.
This adds two new commands to ipa-replica-manage: list-ruv & clean-ruv list-ruv can be use to list the update vectors the master has configugured clean-ruv can be used to fire off the CLEANRUV task to remove a replication vector. It should be used with caution. https://fedorahosted.org/freeipa/ticket/2303
This commit is contained in:
committed by
Martin Kosek
parent
c0630950a1
commit
c9c55a2845
@@ -1103,3 +1103,71 @@ class ReplicationManager(object):
|
||||
|
||||
if err:
|
||||
raise err #pylint: disable=E0702
|
||||
|
||||
def set_readonly(self, readonly, critical=False):
|
||||
"""
|
||||
Set the database readonly status.
|
||||
|
||||
@readonly: boolean for read-only status
|
||||
@critical: boolean to raise an exception on failure, default False.
|
||||
"""
|
||||
dn = DN(('cn', 'userRoot'), ('cn', 'ldbm database'),
|
||||
('cn', 'plugins'), ('cn', 'config'))
|
||||
|
||||
mod = [(ldap.MOD_REPLACE, 'nsslapd-readonly', 'on' if readonly else 'off')]
|
||||
try:
|
||||
self.conn.modify_s(dn, mod)
|
||||
except ldap.INSUFFICIENT_ACCESS, e:
|
||||
# We can't modify the read-only status on the remote server.
|
||||
# This usually isn't a show-stopper.
|
||||
if critical:
|
||||
raise e
|
||||
root_logger.debug("No permission to modify replica read-only status, continuing anyway")
|
||||
|
||||
def cleanallruv(self, replicaId):
|
||||
"""
|
||||
Create a CLEANALLRUV task and monitor it until it has
|
||||
completed.
|
||||
"""
|
||||
root_logger.debug("Creating CLEANALLRUV task for replica id %d" % replicaId)
|
||||
|
||||
dn = DN(('cn', 'clean %d' % replicaId), ('cn', 'cleanallruv'),('cn', 'tasks'), ('cn', 'config'))
|
||||
e = ipaldap.Entry(dn)
|
||||
e.setValues('objectclass', ['top', 'extensibleObject'])
|
||||
e.setValue('replica-base-dn', api.env.basedn)
|
||||
e.setValue('replica-id', replicaId)
|
||||
e.setValue('cn', 'clean %d' % replicaId)
|
||||
try:
|
||||
self.conn.addEntry(e)
|
||||
except errors.DuplicateEntry:
|
||||
print "CLEANALLRUV task for replica id %d already exists." % replicaId
|
||||
else:
|
||||
print "Background task created to clean replication data. This may take a while."
|
||||
|
||||
print "This may be safely interrupted with Ctrl+C"
|
||||
|
||||
self.conn.checkTask(dn, dowait=True)
|
||||
|
||||
def abortcleanallruv(self, replicaId):
|
||||
"""
|
||||
Create a task to abort a CLEANALLRUV operation.
|
||||
"""
|
||||
root_logger.debug("Creating task to abort a CLEANALLRUV operation for replica id %d" % replicaId)
|
||||
|
||||
dn = DN(('cn', 'abort %d' % replicaId), ('cn', 'abort cleanallruv'),('cn', 'tasks'), ('cn', 'config'))
|
||||
e = ipaldap.Entry(dn)
|
||||
e.setValues('objectclass', ['top', 'extensibleObject'])
|
||||
e.setValue('replica-base-dn', api.env.basedn)
|
||||
e.setValue('replica-id', replicaId)
|
||||
e.setValue('cn', 'abort %d' % replicaId)
|
||||
try:
|
||||
self.conn.addEntry(e)
|
||||
except errors.DuplicateEntry:
|
||||
print "An abort CLEANALLRUV task for replica id %d already exists." % replicaId
|
||||
else:
|
||||
print "Background task created. This may take a while."
|
||||
|
||||
print "This may be safely interrupted with Ctrl+C"
|
||||
|
||||
self.conn.checkTask(dn, dowait=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user