mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
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
This commit is contained in:
committed by
Martin Kosek
parent
31f00f90f1
commit
5c7cd8ee2f
@@ -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"
|
print "Please use the 'del' command to remove it from the domain"
|
||||||
return
|
return
|
||||||
|
|
||||||
except ldap.NO_SUCH_OBJECT:
|
except (ldap.NO_SUCH_OBJECT, errors.NotFound):
|
||||||
print "'%s' has no replication agreement for '%s'" % (replica1, replica2)
|
|
||||||
return
|
|
||||||
except errors.NotFound:
|
|
||||||
print "'%s' has no replication agreement for '%s'" % (replica1, replica2)
|
print "'%s' has no replication agreement for '%s'" % (replica1, replica2)
|
||||||
return
|
return
|
||||||
except Exception, e:
|
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"
|
print "Please use the 'del' command to remove it from the domain"
|
||||||
return
|
return
|
||||||
|
|
||||||
except ldap.NO_SUCH_OBJECT:
|
except (ldap.NO_SUCH_OBJECT, errors.NotFound):
|
||||||
print "'%s' has no replication agreement for '%s'" % (replica2, replica1)
|
|
||||||
if not force:
|
|
||||||
return
|
|
||||||
except errors.NotFound:
|
|
||||||
print "'%s' has no replication agreement for '%s'" % (replica2, replica1)
|
print "'%s' has no replication agreement for '%s'" % (replica2, replica1)
|
||||||
if not force:
|
if not force:
|
||||||
return
|
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")
|
root_logger.error("winsync agreements need to be created as root")
|
||||||
sys.exit(1)
|
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:
|
if options.cacert:
|
||||||
# have to install the given CA cert before doing anything else
|
# have to install the given CA cert before doing anything else
|
||||||
ds = dsinstance.DsInstance(realm_name = realm,
|
ds = dsinstance.DsInstance(realm_name = realm,
|
||||||
@@ -372,10 +377,7 @@ def add_link(realm, replica1, replica2, dirman_passwd, options):
|
|||||||
try:
|
try:
|
||||||
repl1 = replication.ReplicationManager(realm, replica1, dirman_passwd)
|
repl1 = replication.ReplicationManager(realm, replica1, dirman_passwd)
|
||||||
|
|
||||||
except ldap.NO_SUCH_OBJECT:
|
except (ldap.NO_SUCH_OBJECT, errors.NotFound):
|
||||||
print "Cannot find replica '%s'" % replica1
|
|
||||||
return
|
|
||||||
except errors.NotFound:
|
|
||||||
print "Cannot find replica '%s'" % replica1
|
print "Cannot find replica '%s'" % replica1
|
||||||
return
|
return
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
|
|||||||
Reference in New Issue
Block a user