summaryrefslogtreecommitdiffstats
path: root/ipa-client
diff options
context:
space:
mode:
authorAlexander Bokovoy <abokovoy@redhat.com>2011-07-20 20:20:22 +0300
committerAlexander Bokovoy <abokovoy@redhat.com>2011-08-30 11:41:03 +0300
commitfeb01f4186dd76d2f9fc65d14f19ed73bea351eb (patch)
treecd2acf87fb645e9f37f3ec040b2bffdc0ac8c1cf /ipa-client
parent28e6d137afa65f638ea6e748eb39bce9aa83e403 (diff)
downloadfreeipa-feb01f4186dd76d2f9fc65d14f19ed73bea351eb.tar.gz
freeipa-feb01f4186dd76d2f9fc65d14f19ed73bea351eb.tar.xz
freeipa-feb01f4186dd76d2f9fc65d14f19ed73bea351eb.zip
First phase of iputil refactoring: introduce ipapython.services and ipapython.platform
Diffstat (limited to 'ipa-client')
-rwxr-xr-xipa-client/ipa-install/ipa-client-install64
1 files changed, 36 insertions, 28 deletions
diff --git a/ipa-client/ipa-install/ipa-client-install b/ipa-client/ipa-install/ipa-client-install
index 64c5bf2c6..495b7f211 100755
--- a/ipa-client/ipa-install/ipa-client-install
+++ b/ipa-client/ipa-install/ipa-client-install
@@ -34,6 +34,7 @@ try:
import ipaclient.ipachangeconf
import ipaclient.ntpconf
from ipapython.ipautil import run, user_input, CalledProcessError, file_exists, install_file
+ import ipapython.services as ipaservices
from ipapython import ipautil
from ipapython import dnsclient
from ipapython import sysrestore
@@ -183,19 +184,19 @@ def uninstall(options, env):
# Always start certmonger. We can't untrack something if it isn't
# running
try:
- ipautil.service_start('messagebus')
+ ipaservices.service_start('messagebus')
except Exception, e:
logging.error("messagebus failed to start: %s" % str(e))
try:
- ipautil.service_start('certmonger')
+ ipaservices.service_start(ipaservices.SERVICE_CERTMONGER)
except Exception, e:
logging.error("certmonger failed to start: %s" % str(e))
try:
certmonger.stop_tracking('/etc/pki/nssdb', nickname=client_nss_nickname)
except (CalledProcessError, RuntimeError), e:
- logging.error("certmonger failed to stop tracking certificate: %s" % str(e))
+ logging.error("%s failed to stop tracking certificate: %s" % (ipaservices.SERVICE_CERTMONGER, str(e)))
if nickname_exists(client_nss_nickname):
try:
@@ -204,18 +205,18 @@ def uninstall(options, env):
print "Failed to remove %s from /etc/pki/nssdb: %s" % (client_nss_nickname, str(e))
try:
- ipautil.service_stop('certmonger')
+ ipaservices.service_stop(ipaservices.SERVICE_CERTMONGER)
except Exception, e:
- logging.error("certmonger failed to stop: %s" % str(e))
+ logging.error("%s failed to stop: %s" % (ipaservices.SERVICE_CERTMONGER, str(e)))
# Remove any special principal names we added to the IPA CA helper
certmonger.remove_principal_from_cas()
try:
- ipautil.chkconfig_off('certmonger')
+ ipaservices.service_off(ipaservices.SERVICE_CERTMONGER)
except Exception, e:
- print "Failed to disable automatic startup of the certmonger daemon"
- logging.error("Failed to disable automatic startup of the certmonger daemon: %s" % str(e))
+ print "Failed to disable automatic startup of the %s service" % (ipaservices.SERVICE_CERTMONGER)
+ logging.error("Failed to disable automatic startup of the %s service: %s" % (ipaservices.SERVICE_CERTMONGER, str(e)))
if not options.on_master:
print "Unenrolling client from IPA server"
@@ -238,7 +239,14 @@ def uninstall(options, env):
print "Disabling client Kerberos and LDAP configurations"
try:
- run(["/usr/sbin/authconfig", "--disableldap", "--disablekrb5", "--disablesssd", "--disablesssdauth", "--disablemkhomedir", "--update"])
+ auth_config = ipaservices.authconfig()
+ auth_config.disable("ldap").\
+ disable("krb5").\
+ disable("sssd").\
+ disable("sssdauth").\
+ disable("mkhomedir").\
+ add_option("update")
+ auth_config.execute()
except Exception, e:
print "Failed to remove krb5/LDAP configuration. " +str(e)
sys.exit(1)
@@ -252,28 +260,28 @@ def uninstall(options, env):
except CalledProcessError, e:
print >>sys.stderr, "Failed to set this machine hostname to %s (%s)." % (old_hostname, str(e))
- if ipautil.service_is_installed('nscd'):
+ if ipaservices.service_is_installed('nscd'):
try:
- ipautil.service_restart('nscd')
+ ipaservices.service_restart('nscd')
except:
print "Failed to restart start the NSCD daemon"
try:
- ipautil.chkconfig_on('nscd')
+ ipaservices.service_on('nscd')
except:
print "Failed to configure automatic startup of the NSCD daemon"
else:
# this is optional service, just log
logging.info("NSCD daemon is not installed, skip configuration")
- if ipautil.service_is_installed('nslcd'):
+ if ipaservices.service_is_installed('nslcd'):
try:
- ipautil.service_stop('nslcd')
+ ipaservices.service_stop('nslcd')
except:
print "Failed to stop the NSLCD daemon"
try:
- ipautil.chkconfig_off('nslcd')
+ ipaservices.service_off('nslcd')
except:
print "Failed to disable automatic startup of the NSLCD daemon"
else:
@@ -398,14 +406,14 @@ def configure_nslcd_conf(fstore, cli_basedn, cli_realm, cli_domain, cli_server,
print "Creation of %s: %s" % ('/etc/nslcd.conf', str(e))
return (1, None, None)
- if ipautil.service_is_installed('nslcd'):
+ if ipaservices.service_is_installed('nslcd'):
try:
- ipautil.service_restart('nslcd')
+ ipaservices.service_restart('nslcd')
except Exception, e:
logging.error("nslcd failed to restart: %s" % str(e))
try:
- ipautil.chkconfig_on('nslcd')
+ ipaservices.service_on('nslcd')
except Exception, e:
print "Failed to configure automatic startup of the NSLCD daemon"
logging.error("Failed to enable automatic startup of the NSLCD daemon: %s" % str(e))
@@ -506,14 +514,14 @@ def configure_certmonger(fstore, subject_base, cli_realm, hostname, options):
# Ensure that certmonger has been started at least once to generate the
# cas files in /var/lib/certmonger/cas.
try:
- ipautil.service_restart('certmonger')
+ ipaservices.service_restart('certmonger')
except Exception, e:
logging.error("certmonger failed to restart: %s" % str(e))
if options.hostname:
# It needs to be stopped if we touch them
try:
- ipautil.service_stop('certmonger')
+ ipaservices.service_stop('certmonger')
except Exception, e:
logging.error("certmonger failed to stop: %s" % str(e))
# If the hostname is explicitly set then we need to tell certmonger
@@ -521,7 +529,7 @@ def configure_certmonger(fstore, subject_base, cli_realm, hostname, options):
certmonger.add_principal_to_cas(principal)
try:
- ipautil.service_restart('certmonger')
+ ipaservices.service_restart('certmonger')
except Exception, e:
print "Failed to start the certmonger daemon"
print "Automatic certificate management will not be available"
@@ -529,7 +537,7 @@ def configure_certmonger(fstore, subject_base, cli_realm, hostname, options):
started = False
try:
- ipautil.chkconfig_on('certmonger')
+ ipaservices.service_on('certmonger')
except Exception, e:
print "Failed to configure automatic startup of the certmonger daemon"
print "Automatic certificate management will not be available"
@@ -998,15 +1006,15 @@ def main():
client_dns(cli_server, hostname, options.dns_updates)
#Name Server Caching Daemon. Disable for SSSD, use otherwise (if installed)
- if ipautil.service_is_installed("nscd"):
+ if ipaservices.service_is_installed("nscd"):
if options.sssd:
nscd_service_action = "stop"
- nscd_service_cmd = ipautil.service_stop
- nscd_chkconfig_cmd = ipautil.chkconfig_off
+ nscd_service_cmd = ipaservices.service_stop
+ nscd_service_cmd = ipaservices.service_off
else:
nscd_service_action = "restart"
- nscd_service_cmd = ipautil.service_restart
- nscd_chkconfig_cmd = ipautil.chkconfig_on
+ nscd_service_cmd = ipaservices.service_restart
+ nscd_service_cmd = ipaservices.service_on
try:
nscd_service_cmd('nscd')
@@ -1016,7 +1024,7 @@ def main():
print >>sys.stderr, "Caching of users/groups will not be available"
try:
- nscd_chkconfig_cmd('nscd')
+ nscd_service_cmd('nscd')
except:
if not options.sssd:
print >>sys.stderr, "Failed to configure automatic startup of the NSCD daemon"