summaryrefslogtreecommitdiffstats
path: root/install/tools/ipa-replica-manage
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2012-02-08 14:47:43 -0500
committerMartin Kosek <mkosek@redhat.com>2012-02-27 14:39:37 +0100
commit5c7cd8ee2f513c49ddb3738811cbe75d9a01c806 (patch)
treee6fb5f31745455fa08e4de7bd49e873f42effc24 /install/tools/ipa-replica-manage
parent31f00f90f1a08804e9dfdd6bdf85c2dc245bea51 (diff)
downloadfreeipa-5c7cd8ee2f513c49ddb3738811cbe75d9a01c806.tar.gz
freeipa-5c7cd8ee2f513c49ddb3738811cbe75d9a01c806.tar.xz
freeipa-5c7cd8ee2f513c49ddb3738811cbe75d9a01c806.zip
Check for duplicate winsync agreement before trying to set one up.
We currently only support a single winsync agreement so all we need to do is check to see if we have one with the remote host. This also adds some minor exception handling cleanup. https://fedorahosted.org/freeipa/ticket/2130
Diffstat (limited to 'install/tools/ipa-replica-manage')
-rwxr-xr-xinstall/tools/ipa-replica-manage28
1 files changed, 15 insertions, 13 deletions
diff --git a/install/tools/ipa-replica-manage b/install/tools/ipa-replica-manage
index 084138ee3..c804ccb8c 100755
--- a/install/tools/ipa-replica-manage
+++ b/install/tools/ipa-replica-manage
@@ -199,10 +199,7 @@ def del_link(realm, replica1, replica2, dirman_passwd, force=False):
print "Please use the 'del' command to remove it from the domain"
return
- except ldap.NO_SUCH_OBJECT:
- print "'%s' has no replication agreement for '%s'" % (replica1, replica2)
- return
- except errors.NotFound:
+ except (ldap.NO_SUCH_OBJECT, errors.NotFound):
print "'%s' has no replication agreement for '%s'" % (replica1, replica2)
return
except Exception, e:
@@ -219,11 +216,7 @@ def del_link(realm, replica1, replica2, dirman_passwd, force=False):
print "Please use the 'del' command to remove it from the domain"
return
- except ldap.NO_SUCH_OBJECT:
- print "'%s' has no replication agreement for '%s'" % (replica2, replica1)
- if not force:
- return
- except errors.NotFound:
+ except (ldap.NO_SUCH_OBJECT, errors.NotFound):
print "'%s' has no replication agreement for '%s'" % (replica2, replica1)
if not force:
return
@@ -357,6 +350,18 @@ def add_link(realm, replica1, replica2, dirman_passwd, options):
root_logger.error("winsync agreements need to be created as root")
sys.exit(1)
+ # See if we already have an agreement with this host
+ try:
+ repl = replication.ReplicationManager(realm, replica1, dirman_passwd)
+ if repl.get_agreement_type(replica2) == replication.WINSYNC:
+ agreement = repl.get_replication_agreement(replica2)
+ sys.exit("winsync agreement already exists on subtree %s" %
+ agreement.getValue('nsds7WindowsReplicaSubtree'))
+ else:
+ sys.exit("A replication agreement to %s already exists" % replica2)
+ except errors.NotFound:
+ pass
+
if options.cacert:
# have to install the given CA cert before doing anything else
ds = dsinstance.DsInstance(realm_name = realm,
@@ -372,10 +377,7 @@ def add_link(realm, replica1, replica2, dirman_passwd, options):
try:
repl1 = replication.ReplicationManager(realm, replica1, dirman_passwd)
- except ldap.NO_SUCH_OBJECT:
- print "Cannot find replica '%s'" % replica1
- return
- except errors.NotFound:
+ except (ldap.NO_SUCH_OBJECT, errors.NotFound):
print "Cannot find replica '%s'" % replica1
return
except Exception, e: