summaryrefslogtreecommitdiffstats
path: root/ipaserver
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2012-09-17 17:45:42 +0200
committerMartin Kosek <mkosek@redhat.com>2012-09-17 17:48:25 +0200
commitc9c55a2845fd8471bc609a23f5a32d252f7df04c (patch)
treea7ae157b90ece3bc3829c234d7bd8a2177f0e800 /ipaserver
parentc0630950a170cc9c0fa68256ff606589641bc812 (diff)
downloadfreeipa-c9c55a2845fd8471bc609a23f5a32d252f7df04c.tar.gz
freeipa-c9c55a2845fd8471bc609a23f5a32d252f7df04c.tar.xz
freeipa-c9c55a2845fd8471bc609a23f5a32d252f7df04c.zip
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
Diffstat (limited to 'ipaserver')
-rw-r--r--ipaserver/install/replication.py68
1 files changed, 68 insertions, 0 deletions
diff --git a/ipaserver/install/replication.py b/ipaserver/install/replication.py
index 8501a8c2c..564097e76 100644
--- a/ipaserver/install/replication.py
+++ b/ipaserver/install/replication.py
@@ -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)
+