diff options
-rwxr-xr-x | install/tools/ipa-replica-manage | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/install/tools/ipa-replica-manage b/install/tools/ipa-replica-manage index 084138ee..c804ccb8 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: |