Skip to content

Commit 340b419

Browse files
Dan Lavupbrezina
authored andcommitted
utils sssd, adding clean flag, clearing the cache on starts and restarts
1 parent 33e10d0 commit 340b419

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

sssd_test_framework/utils/sssd.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ def async_start(
119119
apply_config: bool = True,
120120
check_config: bool = True,
121121
debug_level: str | None = "0xfff0",
122+
clean: bool = False,
122123
) -> Process:
123124
"""
124125
Start the SSSD and KCM services. Non-blocking call.
@@ -133,6 +134,8 @@ def async_start(
133134
:type check_config: bool, optional
134135
:param debug_level: Automatically set debug level to the given value, defaults to 0xfff0
135136
:type debug_level: str | None, optional
137+
:param clean: Does a clean restart, clearing the cache, defaults to False
138+
:type clean: bool, defaults to False
136139
:return: Running SSH process.
137140
:rtype: Process
138141
"""
@@ -145,6 +148,9 @@ def async_start(
145148
if service == "sssd":
146149
self.svc.async_stop("sssd-kcm.service")
147150

151+
if clean and service == "sssd":
152+
self.clear()
153+
148154
return self.svc.async_start(service)
149155

150156
def start(
@@ -156,6 +162,7 @@ def start(
156162
apply_config: bool = True,
157163
check_config: bool = True,
158164
debug_level: str | None = "0xfff0",
165+
clean: bool = False,
159166
) -> ProcessResult:
160167
"""
161168
Start the SSSD and KCM services. The call will wait until the operation is finished.
@@ -172,6 +179,8 @@ def start(
172179
:type check_config: bool, optional
173180
:param debug_level: Automatically set debug level to the given value, defaults to 0xfff0
174181
:type debug_level: str | None, optional
182+
:param clean: Does a clean restart, clearing the cache, defaults to False
183+
:type clean: bool, defaults to False
175184
:return: SSH process result.
176185
:rtype: ProcessResult
177186
"""
@@ -184,6 +193,9 @@ def start(
184193
if service == "sssd":
185194
self.svc.stop("sssd-kcm.service")
186195

196+
if clean and service == "sssd":
197+
self.clear()
198+
187199
return self.svc.start(service, raise_on_error=raise_on_error)
188200

189201
def async_stop(self, service="sssd") -> Process:
@@ -225,6 +237,7 @@ def async_restart(
225237
apply_config: bool = True,
226238
check_config: bool = True,
227239
debug_level: str | None = "0xfff0",
240+
clean: bool = False,
228241
) -> Process:
229242
"""
230243
Restart the SSSD and KCM services. Non-blocking call.
@@ -237,6 +250,8 @@ def async_restart(
237250
:type check_config: bool, optional
238251
:param debug_level: Automatically set debug level to the given value, defaults to 0xfff0
239252
:type debug_level: str | None, optional
253+
:param clean: Does a clean restart, clearing the cache, defaults to False
254+
:type clean: bool, defaults to False
240255
:return: Running SSH process.
241256
:rtype: Process
242257
"""
@@ -247,6 +262,9 @@ def async_restart(
247262
if service == "sssd":
248263
self.svc.async_stop("sssd-kcm.service")
249264

265+
if clean and service == "sssd":
266+
self.clear()
267+
250268
return self.svc.async_restart(service)
251269

252270
def restart(
@@ -257,6 +275,7 @@ def restart(
257275
apply_config: bool = True,
258276
check_config: bool = True,
259277
debug_level: str | None = "0xfff0",
278+
clean: bool = False,
260279
) -> ProcessResult:
261280
"""
262281
Restart the SSSD and KCM services. The call will wait until the operation is finished.
@@ -271,6 +290,8 @@ def restart(
271290
:type check_config: bool, optional
272291
:param debug_level: Automatically set debug level to the given value, defaults to 0xfff0
273292
:type debug_level: str | None, optional
293+
:param clean: Does a clean restart, clearing the cache, defaults to False
294+
:type clean: bool, defaults to False
274295
:return: SSH process result.
275296
:rtype: ProcessResult
276297
"""
@@ -281,6 +302,9 @@ def restart(
281302
if service == "sssd":
282303
self.svc.stop("sssd-kcm.service")
283304

305+
if clean and service == "sssd":
306+
self.clear()
307+
284308
return self.svc.restart(service, raise_on_error=raise_on_error)
285309

286310
def clear(self, *, db: bool = True, memcache: bool = True, config: bool = False, logs: bool = False):

0 commit comments

Comments
 (0)