andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone
Blob Blame History Raw
From 442b49cc1a0d93122fa749363b5930f3acf2eaf0 Mon Sep 17 00:00:00 2001
From: Matus Honek <mhonek@redhat.com>
Date: Wed, 29 Jan 2020 14:06:04 +0000
Subject: [PATCH] Issue 50823 - dsctl doesn't work with 'slapd-' in the
 instance name

Bug Description:
DirSrv.list drops all occurrences of 'slapd-' within a serverid
rendering names containing it damaged.

Fix Description:
Remove only the first occurrence of 'slapd-' in the serverid, which is
the prefix that is expected to be removed.

Fixes https://pagure.io/389-ds-base/issue/50823

Author: Matus Honek <mhonek@redhat.com>

Review by: Mark, William (thanks!)

(cherry picked from commit 52930da0bb8abe94a56ff6dca5ea57347d3461a9)
---
 src/lib389/lib389/__init__.py       | 2 +-
 src/lib389/lib389/instance/setup.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/lib389/lib389/__init__.py b/src/lib389/lib389/__init__.py
index 0d1ab5747..003b686fa 100644
--- a/src/lib389/lib389/__init__.py
+++ b/src/lib389/lib389/__init__.py
@@ -711,7 +711,7 @@ class DirSrv(SimpleLDAPObject, object):
         if serverid is None and hasattr(self, 'serverid'):
             serverid = self.serverid
         elif serverid is not None:
-            serverid = serverid.replace('slapd-', '')
+            serverid = serverid.replace('slapd-', '', 1)
 
         if self.serverid is None:
             # Need to set the Paths in case it does exist
diff --git a/src/lib389/lib389/instance/setup.py b/src/lib389/lib389/instance/setup.py
index 61ffc32ee..c6bb4fcdc 100644
--- a/src/lib389/lib389/instance/setup.py
+++ b/src/lib389/lib389/instance/setup.py
@@ -219,7 +219,7 @@ class SetupDs(object):
         insts = inst.list(serverid=serverid)
 
         if len(insts) != 1:
-            log.error("No such instance to remove {}".format(serverid))
+            self.log.error("No such instance to remove {}".format(serverid))
             return
         inst.allocate(insts[0])
         remove_ds_instance(inst, force=True)
-- 
2.21.1