summaryrefslogtreecommitdiffstats
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
parent28e6d137afa65f638ea6e748eb39bce9aa83e403 (diff)
downloadfreeipa-feb01f4186dd76d2f9fc65d14f19ed73bea351eb.tar.gz
freeipa-feb01f4186dd76d2f9fc65d14f19ed73bea351eb.tar.xz
freeipa-feb01f4186dd76d2f9fc65d14f19ed73bea351eb.zip
First phase of iputil refactoring: introduce ipapython.services and ipapython.platform
-rw-r--r--Makefile8
-rwxr-xr-xinstall/tools/ipa-nis-manage11
-rwxr-xr-xinstall/tools/ipa-replica-install2
-rwxr-xr-xinstall/tools/ipa-server-install7
-rwxr-xr-xipa-client/ipa-install/ipa-client-install64
-rw-r--r--ipapython/Makefile4
-rw-r--r--ipapython/ipautil.py117
-rw-r--r--ipapython/platform/__init__.py23
-rw-r--r--ipapython/platform/redhat.py116
-rw-r--r--ipapython/setup.py.in2
-rw-r--r--ipaserver/install/bindinstance.py2
-rw-r--r--ipaserver/install/cainstance.py4
-rw-r--r--ipaserver/install/certs.py2
-rw-r--r--ipaserver/install/dsinstance.py6
-rw-r--r--ipaserver/install/httpinstance.py2
-rw-r--r--ipaserver/install/krbinstance.py2
-rw-r--r--ipaserver/install/ntpinstance.py4
-rw-r--r--ipaserver/install/service.py55
18 files changed, 307 insertions, 124 deletions
diff --git a/Makefile b/Makefile
index 6484dbbc9..9d8802587 100644
--- a/Makefile
+++ b/Makefile
@@ -8,6 +8,8 @@ PRJ_PREFIX=freeipa
RPMBUILD ?= $(PWD)/rpmbuild
TARGET ?= master
+SUPPORTED_PLATFORM=redhat
+
# After updating the version in VERSION you should run the version-update
# target.
@@ -109,6 +111,12 @@ version-update: release-update
ipa-client/ipa-client.spec.in > ipa-client/ipa-client.spec
sed -e s/__VERSION__/$(IPA_VERSION)/ ipa-client/version.m4.in \
> ipa-client/version.m4
+
+ if [ "$(SUPPORTED_PLATFORM)" != "" ]; then \
+ sed -e s/SUPPORTED_PLATFORM/$(SUPPORTED_PLATFORM)/ ipapython/services.py.in \
+ > ipapython/services.py; \
+ fi
+
if [ "$(SKIP_API_VERSION_CHECK)" != "yes" ]; then \
./makeapi --validate; \
fi
diff --git a/install/tools/ipa-nis-manage b/install/tools/ipa-nis-manage
index d875f96de..ca1505d2b 100755
--- a/install/tools/ipa-nis-manage
+++ b/install/tools/ipa-nis-manage
@@ -24,6 +24,7 @@ import os
try:
from optparse import OptionParser
from ipapython import ipautil, config
+ from ipapython import services as ipaservices
from ipaserver.install import installutils
from ipaserver.install.ldapupdate import LDAPUpdate, BadSyntax
from ipaserver.plugins.ldap2 import ldap2
@@ -143,15 +144,15 @@ def main():
# Enable either the portmap or rpcbind service
try:
- ipautil.run(["/sbin/chkconfig", "portmap", "on"])
- servicemsg = "portmap"
+ ipaservices.service_on(ipaservices.SERVICE_PORTMAP)
+ servicemsg = ipaservices.SERVICE_PORTMAP
except ipautil.CalledProcessError, cpe:
if cpe.returncode == 1:
try:
- ipautil.run(["/sbin/chkconfig", "rpcbind", "on"])
- servicemsg = "rpcbind"
+ ipaservices.service_on(ipaservices.SERVICE_RPCBIND)
+ servicemsg = ipaservices.SERVICE_RPCBIND
except ipautil.CalledProcessError, cpe:
- print "Unable to enable either portmap or rpcbind"
+ print "Unable to enable either %s or %s" % (ipaservices.SERVICE_PORTMAP, ipaservices.SERVICE_RPCBIND)
retval = 3
# The cn=config entry for the plugin may already exist but it
diff --git a/install/tools/ipa-replica-install b/install/tools/ipa-replica-install
index 6b97e0e93..e8c3fb59a 100755
--- a/install/tools/ipa-replica-install
+++ b/install/tools/ipa-replica-install
@@ -463,7 +463,7 @@ def main():
ds.init_memberof()
#Everything installed properly, activate ipa service.
- service.chkconfig_on('ipa')
+ service.service_on('ipa')
try:
if not os.geteuid()==0:
diff --git a/install/tools/ipa-server-install b/install/tools/ipa-server-install
index c87ba9e00..187885b7c 100755
--- a/install/tools/ipa-server-install
+++ b/install/tools/ipa-server-install
@@ -56,6 +56,7 @@ from ipaserver.plugins.ldap2 import ldap2
from ipapython import sysrestore
from ipapython.ipautil import *
+import ipapython.services as ipaservices
from ipalib import api, errors, util
from ipalib.parameters import IA5Str
from ipapython.config import IPAOptionParser
@@ -477,7 +478,7 @@ def uninstall():
except KeyError:
logging.info("Group %s already removed", dsinstance.DS_GROUP)
- service.chkconfig_off('ipa')
+ service.service_off('ipa')
return 0
@@ -947,7 +948,7 @@ def main():
os.remove(pw_name)
else:
http.create_instance(realm_name, host_name, domain_name, dm_password, autoconfig=True, self_signed_ca=options.selfsign, subject_base=options.subject, auto_redirect=options.ui_redirect)
- ipautil.run(["/sbin/restorecon", "/var/cache/ipa/sessions"])
+ ipaservices.restore_context("/var/cache/ipa/sessions")
set_subject_in_config(realm_name, dm_password, util.realm_to_suffix(realm_name), options.subject)
@@ -988,7 +989,7 @@ def main():
#Everything installed properly, activate ipa service.
- service.chkconfig_on('ipa')
+ service.service_on('ipa')
print "=============================================================================="
print "Setup complete"
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"
diff --git a/ipapython/Makefile b/ipapython/Makefile
index c96d5d9c1..7b046383a 100644
--- a/ipapython/Makefile
+++ b/ipapython/Makefile
@@ -3,7 +3,7 @@ PACKAGEDIR ?= $(DESTDIR)/$(PYTHONLIBDIR)/ipa
CONFIGDIR ?= $(DESTDIR)/etc/ipa
TESTS = $(wildcard test/*.py)
-SUBDIRS = py_default_encoding
+SUBDIRS = py_default_encoding platform
all:
@for subdir in $(SUBDIRS); do \
@@ -27,7 +27,7 @@ clean:
done
distclean: clean
- rm -f setup.py ipa-python.spec version.py
+ rm -f setup.py ipa-python.spec version.py services.py
@for subdir in $(SUBDIRS); do \
(cd $$subdir && $(MAKE) $@) || exit 1; \
done
diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py
index da6e94c85..0e2532dc9 100644
--- a/ipapython/ipautil.py
+++ b/ipapython/ipautil.py
@@ -1,6 +1,7 @@
# Authors: Simo Sorce <ssorce@redhat.com>
+# Alexander Bokovoy <abokovoy@redhat.com>
#
-# Copyright (C) 2007 Red Hat
+# Copyright (C) 2007-2011 Red Hat
# see file 'COPYING' for use and warranty information
#
# This program is free software; you can redistribute it and/or modify
@@ -1053,51 +1054,6 @@ def get_gsserror(e):
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])
def host_port_open(host, port, socket_stream=True, socket_timeout=None):
families = (socket.AF_INET, socket.AF_INET6)
@@ -1171,3 +1127,72 @@ def bind_port_responder(port, socket_stream=True, socket_timeout=None, responder
s.sendto(responder_data, addr)
finally:
s.close()
+
+class AuthConfig:
+ """
+ AuthConfig class implements system-independent interface to configure
+ system authentication resources. In Red Hat systems this is done with
+ authconfig(8) utility.
+
+ AuthConfig class is nothing more than a tool to gather configuration options
+ and execute their processing. These options then converted by an actual implementation
+ to series of a system calls to appropriate utilities performing real configuration.
+
+ Actual implementation should be done in ipapython/platform/<platform>.py by inheriting from ipautil.AuthConfig
+ and redefining __build_args() and execute() methods.
+ ....
+ class PlatformAuthConfig(ipautil.AuthConfig):
+ def __build_args():
+ ...
+
+ def execute():
+ ...
+
+ authconfig = PlatformAuthConfig
+ ....
+
+ See ipapython/platform/redhat.py for a sample implementation that uses authconfig(8) as its backend.
+
+ From IPA perspective, the authentication configuration should be done with use of ipapython.services.authconfig:
+
+ auth_config = ipapython.services.authconfig()
+ auth_config.disable("ldap").\
+ disable("krb5").\
+ disable("sssd").\
+ disable("sssdauth").\
+ disable("mkhomedir").\
+ add_option("update").\
+ enable("nis").\
+ add_parameter("nisdomain","foobar")
+ auth_config.execute()
+ """
+
+ def __init__(self):
+ self.parameters = {}
+
+ def enable(self, option):
+ self.parameters[option] = True
+ return self
+
+ def disable(self, option):
+ self.parameters[option] = False
+ return self
+
+ def add_option(self, option):
+ self.parameters[option] = None
+ return self
+
+ def add_parameter(self, option, value):
+ self.parameters[option] = [value]
+ return self
+
+ def __build_args(self):
+ # do nothing
+ return None
+
+ def execute(self):
+ # do nothing
+ return None
+
+
+
diff --git a/ipapython/platform/__init__.py b/ipapython/platform/__init__.py
new file mode 100644
index 000000000..e0a394b02
--- /dev/null
+++ b/ipapython/platform/__init__.py
@@ -0,0 +1,23 @@
+# Authors:
+# Alexander Bokovoy <abokovoy@redhat.com>
+#
+# Copyright (C) 2011 Red Hat
+# see file 'COPYING' for use and warranty information
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""
+Sub-package containing all platform-specific adaptation for ipapython.services.
+Should not be used directly.
+"""
diff --git a/ipapython/platform/redhat.py b/ipapython/platform/redhat.py
new file mode 100644
index 000000000..c6d2631cd
--- /dev/null
+++ b/ipapython/platform/redhat.py
@@ -0,0 +1,116 @@
+# Authors: Simo Sorce <ssorce@redhat.com>
+# Alexander Bokovoy <abokovoy@redhat.com>
+#
+# Copyright (C) 2007-2011 Red Hat
+# see file 'COPYING' for use and warranty information
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+from ipapython import ipautil
+
+SERVICE_PORTMAP = "portmap"
+SERVICE_RPCBIND = "rpcbind"
+SERVICE_CERTMONGER = "certmonger"
+SERVICE_NSCD = "nscd"
+SERVICE_NLSCD = "nlscd"
+
+def service_stop(service_name, instance_name="", capture_output=True):
+ ipautil.run(["/sbin/service", service_name, "stop", instance_name],
+ capture_output=capture_output)
+
+def service_start(service_name, instance_name="", capture_output=True):
+ ipautil.run(["/sbin/service", service_name, "start", instance_name],
+ capture_output=capture_output)
+
+def service_restart(service_name, instance_name="", capture_output=True):
+ ipautil.run(["/sbin/service", service_name, "restart", instance_name],
+ capture_output=capture_output)
+
+def service_is_running(service_name, instance_name=""):
+ ret = True
+ try:
+ ipautil.run(["/sbin/service", service_name, "status", instance_name])
+ except ipautil.CalledProcessError:
+ ret = False
+ return ret
+
+def service_is_installed(service_name):
+ installed = True
+ try:
+ ipautil.run(["/sbin/service", service_name, "status"])
+ except ipautil.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) = ipautil.run(["/sbin/chkconfig", service_name], raiseonerr=False)
+ return (returncode == 0)
+
+def service_on(service_name):
+ ipautil.run(["/sbin/chkconfig", service_name, "on"])
+
+def service_off(service_name):
+ ipautil.run(["/sbin/chkconfig", service_name, "off"])
+
+def service_add(service_name):
+ ipautil.run(["/sbin/chkconfig", "--add", service_name])
+
+def service_del(service_name):
+ ipautil.run(["/sbin/chkconfig", "--del", service_name])
+
+def restore_context(dirname):
+ """
+ restore security context on the directory
+ SE Linux equivalent is /sbin/restorecon <dirname>
+ """
+ ipautil.run(["/sbin/restorecon", dirname])
+
+class RedHatAuthConfig(ipautil.AuthConfig):
+ """
+ AuthConfig class implements system-independent interface to configure
+ system authentication resources. In Red Hat-produced systems this is done with
+ authconfig(8) utility.
+
+ """
+ S_SHADOW = "shadow"
+ S_MD5 = "md5"
+ S_NIS = "nis"
+ S_LDAP = "ldap"
+ S_SSSD = "sssd"
+
+ def __build_args(self):
+ args = []
+ for (option, value) in self.parameters.items():
+ if type(value) is bool:
+ if value:
+ args.append("--enable%s" % (option))
+ else:
+ args.append("--disable%s" % (option))
+ elif type(value) in (tuple, list):
+ args.append("--%s" % (option))
+ args.append("%s" % (value[0]))
+ elif value is None:
+ args.append("--%s" % (option))
+ else:
+ args.append("--%s%s" % (option,value))
+ return args
+
+ def execute(self):
+ args = self.__build_args()
+ ipautil.run(["/usr/sbin/authconfig"]+args)
+
+authconfig = RedHatAuthConfig
diff --git a/ipapython/setup.py.in b/ipapython/setup.py.in
index d9ee28c55..df1cacf85 100644
--- a/ipapython/setup.py.in
+++ b/ipapython/setup.py.in
@@ -65,7 +65,7 @@ def setup_package():
classifiers=filter(None, CLASSIFIERS.split('\n')),
platforms = ["Linux", "Solaris", "Unix"],
package_dir = {'ipapython': ''},
- packages = [ "ipapython" ],
+ packages = [ "ipapython", "ipapython.platform" ],
)
finally:
del sys.path[0]
diff --git a/ipaserver/install/bindinstance.py b/ipaserver/install/bindinstance.py
index 676b1a476..7f7d67b41 100644
--- a/ipaserver/install/bindinstance.py
+++ b/ipaserver/install/bindinstance.py
@@ -608,7 +608,7 @@ class BindInstance(service.Service):
pass
if not enabled is None and not enabled:
- self.chkconfig_off()
+ self.service_off()
if not running is None and running:
self.start()
diff --git a/ipaserver/install/cainstance.py b/ipaserver/install/cainstance.py
index 5c6c49e4b..a5b5500e1 100644
--- a/ipaserver/install/cainstance.py
+++ b/ipaserver/install/cainstance.py
@@ -397,7 +397,7 @@ class CADSInstance(service.Service):
self.stop(serverid)
if not enabled is None and not enabled:
- self.chkconfig_off()
+ self.service_off()
if not serverid is None:
# drop the trailing / off the config_dirname so the directory
@@ -1054,7 +1054,7 @@ class CAInstance(service.Service):
enabled = self.restore_state("enabled")
if not enabled is None and not enabled:
- self.chkconfig_off()
+ self.service_off()
try:
ipautil.run(["/usr/bin/pkiremove", "-pki_instance_root=/var/lib",
diff --git a/ipaserver/install/certs.py b/ipaserver/install/certs.py
index f14efe33f..99045dcbb 100644
--- a/ipaserver/install/certs.py
+++ b/ipaserver/install/certs.py
@@ -483,7 +483,7 @@ class CertDB(object):
"""
Tell certmonger to track the given certificate nickname.
"""
- service.chkconfig_on("certmonger")
+ service.service_on("certmonger")
service.start("messagebus")
service.start("certmonger")
try:
diff --git a/ipaserver/install/dsinstance.py b/ipaserver/install/dsinstance.py
index 50060832e..deebd221f 100644
--- a/ipaserver/install/dsinstance.py
+++ b/ipaserver/install/dsinstance.py
@@ -324,8 +324,8 @@ class DsInstance(service.Service):
self.backup_state("enabled", self.is_enabled())
# At the end of the installation ipa-server-install will enable the
# 'ipa' service wich takes care of starting/stopping dirsrv
- # self.chkconfig_on()
- self.chkconfig_off()
+ # self.service_on()
+ self.service_off()
def __setup_sub_dict(self):
server_root = find_server_root()
@@ -657,7 +657,7 @@ class DsInstance(service.Service):
pass
if not enabled is None and not enabled:
- self.chkconfig_off()
+ self.service_off()
serverid = self.restore_state("serverid")
if not serverid is None:
diff --git a/ipaserver/install/httpinstance.py b/ipaserver/install/httpinstance.py
index fe5f7aa95..6a863cb17 100644
--- a/ipaserver/install/httpinstance.py
+++ b/ipaserver/install/httpinstance.py
@@ -259,7 +259,7 @@ class HTTPInstance(service.Service):
db = certs.CertDB(api.env.realm)
db.untrack_server_cert("Server-Cert")
if not enabled is None and not enabled:
- self.chkconfig_off()
+ self.service_off()
for f in ["/etc/httpd/conf.d/ipa.conf", SSL_CONF, NSS_CONF]:
try:
diff --git a/ipaserver/install/krbinstance.py b/ipaserver/install/krbinstance.py
index 5326e2f23..1f66723c7 100644
--- a/ipaserver/install/krbinstance.py
+++ b/ipaserver/install/krbinstance.py
@@ -572,7 +572,7 @@ class KrbInstance(service.Service):
pass
if not enabled is None and not enabled:
- self.chkconfig_off()
+ self.service_off()
if not running is None and running:
self.start()
diff --git a/ipaserver/install/ntpinstance.py b/ipaserver/install/ntpinstance.py
index d85e430b7..7fc16d495 100644
--- a/ipaserver/install/ntpinstance.py
+++ b/ipaserver/install/ntpinstance.py
@@ -143,7 +143,7 @@ class NTPInstance(service.Service):
def __enable(self):
self.backup_state("enabled", self.is_enabled())
- self.chkconfig_on()
+ self.service_on()
def create_instance(self):
@@ -174,7 +174,7 @@ class NTPInstance(service.Service):
pass
if not enabled is None and not enabled:
- self.chkconfig_off()
+ self.service_off()
if not running is None and running:
self.start()
diff --git a/ipaserver/install/service.py b/ipaserver/install/service.py
index 62db9baf5..0d8398bdf 100644
--- a/ipaserver/install/service.py
+++ b/ipaserver/install/service.py
@@ -22,6 +22,7 @@ import os, socket
import tempfile
from ipapython import sysrestore
from ipapython import ipautil
+from ipapython import services as ipaservices
from ipalib import errors
import ldap
from ipaserver import ipaldap
@@ -41,34 +42,34 @@ SERVICE_LIST = {
}
def stop(service_name, instance_name="", capture_output=True):
- ipautil.service_stop(service_name, instance_name, capture_output)
+ ipaservices.service_stop(service_name, instance_name, capture_output)
def start(service_name, instance_name="", capture_output=True):
- ipautil.service_start(service_name, instance_name, capture_output)
+ ipaservices.service_start(service_name, instance_name, capture_output)
def restart(service_name, instance_name="", capture_output=True):
- ipautil.service_restart(service_name, instance_name, capture_output)
+ ipaservices.service_restart(service_name, instance_name, capture_output)
def is_running(service_name, instance_name=""):
- return ipautil.service_is_running(service_name, instance_name)
+ return ipaservices.service_is_running(service_name, instance_name)
def is_installed(service_name):
- return ipautil.service_is_installed(service_name)
+ return ipaservices.service_is_installed(service_name)
-def chkconfig_on(service_name):
- ipautil.chkconfig_on(service_name)
+def service_on(service_name):
+ ipaservices.service_on(service_name)
-def chkconfig_off(service_name):
- ipautil.chkconfig_on(service_name)
+def service_off(service_name):
+ ipaservices.service_on(service_name)
-def chkconfig_add(service_name):
- ipautil.chkconfig_on(service_name)
+def service_add(service_name):
+ ipaservices.service_on(service_name)
-def chkconfig_del(service_name):
- ipautil.chkconfig_on(service_name)
+def service_del(service_name):
+ ipaservices.service_on(service_name)
def is_enabled(service_name):
- return ipautil.service_is_enabled(service_name)
+ return ipaservices.service_is_enabled(service_name)
def print_msg(message, output_fd=sys.stdout):
logging.debug(message)
@@ -224,17 +225,17 @@ class Service(object):
def is_running(self):
return is_running(self.service_name)
- def chkconfig_add(self):
- chkconfig_add(self.service_name)
+ def service_add(self):
+ service_add(self.service_name)
- def chkconfig_del(self):
- chkconfig_del(self.service_name)
+ def service_del(self):
+ service_del(self.service_name)
- def chkconfig_on(self):
- chkconfig_on(self.service_name)
+ def service_on(self):
+ service_on(self.service_name)
- def chkconfig_off(self):
- chkconfig_off(self.service_name)
+ def service_off(self):
+ service_off(self.service_name)
def is_enabled(self):
return is_enabled(self.service_name)
@@ -300,7 +301,7 @@ class Service(object):
return conn
def ldap_enable(self, name, fqdn, dm_password, ldap_suffix):
- self.chkconfig_off()
+ self.service_off()
conn = self.__get_conn(fqdn, dm_password)
entry_name = "cn=%s,cn=%s,%s,%s" % (name, fqdn,
@@ -336,10 +337,10 @@ class SimpleServiceInstance(Service):
self.restart()
def __enable(self):
- self.chkconfig_add()
+ self.service_add()
self.backup_state("enabled", self.is_enabled())
if self.gensvc_name == None:
- self.chkconfig_on()
+ self.service_on()
else:
self.ldap_enable(self.gensvc_name, self.fqdn,
self.dm_password, self.suffix)
@@ -354,5 +355,5 @@ class SimpleServiceInstance(Service):
if not running is None and not running:
self.stop()
if not enabled is None and not enabled:
- self.chkconfig_off()
- self.chkconfig_del()
+ self.service_off()
+ self.service_del()