summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2008-11-10 17:08:22 -0500
committerRob Crittenden <rcritten@redhat.com>2008-11-12 15:54:38 -0500
commitb73e0cd233d240265103e50bba4937f17cc52351 (patch)
tree097c968ae3bdefd2c296902192772505c1a66051
parent00f42a236ef2b6a768597df754bbdc92925de558 (diff)
downloadfreeipa-b73e0cd233d240265103e50bba4937f17cc52351.zip
freeipa-b73e0cd233d240265103e50bba4937f17cc52351.tar.gz
freeipa-b73e0cd233d240265103e50bba4937f17cc52351.tar.xz
Fix deleting a winsync replication agreement.
-rwxr-xr-x[-rw-r--r--]ipa-server/ipa-install/ipa-replica-manage13
-rw-r--r--ipa-server/ipaserver/replication.py30
2 files changed, 32 insertions, 11 deletions
diff --git a/ipa-server/ipa-install/ipa-replica-manage b/ipa-server/ipa-install/ipa-replica-manage
index 8ba4427..9b46748 100644..100755
--- a/ipa-server/ipa-install/ipa-replica-manage
+++ b/ipa-server/ipa-install/ipa-replica-manage
@@ -93,12 +93,15 @@ def list_masters(replman, verbose):
print " last update ended: %s" % str(ipautil.parse_generalized_time(entry.nsds5replicalastupdateend))
def del_master(replman, hostname):
- dirman_passwd = getpass.getpass("Directory Manager password (%s): " % hostname)
- other_replman = replication.ReplicationManager(hostname, dirman_passwd)
- other_replman.suffix = get_suffix()
+ t = replman.get_agreement_type(hostname)
- replman.delete_agreement(other_replman.conn)
- other_replman.delete_agreement(replman.conn)
+ if t == replication.IPA_REPLICA:
+ dirman_passwd = getpass.getpass("Directory Manager password (%s): " % hostname)
+ other_replman = replication.ReplicationManager(hostname, dirman_passwd)
+ other_replman.suffix = get_suffix()
+ other_replman.delete_agreement(replman.conn.host)
+
+ replman.delete_agreement(hostname)
def add_master(replman, hostname, options):
other_args = {}
diff --git a/ipa-server/ipaserver/replication.py b/ipa-server/ipaserver/replication.py
index d356c53..86d1f5f 100644
--- a/ipa-server/ipaserver/replication.py
+++ b/ipa-server/ipaserver/replication.py
@@ -31,6 +31,10 @@ WIN_USER_CONTAINER="cn=Users"
IPA_USER_CONTAINER="cn=users,cn=accounts"
PORT = 636
TIMEOUT = 120
+
+IPA_REPLICA = 1
+WINSYNC = 2
+
class ReplicationManager:
"""Manage replication agreements between DS servers, and sync
agreements with Windows servers"""
@@ -260,14 +264,14 @@ class ReplicationManager:
windomain = '.'.join(ldap.explode_dn(self.suffix, 1))
entry.setValues("nsds7WindowsDomain", windomain)
- def agreement_dn(self, conn):
- cn = "meTo%s%d" % (conn.host, PORT)
+ def agreement_dn(self, hostname, port=PORT):
+ cn = "meTo%s%d" % (hostname, port)
dn = "cn=%s, %s" % (cn, self.replica_dn())
return (cn, dn)
def setup_agreement(self, a, b, **kargs):
- cn, dn = self.agreement_dn(b)
+ cn, dn = self.agreement_dn(b.host)
try:
a.getEntry(dn, ldap.SCOPE_BASE)
return
@@ -300,8 +304,8 @@ class ReplicationManager:
entry = a.waitForEntry(entry)
- def delete_agreement(self, other):
- cn, dn = self.agreement_dn(other)
+ def delete_agreement(self, hostname):
+ cn, dn = self.agreement_dn(hostname)
return self.conn.deleteEntry(dn)
def check_repl_init(self, conn, agmtdn):
@@ -351,7 +355,7 @@ class ReplicationManager:
print "Starting replication, please wait until this has completed."
if conn == None:
conn = self.conn
- cn, dn = self.agreement_dn(conn)
+ cn, dn = self.agreement_dn(conn.host)
mod = [(ldap.MOD_ADD, 'nsds5BeginReplicaRefresh', 'start')]
other_conn.modify_s(dn, mod)
@@ -383,6 +387,7 @@ class ReplicationManager:
if iswinsync:
logging.info("Could not validate connection to remote server %s:%d - continuing" %
(other_hostname, oth_port))
+ logging.info("The error was: %s" % e)
else:
raise e
@@ -429,3 +434,16 @@ class ReplicationManager:
(dn, schedule))
mod = [(ldap.MOD_REPLACE, 'nsDS5ReplicaUpdateSchedule', [ schedule ])]
conn.modify_s(dn, mod)
+
+ def get_agreement_type(self, hostname):
+ cn, dn = self.agreement_dn(hostname)
+
+ entry = self.conn.getEntry(dn, ldap.SCOPE_BASE)
+
+ objectclass = entry.getValues("objectclass")
+
+ for o in objectclass:
+ if o.lower() == "nsdswindowsreplicationagreement":
+ return WINSYNC
+
+ return IPA_REPLICA