Hi,

This allows us to clean sssd cache on older, non-systemd platforms.

Part of: https://fedorahosted.org/freeipa/ticket/3833

--
Tomas Babej
Associate Software Engeneer | Red Hat | Identity Management
RHCE | Brno Site | IRC: tbabej | freeipa.org


From 38f1b53bb70fb20b969b5621fc6404011e1cef8a Mon Sep 17 00:00:00 2001
From: Tomas Babej <tba...@redhat.com>
Date: Wed, 30 Oct 2013 10:07:22 +0100
Subject: [PATCH] ipatests: Extend clear_sssd_cache to support non-systemd
 platforms

Part of: https://fedorahosted.org/freeipa/ticket/3833
---
 ipatests/test_integration/tasks.py | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/ipatests/test_integration/tasks.py b/ipatests/test_integration/tasks.py
index fc3ce67cf84617ad43e93c1bcdf868f631659584..af88f9f753eada39c6751468f668434ac475dcc2 100644
--- a/ipatests/test_integration/tasks.py
+++ b/ipatests/test_integration/tasks.py
@@ -376,12 +376,22 @@ def clear_sssd_cache(host):
     Clears SSSD cache by removing the cache files. Restarts SSSD.
     """
 
-    host.run_command(['systemctl', 'stop', 'sssd'])
-    host.run_command(['rm', '-rfv', '/var/lib/sss/db/cache_%s.ldb'
-                                    % host.domain.name])
-    host.run_command(['rm', '-rfv', '/var/lib/sss/mc/group'])
-    host.run_command(['rm', '-rfv', '/var/lib/sss/mc/passwd'])
-    host.run_command(['systemctl', 'start', 'sssd'])
+    systemd_available = host.transport.file_exists('/bin/systemctl')
+
+    if systemd_available:
+        host.run_command(['systemctl', 'start', 'sssd'])
+    else:
+        host.run_command(['/sbin/service', 'sssd', 'start'])
+
+    host.run_command("find /var/lib/sss/db -name '*.ldb' | "
+                     "xargs rm -fv")
+    host.run_command(['rm', '-fv', '/var/lib/sss/mc/group'])
+    host.run_command(['rm', '-fv', '/var/lib/sss/mc/passwd'])
+
+    if systemd_available:
+        host.run_command(['systemctl', 'start', 'sssd'])
+    else:
+        host.run_command(['/sbin/service', 'sssd', 'start'])
 
 
 def sync_time(host, server):
-- 
1.8.3.1

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to