From 804684254516c0c04d6d00080d38e3cbd0dd06b3 Mon Sep 17 00:00:00 2001 From: William Brown Date: May 01 2019 01:38:11 +0000 Subject: Ticket 50344 - tidy rpm vs build systemd flag handling Bug Description: In rpm builds we would read with_systemd from defaults.inf, which has a diffeent value to hand-building. AS a result this caused as issue in dscontainer on opensuse where it believed systemd was present. Fix Description: Simplify the systemd handling to a single flag which is possible to override in a container env. https://pagure.io/389-ds-base/issue/50344 Author: William Brown Review by: ??? --- diff --git a/src/lib389/lib389/__init__.py b/src/lib389/lib389/__init__.py index 0c5852a..df1add7 100644 --- a/src/lib389/lib389/__init__.py +++ b/src/lib389/lib389/__init__.py @@ -415,6 +415,9 @@ class DirSrv(SimpleLDAPObject, object): self.confdir = None self.ds_paths = Paths(instance=self) + # Set the default systemd status. This MAY be overidden in the setup utils + # as required. + self.systemd = self.ds_paths.with_systemd # Reset the args (py.test reuses the args_instance for each test case) # We allocate a "default" prefix here which allows an un-allocate or @@ -423,7 +426,6 @@ class DirSrv(SimpleLDAPObject, object): # ds = lib389.DirSrv() # ds.list(all=True) # self.ds_paths.prefix = args_instance[SER_DEPLOYED_DIR] - self.containerised = False self.__wrapmethods() self.__add_brookers__() @@ -1126,12 +1128,14 @@ class DirSrv(SimpleLDAPObject, object): if self.status() is True: return - if self.with_systemd() and not self.containerised: + if self.with_systemd(): + self.log.debug("systemd status -> True") # Do systemd things here ... subprocess.check_call(["systemctl", "start", "dirsrv@%s" % self.serverid]) else: + self.log.debug("systemd status -> False") # Start the process. # Wait for it to terminate # This means the server is probably ready to go .... @@ -1190,12 +1194,14 @@ class DirSrv(SimpleLDAPObject, object): if self.status() is False: return - if self.with_systemd() and not self.containerised: + if self.with_systemd(): + self.log.debug("systemd status -> True") # Do systemd things here ... subprocess.check_call(["systemctl", "stop", "dirsrv@%s" % self.serverid]) else: + self.log.debug("systemd status -> False") # TODO: Make the pid path in the files things # TODO: use the status call instead!!!! count = timeout @@ -1217,7 +1223,8 @@ class DirSrv(SimpleLDAPObject, object): Will update the self.state parameter. """ - if self.with_systemd() and not self.containerised: + if self.with_systemd(): + self.log.debug("systemd status -> True") # Do systemd things here ... rc = subprocess.call(["systemctl", "is-active", "--quiet", @@ -1229,6 +1236,7 @@ class DirSrv(SimpleLDAPObject, object): self.state = DIRSRV_STATE_OFFLINE return False else: + self.log.debug("systemd status -> False") # TODO: Make the pid path in the files things # TODO: use the status call instead!!!! pid = pid_from_file(self.ds_paths.pid_file) @@ -1706,7 +1714,7 @@ class DirSrv(SimpleLDAPObject, object): return self.ds_paths.asan_enabled def with_systemd(self): - return self.ds_paths.with_systemd + return self.systemd def get_server_tls_subject(self): """ Get the servers TLS subject line for enrollment purposes. diff --git a/src/lib389/lib389/instance/setup.py b/src/lib389/lib389/instance/setup.py index 757450d..c6ca83c 100644 --- a/src/lib389/lib389/instance/setup.py +++ b/src/lib389/lib389/instance/setup.py @@ -804,7 +804,8 @@ class SetupDs(object): # Should I move this import? I think this prevents some recursion from lib389 import DirSrv ds_instance = DirSrv(self.verbose) - ds_instance.containerised = self.containerised + if self.containerised: + ds_instance.systemd = general['systemd'] args = { SER_PORT: slapd['port'], SER_SERVERID_PROP: slapd['instance_name'],