|
|
2737e7 |
From 6db737931822c188833dee8cd086f91c640710fd Mon Sep 17 00:00:00 2001
|
|
|
2737e7 |
From: Felipe Barreto <fbarreto@redhat.com>
|
|
|
2737e7 |
Date: Mon, 15 Jan 2018 17:12:15 -0200
|
|
|
2737e7 |
Subject: [PATCH] Check if replication agreement exist before enable/disable it
|
|
|
2737e7 |
|
|
|
2737e7 |
If the replication agreement does not exist, a custom exception is
|
|
|
2737e7 |
raised explaining the problem.
|
|
|
2737e7 |
|
|
|
2737e7 |
https://pagure.io/freeipa/issue/7201
|
|
|
2737e7 |
|
|
|
2737e7 |
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
|
|
|
2737e7 |
Reviewed-By: Christian Heimes <cheimes@redhat.com>
|
|
|
2737e7 |
---
|
|
|
2737e7 |
install/tools/ipa-replica-manage | 7 +++++--
|
|
|
2737e7 |
ipaserver/install/replication.py | 11 +++++++++++
|
|
|
2737e7 |
2 files changed, 16 insertions(+), 2 deletions(-)
|
|
|
2737e7 |
|
|
|
2737e7 |
diff --git a/install/tools/ipa-replica-manage b/install/tools/ipa-replica-manage
|
|
|
2737e7 |
index c00d8ca3a0fa8228c5aa782a270991f14ee16974..019826f822b23e4e55dedb794ff6c1459a3d93c8 100755
|
|
|
2737e7 |
--- a/install/tools/ipa-replica-manage
|
|
|
2737e7 |
+++ b/install/tools/ipa-replica-manage
|
|
|
2737e7 |
@@ -1200,8 +1200,11 @@ def re_initialize(realm, thishost, fromhost, dirman_passwd, nolookup=False):
|
|
|
2737e7 |
repl = replication.ReplicationManager(realm, fromhost, dirman_passwd)
|
|
|
2737e7 |
agreement = repl.get_replication_agreement(thishost)
|
|
|
2737e7 |
|
|
|
2737e7 |
- thisrepl.enable_agreement(fromhost)
|
|
|
2737e7 |
- repl.enable_agreement(thishost)
|
|
|
2737e7 |
+ try:
|
|
|
2737e7 |
+ thisrepl.enable_agreement(fromhost)
|
|
|
2737e7 |
+ repl.enable_agreement(thishost)
|
|
|
2737e7 |
+ except errors.NotFound as e:
|
|
|
2737e7 |
+ sys.exit(e)
|
|
|
2737e7 |
|
|
|
2737e7 |
repl.force_sync(repl.conn, thishost)
|
|
|
2737e7 |
|
|
|
2737e7 |
diff --git a/ipaserver/install/replication.py b/ipaserver/install/replication.py
|
|
|
2737e7 |
index 3a76b70038bf6f739fe63aeac0233ccbfda2f016..d4b41caa45409fa1537ae10f182599307f3e0439 100644
|
|
|
2737e7 |
--- a/ipaserver/install/replication.py
|
|
|
2737e7 |
+++ b/ipaserver/install/replication.py
|
|
|
2737e7 |
@@ -31,6 +31,7 @@ import ldap
|
|
|
2737e7 |
from ipalib import api, errors
|
|
|
2737e7 |
from ipalib.cli import textui
|
|
|
2737e7 |
from ipapython.ipa_log_manager import root_logger
|
|
|
2737e7 |
+from ipalib.text import _
|
|
|
2737e7 |
from ipapython import ipautil, ipaldap, kerberos
|
|
|
2737e7 |
from ipapython.admintool import ScriptError
|
|
|
2737e7 |
from ipapython.dn import DN
|
|
|
2737e7 |
@@ -1599,6 +1600,11 @@ class ReplicationManager(object):
|
|
|
2737e7 |
Disable the replication agreement to hostname.
|
|
|
2737e7 |
"""
|
|
|
2737e7 |
entry = self.get_replication_agreement(hostname)
|
|
|
2737e7 |
+ if not entry:
|
|
|
2737e7 |
+ raise errors.NotFound(reason=_(
|
|
|
2737e7 |
+ "Replication agreement for %(hostname)s not found") % {
|
|
|
2737e7 |
+ 'hostname': hostname
|
|
|
2737e7 |
+ })
|
|
|
2737e7 |
entry['nsds5ReplicaEnabled'] = 'off'
|
|
|
2737e7 |
|
|
|
2737e7 |
try:
|
|
|
2737e7 |
@@ -1613,6 +1619,11 @@ class ReplicationManager(object):
|
|
|
2737e7 |
Note: for replication to work it needs to be enabled both ways.
|
|
|
2737e7 |
"""
|
|
|
2737e7 |
entry = self.get_replication_agreement(hostname)
|
|
|
2737e7 |
+ if not entry:
|
|
|
2737e7 |
+ raise errors.NotFound(reason=_(
|
|
|
2737e7 |
+ "Replication agreement for %(hostname)s not found") % {
|
|
|
2737e7 |
+ 'hostname': hostname
|
|
|
2737e7 |
+ })
|
|
|
2737e7 |
entry['nsds5ReplicaEnabled'] = 'on'
|
|
|
2737e7 |
|
|
|
2737e7 |
try:
|
|
|
2737e7 |
--
|
|
|
2737e7 |
2.17.1
|
|
|
2737e7 |
|