URL: https://github.com/SSSD/sssd/pull/5512 Author: sgoveas Title: #5512: TEST: Add function to control services Action: opened
PR body: """ We can use this function to start stop or restart any service """ To pull the PR as Git branch: git remote add ghsssd https://github.com/SSSD/sssd git fetch ghsssd pull/5512/head:pr5512 git checkout pr5512
From 74d7d78223fd7ce4e4cf614acfa9cb6cf858ea12 Mon Sep 17 00:00:00 2001 From: Steeve Goveas <sgov...@redhat.com> Date: Fri, 19 Feb 2021 15:05:06 +0530 Subject: [PATCH] TEST: Add function to control services We can use this function to start stop or restart any service --- src/tests/multihost/sssd/testlib/common/utils.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/tests/multihost/sssd/testlib/common/utils.py b/src/tests/multihost/sssd/testlib/common/utils.py index fb66a99325..10cad4642c 100644 --- a/src/tests/multihost/sssd/testlib/common/utils.py +++ b/src/tests/multihost/sssd/testlib/common/utils.py @@ -88,6 +88,22 @@ def server_install_pkgs(self): self.multihost.package_mgmt(pkgs, action='install') self.multihost.package_mgmt(sssd_pkgs, action='install') + def service_ctrl(self, action, target_service): + """ Start, stop, restart, reload service with systemctl + + :param str action: start/ stop/ restart/ reload + :param str target_service: target service/daemon + :return: str Return code of the systemctl command + :Exception Raises exception + """ + cmd = self.run_command(['systemctl', action, target_service], + raiseonerr=False) + if cmd.returncode == 0: + time.sleep(10) + return cmd.returncode + else: + raise SSSDException('Unable to %s sssd' % action, 1) + def update_resolv_conf(self, ip_addr): """ Update /etc/resolv.conf with Windows AD IP address
_______________________________________________ sssd-devel mailing list -- sssd-devel@lists.fedorahosted.org To unsubscribe send an email to sssd-devel-le...@lists.fedorahosted.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedorahosted.org/archives/list/sssd-devel@lists.fedorahosted.org Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure