URL: https://github.com/freeipa/freeipa/pull/1823
Author: abbra
 Title: #1823: [backport ipa-4-5] replication: support error messages from 
389-ds 1.3.5 or later
Action: opened

PR body:
"""
389-ds 1.3.5 changed the error message format for
nsds5ReplicaLastUpdateStatus value. Now it produces
"Error (%d) %s" instead of "%d %s".

Change the check_repl_update() to handle both formats.

Fixes: https://pagure.io/freeipa/issue/7442
(cherry picked from commit ee437fcabd8c11907bc027f3815a6cdb7da65106)
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/1823/head:pr1823
git checkout pr1823
From 67c85c381f3a9b22dc9331d3e810535a72738c01 Mon Sep 17 00:00:00 2001
From: Alexander Bokovoy <aboko...@redhat.com>
Date: Mon, 16 Apr 2018 17:52:30 +0300
Subject: [PATCH] replication: support error messages from 389-ds 1.3.5 or
 later

389-ds 1.3.5 changed the error message format for
nsds5ReplicaLastUpdateStatus value. Now it produces
"Error (%d) %s" instead of "%d %s".

Change the check_repl_update() to handle both formats.

Fixes: https://pagure.io/freeipa/issue/7442
(cherry picked from commit ee437fcabd8c11907bc027f3815a6cdb7da65106)
---
 ipaserver/install/replication.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/ipaserver/install/replication.py b/ipaserver/install/replication.py
index e0055b792c..1a8be5e1f8 100644
--- a/ipaserver/install/replication.py
+++ b/ipaserver/install/replication.py
@@ -18,6 +18,7 @@
 #
 
 from __future__ import print_function
+from __future__ import absolute_import
 
 import six
 import time
@@ -973,7 +974,13 @@ def check_repl_update(self, conn, agmtdn):
             if status: # always check for errors
                 # status will usually be a number followed by a string
                 # number != 0 means error
-                rc, msg = status.split(' ', 1)
+                # Since 389-ds-base 1.3.5 it is 'Error (%d) %s'
+                # so we need to remove a prefix string and parentheses
+                if status.startswith('Error '):
+                    rc, msg = status[6:].split(' ', 1)
+                    rc = rc.strip('()')
+                else:
+                    rc, msg = status.split(' ', 1)
                 if rc != '0':
                     hasError = 1
                     error_message = msg
_______________________________________________
FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org
To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org

Reply via email to