From b73e0cd233d240265103e50bba4937f17cc52351 Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Mon, 10 Nov 2008 17:08:22 -0500 Subject: Fix deleting a winsync replication agreement. --- ipa-server/ipa-install/ipa-replica-manage | 13 ++++++++----- ipa-server/ipaserver/replication.py | 30 ++++++++++++++++++++++++------ 2 files changed, 32 insertions(+), 11 deletions(-) mode change 100644 => 100755 ipa-server/ipa-install/ipa-replica-manage diff --git a/ipa-server/ipa-install/ipa-replica-manage b/ipa-server/ipa-install/ipa-replica-manage old mode 100644 new mode 100755 index 8ba4427ba..9b46748e3 --- 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 d356c530d..86d1f5f92 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 -- cgit