diff options
author | Martin Kosek <mkosek@redhat.com> | 2011-05-10 15:14:20 +0200 |
---|---|---|
committer | Martin Kosek <mkosek@redhat.com> | 2011-05-13 13:24:35 +0200 |
commit | 2cbc6fd6a2c33b46f97658b613bfca9182a5b518 (patch) | |
tree | df9fa64a72af04f5283f3e5218373a41b85ef9f2 /ipapython | |
parent | 72b56e4630f99608808522b2b5f768497f94d2bd (diff) | |
download | freeipa-2cbc6fd6a2c33b46f97658b613bfca9182a5b518.tar.gz freeipa-2cbc6fd6a2c33b46f97658b613bfca9182a5b518.tar.xz freeipa-2cbc6fd6a2c33b46f97658b613bfca9182a5b518.zip |
Improve service manipulation in client install
Remove redundant ipa-client-install error message when optional nscd
daemon was not installed. Additionally, use standard IPA functions
for service manipulation and improve logging.
https://fedorahosted.org/freeipa/ticket/1207
Diffstat (limited to 'ipapython')
-rw-r--r-- | ipapython/ipautil.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py index b5a0b9105..4280cd9f4 100644 --- a/ipapython/ipautil.py +++ b/ipapython/ipautil.py @@ -967,3 +967,51 @@ def get_gsserror(e): minor = e[0][1] return (major, minor) + + +def service_stop(service_name, instance_name="", capture_output=True): + run(["/sbin/service", service_name, "stop", instance_name], + capture_output=capture_output) + +def service_start(service_name, instance_name="", capture_output=True): + run(["/sbin/service", service_name, "start", instance_name], + capture_output=capture_output) + +def service_restart(service_name, instance_name="", capture_output=True): + run(["/sbin/service", service_name, "restart", instance_name], + capture_output=capture_output) + +def service_is_running(service_name, instance_name=""): + ret = True + try: + run(["/sbin/service", service_name, "status", instance_name]) + except CalledProcessError: + ret = False + return ret + +def service_is_installed(service_name): + installed = True + try: + run(["/sbin/service", service_name, "status"]) + except CalledProcessError, e: + if e.returncode == 1: + # service is not installed or there is other serious issue + installed = False + return installed + +def service_is_enabled(service_name): + (stdout, stderr, returncode) = run(["/sbin/chkconfig", service_name], raiseonerr=False) + return (returncode == 0) + +def chkconfig_on(service_name): + run(["/sbin/chkconfig", service_name, "on"]) + +def chkconfig_off(service_name): + run(["/sbin/chkconfig", service_name, "off"]) + +def chkconfig_add(service_name): + run(["/sbin/chkconfig", "--add", service_name]) + +def chkconfig_del(service_name): + run(["/sbin/chkconfig", "--del", service_name]) + |