summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Babej <tbabej@redhat.com>2014-05-29 10:37:18 +0200
committerPetr Viktorin <pviktori@redhat.com>2014-06-16 19:48:19 +0200
commit49fcd42f8fd71b894a0953a37f10a6c326e16048 (patch)
tree0c1324c5a3183ce20e92af183ffefde92a77147a
parent926f8647d2a676c1dd2e446633eb76cdf1a7bf0c (diff)
downloadfreeipa-49fcd42f8fd71b894a0953a37f10a6c326e16048.tar.gz
freeipa-49fcd42f8fd71b894a0953a37f10a6c326e16048.tar.xz
freeipa-49fcd42f8fd71b894a0953a37f10a6c326e16048.zip
ipaplatform: Change service code in freeipa to use ipaplatform services
https://fedorahosted.org/freeipa/ticket/4052 Reviewed-By: Petr Viktorin <pviktori@redhat.com>
-rw-r--r--install/restart_scripts/renew_ca_cert5
-rw-r--r--install/restart_scripts/renew_ra_cert3
-rw-r--r--install/restart_scripts/restart_dirsrv3
-rw-r--r--install/restart_scripts/restart_httpd3
-rw-r--r--install/restart_scripts/stop_pkicad3
-rwxr-xr-xinstall/share/copy-schema-to-ca.py3
-rwxr-xr-xinstall/tools/ipa-ca-install3
-rwxr-xr-xinstall/tools/ipa-nis-manage5
-rwxr-xr-xinstall/tools/ipa-replica-install5
-rwxr-xr-xinstall/tools/ipa-server-install7
-rwxr-xr-xinstall/tools/ipactl25
-rwxr-xr-xipa-client/ipa-install/ipa-client-automount17
-rwxr-xr-xipa-client/ipa-install/ipa-client-install56
-rw-r--r--ipa-client/ipaclient/ntpconf.py19
-rw-r--r--ipaserver/install/adtrustinstance.py9
-rw-r--r--ipaserver/install/cainstance.py19
-rw-r--r--ipaserver/install/certs.py9
-rw-r--r--ipaserver/install/dsinstance.py7
-rw-r--r--ipaserver/install/installutils.py7
-rw-r--r--ipaserver/install/ipa_backup.py3
-rw-r--r--ipaserver/install/ipa_restore.py9
-rw-r--r--ipaserver/install/replication.py3
-rw-r--r--ipaserver/install/service.py3
23 files changed, 124 insertions, 102 deletions
diff --git a/install/restart_scripts/renew_ca_cert b/install/restart_scripts/renew_ca_cert
index 2663887d6..550de969a 100644
--- a/install/restart_scripts/renew_ca_cert
+++ b/install/restart_scripts/renew_ca_cert
@@ -32,6 +32,7 @@ from ipapython import services as ipaservices
from ipalib import api, errors, x509, util
from ipaserver.install import certs, cainstance, installutils
from ipaserver.plugins.ldap2 import ldap2
+from ipaplatform import services
def main():
nickname = sys.argv[1]
@@ -41,7 +42,7 @@ def main():
configured_constants = dogtag.configured_constants(api)
alias_dir = configured_constants.ALIAS_DIR
- dogtag_service = ipaservices.knownservices[configured_constants.SERVICE_NAME]
+ dogtag_service = services.knownservices[configured_constants.SERVICE_NAME]
dogtag_instance = configured_constants.PKI_INSTANCE_NAME
# dogtag opens its NSS database in read/write mode so we need it
@@ -89,7 +90,7 @@ def main():
"Updating trust on certificate %s failed in %s" %
(nickname, db.secdir))
- # Now we can start the CA. Using the ipaservices start should fire
+ # Now we can start the CA. Using the services start should fire
# off the servlet to verify that the CA is actually up and responding so
# when this returns it should be good-to-go. The CA was stopped in the
# pre-save state.
diff --git a/install/restart_scripts/renew_ra_cert b/install/restart_scripts/renew_ra_cert
index 79bc4cf58..46367fd9c 100644
--- a/install/restart_scripts/renew_ra_cert
+++ b/install/restart_scripts/renew_ra_cert
@@ -27,6 +27,7 @@ import traceback
from ipapython import services as ipaservices
from ipalib import api
from ipaserver.install import certs, cainstance
+from ipaplatform import services
nickname = 'ipaCert'
@@ -49,7 +50,7 @@ def main():
# Now restart Apache so the new certificate is available
syslog.syslog(syslog.LOG_NOTICE, "Restarting httpd")
try:
- ipaservices.knownservices.httpd.restart()
+ services.knownservices.httpd.restart()
except Exception, e:
syslog.syslog(syslog.LOG_ERR, "Cannot restart httpd: %s" % e)
else:
diff --git a/install/restart_scripts/restart_dirsrv b/install/restart_scripts/restart_dirsrv
index 03e6a5c42..738bb3120 100644
--- a/install/restart_scripts/restart_dirsrv
+++ b/install/restart_scripts/restart_dirsrv
@@ -24,6 +24,7 @@ import syslog
import traceback
from ipapython import services as ipaservices
from ipalib import api
+from ipaplatform import services
def main():
try:
@@ -37,7 +38,7 @@ def main():
syslog.syslog(syslog.LOG_NOTICE, "certmonger restarted dirsrv instance '%s'" % instance)
try:
- ipaservices.knownservices.dirsrv.restart(instance)
+ services.knownservices.dirsrv.restart(instance)
except Exception, e:
syslog.syslog(syslog.LOG_ERR, "Cannot restart dirsrv (instance: '%s'): %s" % (instance, str(e)))
diff --git a/install/restart_scripts/restart_httpd b/install/restart_scripts/restart_httpd
index 98337bc85..e8ff72824 100644
--- a/install/restart_scripts/restart_httpd
+++ b/install/restart_scripts/restart_httpd
@@ -22,12 +22,13 @@
import syslog
import traceback
from ipapython import services as ipaservices
+from ipaplatform import services
def main():
syslog.syslog(syslog.LOG_NOTICE, 'certmonger restarted httpd')
try:
- ipaservices.knownservices.httpd.restart()
+ services.knownservices.httpd.restart()
except Exception, e:
syslog.syslog(syslog.LOG_ERR, "Cannot restart httpd: %s" % str(e))
diff --git a/install/restart_scripts/stop_pkicad b/install/restart_scripts/stop_pkicad
index e58e04401..461baa6a5 100644
--- a/install/restart_scripts/stop_pkicad
+++ b/install/restart_scripts/stop_pkicad
@@ -25,13 +25,14 @@ import traceback
from ipapython import services as ipaservices
from ipapython import dogtag
from ipalib import api
+from ipaplatform import services
def main():
api.bootstrap(context='restart')
api.finalize()
configured_constants = dogtag.configured_constants(api)
- dogtag_service = ipaservices.knownservices[configured_constants.SERVICE_NAME]
+ dogtag_service = services.knownservices[configured_constants.SERVICE_NAME]
dogtag_instance = configured_constants.PKI_INSTANCE_NAME
syslog.syslog(syslog.LOG_NOTICE, "Stopping %s" % dogtag_service.service_name)
diff --git a/install/share/copy-schema-to-ca.py b/install/share/copy-schema-to-ca.py
index a5646cd6b..68f7dfdbd 100755
--- a/install/share/copy-schema-to-ca.py
+++ b/install/share/copy-schema-to-ca.py
@@ -15,7 +15,8 @@ import sys
import pwd
import shutil
-from ipapython import services, ipautil, dogtag
+from ipaplatform import services
+from ipapython import ipautil, dogtag
from ipapython.ipa_log_manager import root_logger, standard_logging_setup
from ipaserver.install.dsinstance import DS_USER, schema_dirname
from ipaserver.install.cainstance import PKI_USER
diff --git a/install/tools/ipa-ca-install b/install/tools/ipa-ca-install
index 18c81dc1f..630c83815 100755
--- a/install/tools/ipa-ca-install
+++ b/install/tools/ipa-ca-install
@@ -40,6 +40,7 @@ from ipapython.config import IPAOptionParser
from ipapython import sysrestore
from ipapython import dogtag
from ipapython.ipa_log_manager import *
+from ipaplatform import services
log_file_name = "/var/log/ipareplica-ca-install.log"
REPLICA_INFO_TOP_DIR = None
@@ -190,7 +191,7 @@ def main():
install_dns_records(config, options)
# We need to restart apache as we drop a new config file in there
- ipaservices.knownservices.httpd.restart(capture_output=True)
+ services.knownservices.httpd.restart(capture_output=True)
#update dogtag version in config file
try:
diff --git a/install/tools/ipa-nis-manage b/install/tools/ipa-nis-manage
index 229b6b02d..b37cd6594 100755
--- a/install/tools/ipa-nis-manage
+++ b/install/tools/ipa-nis-manage
@@ -31,6 +31,7 @@ try:
from ipalib import api, errors
from ipapython.ipa_log_manager import *
from ipapython.dn import DN
+ from ipaplatform import services
except ImportError:
print >> sys.stderr, """\
There was a problem importing one of the required Python modules. The
@@ -142,13 +143,13 @@ def main():
# Enable either the portmap or rpcbind service
try:
- portmap = ipaservices.knownservices.portmap
+ portmap = services.knownservices.portmap
portmap.enable()
servicemsg = portmap.service_name
except ipautil.CalledProcessError, cpe:
if cpe.returncode == 1:
try:
- rpcbind = ipaservices.knownservices.rpcbind
+ rpcbind = services.knownservices.rpcbind
rpcbind.enable()
servicemsg = rpcbind.service_name
except ipautil.CalledProcessError, cpe:
diff --git a/install/tools/ipa-replica-install b/install/tools/ipa-replica-install
index 9452c6fcb..1c0488e5f 100755
--- a/install/tools/ipa-replica-install
+++ b/install/tools/ipa-replica-install
@@ -52,6 +52,7 @@ from ipapython import dogtag
from ipapython.dn import DN
import ipaclient.ntpconf
from ipaplatform import tasks
+from ipaplatform import services
log_file_name = "/var/log/ipareplica-install.log"
REPLICA_INFO_TOP_DIR = None
@@ -698,7 +699,7 @@ def main():
CA.configure_certmonger_renewal()
CA.import_ra_cert(dir + "/ra.p12")
CA.fix_ra_perms()
- ipaservices.knownservices.httpd.restart()
+ services.knownservices.httpd.restart()
# The DS instance is created before the keytab, add the SSL cert we
# generated
@@ -748,7 +749,7 @@ def main():
ds.replica_populate()
#Everything installed properly, activate ipa service.
- ipaservices.knownservices.ipa.enable()
+ services.knownservices.ipa.enable()
fail_message = '''
Your system may be partly configured.
diff --git a/install/tools/ipa-server-install b/install/tools/ipa-server-install
index 00614b64e..19a0bab94 100755
--- a/install/tools/ipa-server-install
+++ b/install/tools/ipa-server-install
@@ -79,6 +79,7 @@ from ipapython.dn import DN
import ipaclient.ntpconf
from ipaplatform import tasks
+from ipaplatform import services
uninstalling = False
installation_cleanup = True
@@ -521,7 +522,7 @@ def uninstall():
group_exists = sstore.restore_state("install", "group_exists")
- ipaservices.knownservices.ipa.disable()
+ services.knownservices.ipa.disable()
ipautil.restore_hostname(sstore)
@@ -1218,7 +1219,7 @@ def main():
#Everything installed properly, activate ipa service.
- ipaservices.knownservices.ipa.enable()
+ services.knownservices.ipa.enable()
print "=============================================================================="
print "Setup complete"
@@ -1242,7 +1243,7 @@ def main():
print "\t This ticket will allow you to use the IPA tools (e.g., ipa user-add)"
print "\t and the web user interface."
- if not ipaservices.knownservices.ntpd.is_running():
+ if not services.knownservices.ntpd.is_running():
print "\t3. Kerberos requires time synchronization between clients"
print "\t and servers for correct operation. You should consider enabling ntpd."
diff --git a/install/tools/ipactl b/install/tools/ipactl
index 77e6ebd7e..581aacc36 100755
--- a/install/tools/ipactl
+++ b/install/tools/ipactl
@@ -34,6 +34,7 @@ from ipapython import services as ipaservices
from ipapython import config, dogtag
from ipaplatform import tasks
from ipapython.dn import DN
+from ipaplatform import services
class IpactlError(ScriptError):
pass
@@ -196,7 +197,7 @@ def get_config_from_file():
def stop_services(svc_list):
for svc in svc_list:
- svc_off = ipaservices.service(svc)
+ svc_off = services.service(svc)
try:
svc_off.stop(capture_output=False)
except Exception:
@@ -222,7 +223,7 @@ def ipa_start(options):
# service file again
os.unlink(ipaservices.SVC_LIST_FILE)
- dirsrv = ipaservices.knownservices.dirsrv
+ dirsrv = services.knownservices.dirsrv
try:
print "Starting Directory Service"
dirsrv.start(capture_output=get_capture_output('dirsrv', options.debug))
@@ -250,7 +251,7 @@ def ipa_start(options):
return
for svc in svc_list:
- svchandle = ipaservices.service(svc)
+ svchandle = services.service(svc)
try:
print "Starting %s Service" % svc
svchandle.start(capture_output=get_capture_output(svc, options.debug))
@@ -268,7 +269,7 @@ def ipa_start(options):
raise IpactlError("Aborting ipactl")
def ipa_stop(options):
- dirsrv = ipaservices.knownservices.dirsrv
+ dirsrv = services.knownservices.dirsrv
try:
svc_list = get_config_from_file()
except Exception, e:
@@ -293,7 +294,7 @@ def ipa_stop(options):
raise IpactlError("Failed to stop Directory Service")
for svc in reversed(svc_list):
- svchandle = ipaservices.service(svc)
+ svchandle = services.service(svc)
try:
print "Stopping %s Service" % svc
svchandle.stop(capture_output=False)
@@ -308,7 +309,7 @@ def ipa_stop(options):
def ipa_restart(options):
- dirsrv = ipaservices.knownservices.dirsrv
+ dirsrv = services.knownservices.dirsrv
new_svc_list = []
dirsrv_restart = True
if not dirsrv.is_running():
@@ -359,7 +360,7 @@ def ipa_restart(options):
if len(old_svc_list) != 0:
# we need to definitely stop some services
for svc in reversed(old_svc_list):
- svchandle = ipaservices.service(svc)
+ svchandle = services.service(svc)
try:
print "Stopping %s Service" % svc
svchandle.stop(capture_output=False)
@@ -384,7 +385,7 @@ def ipa_restart(options):
# there are services to restart
for svc in svc_list:
- svchandle = ipaservices.service(svc)
+ svchandle = services.service(svc)
try:
print "Restarting %s Service" % svc
svchandle.restart(capture_output=get_capture_output(svc, options.debug))
@@ -404,7 +405,7 @@ def ipa_restart(options):
if len(new_svc_list) != 0:
# we still need to start some services
for svc in new_svc_list:
- svchandle = ipaservices.service(svc)
+ svchandle = services.service(svc)
try:
print "Starting %s Service" % svc
svchandle.start(capture_output=get_capture_output(svc, options.debug))
@@ -424,7 +425,7 @@ def ipa_restart(options):
def ipa_status(options):
try:
- dirsrv = ipaservices.knownservices.dirsrv
+ dirsrv = services.knownservices.dirsrv
if dirsrv.is_running():
svc_list = get_config(dirsrv)
else:
@@ -437,7 +438,7 @@ def ipa_status(options):
except Exception, e:
raise IpactlError("Failed to get list of services to probe status: " + str(e))
- dirsrv = ipaservices.knownservices.dirsrv
+ dirsrv = services.knownservices.dirsrv
try:
if dirsrv.is_running():
print "Directory Service: RUNNING"
@@ -453,7 +454,7 @@ def ipa_status(options):
return
for svc in svc_list:
- svchandle = ipaservices.service(svc)
+ svchandle = services.service(svc)
try:
if svchandle.is_running():
print "%s Service: RUNNING" % svc
diff --git a/ipa-client/ipa-install/ipa-client-automount b/ipa-client/ipa-install/ipa-client-automount
index 0841952cb..7c7491b5d 100755
--- a/ipa-client/ipa-install/ipa-client-automount
+++ b/ipa-client/ipa-install/ipa-client-automount
@@ -39,6 +39,7 @@ from ipapython.ipa_log_manager import *
from ipapython.dn import DN
from ipapython import services as ipaservices
from ipaplatform import tasks
+from ipaplatform import services
AUTOFS_CONF = '/etc/sysconfig/autofs'
NSSWITCH_CONF = '/etc/nsswitch.conf'
@@ -192,7 +193,7 @@ def configure_autofs_sssd(fstore, statestore, autodiscover, options):
sssdconfig.write("/etc/sssd/sssd.conf")
statestore.backup_state('autofs', 'sssd', True)
- sssd = ipaservices.service('sssd')
+ sssd = services.service('sssd')
sssd.restart()
print "Restarting sssd, waiting for it to become available."
wait_for_sssd()
@@ -227,7 +228,7 @@ def configure_autofs(fstore, statestore, autodiscover, server, options):
print "Configured %s" % AUTOFS_CONF
def configure_autofs_common(fstore, statestore, options):
- autofs = ipaservices.knownservices.autofs
+ autofs = services.knownservices.autofs
statestore.backup_state('autofs', 'enabled', autofs.is_enabled())
statestore.backup_state('autofs', 'running', autofs.is_running())
try:
@@ -257,7 +258,7 @@ def uninstall(fstore, statestore):
enabled = statestore.restore_state('autofs', 'enabled')
running = statestore.restore_state('autofs', 'running')
sssd = statestore.restore_state('autofs', 'sssd')
- autofs = ipaservices.knownservices.autofs
+ autofs = services.knownservices.autofs
if not enabled:
autofs.disable()
if not running:
@@ -280,7 +281,7 @@ def uninstall(fstore, statestore):
break
sssdconfig.save_domain(domain)
sssdconfig.write("/etc/sssd/sssd.conf")
- sssd = ipaservices.service('sssd')
+ sssd = services.service('sssd')
sssd.restart()
wait_for_sssd()
except Exception, e:
@@ -289,7 +290,7 @@ def uninstall(fstore, statestore):
if statestore.has_state('rpcidmapd'):
enabled = statestore.restore_state('rpcidmapd', 'enabled')
running = statestore.restore_state('rpcidmapd', 'running')
- rpcidmapd = ipaservices.knownservices.rpcidmapd
+ rpcidmapd = services.knownservices.rpcidmapd
if not enabled:
rpcidmapd.disable()
if not running:
@@ -297,7 +298,7 @@ def uninstall(fstore, statestore):
if statestore.has_state('rpcgssd'):
enabled = statestore.restore_state('rpcgssd', 'enabled')
running = statestore.restore_state('rpcgssd', 'running')
- rpcgssd = ipaservices.knownservices.rpcgssd
+ rpcgssd = services.knownservices.rpcgssd
if not enabled:
rpcgssd.disable()
if not running:
@@ -327,7 +328,7 @@ def configure_nfs(fstore, statestore):
print "Configured %s" % IDMAPD_CONF
- rpcidmapd = ipaservices.knownservices.rpcidmapd
+ rpcidmapd = services.knownservices.rpcidmapd
statestore.backup_state('rpcidmapd', 'enabled', rpcidmapd.is_enabled())
statestore.backup_state('rpcidmapd', 'running', rpcidmapd.is_running())
try:
@@ -341,7 +342,7 @@ def configure_nfs(fstore, statestore):
print "Failed to configure automatic startup of the %s daemon" % (rpcidmapd.service_name)
root_logger.error("Failed to enable automatic startup of the %s daemon: %s" % (rpcidmapd.service_name, str(e)))
- rpcgssd = ipaservices.knownservices.rpcgssd
+ rpcgssd = services.knownservices.rpcgssd
statestore.backup_state('rpcgssd', 'enabled', rpcgssd.is_enabled())
statestore.backup_state('rpcgssd', 'running', rpcgssd.is_running())
try:
diff --git a/ipa-client/ipa-install/ipa-client-install b/ipa-client/ipa-install/ipa-client-install
index 3a5c127b8..1e17dee4c 100755
--- a/ipa-client/ipa-install/ipa-client-install
+++ b/ipa-client/ipa-install/ipa-client-install
@@ -317,7 +317,7 @@ def nssldap_exists():
# helper function for uninstall
# deletes IPA domain from sssd.conf
def delete_ipa_domain():
- sssd = ipaservices.service('sssd')
+ sssd = services.service('sssd')
try:
sssdconfig = SSSDConfig.SSSDConfig()
sssdconfig.import_config()
@@ -492,13 +492,13 @@ def uninstall(options, env):
# Always start certmonger. We can't untrack something if it isn't
# running
- messagebus = ipaservices.knownservices.messagebus
+ messagebus = services.knownservices.messagebus
try:
messagebus.start()
except Exception, e:
log_service_error(messagebus.service_name, 'start', e)
- cmonger = ipaservices.knownservices.certmonger
+ cmonger = services.knownservices.certmonger
try:
cmonger.start()
except Exception, e:
@@ -562,7 +562,7 @@ def uninstall(options, env):
if fstore.has_files():
was_sssd_installed = fstore.has_file("/etc/sssd/sssd.conf")
- sshd_config = os.path.join(ipaservices.knownservices.sshd.get_config_dir(), "sshd_config")
+ sshd_config = os.path.join(services.knownservices.sshd.get_config_dir(), "sshd_config")
was_sshd_configured = fstore.has_file(sshd_config)
try:
tasks.restore_pre_ipa_client_configuration(fstore,
@@ -603,7 +603,7 @@ def uninstall(options, env):
root_logger.info("IPA domain removed from current one, " +
"restarting SSSD service")
- sssd = ipaservices.service('sssd')
+ sssd = services.service('sssd')
try:
sssd.restart()
except CalledProcessError:
@@ -616,7 +616,7 @@ def uninstall(options, env):
root_logger.info("Other domains than IPA domain found, " +
"IPA domain was removed from /etc/sssd/sssd.conf.")
- sssd = ipaservices.service('sssd')
+ sssd = services.service('sssd')
try:
sssd.restart()
except CalledProcessError:
@@ -634,7 +634,7 @@ def uninstall(options, env):
root_logger.info("Redundant SSSD configuration file " +
"/etc/sssd/sssd.conf was moved to /etc/sssd/sssd.conf.deleted")
- sssd = ipaservices.service('sssd')
+ sssd = services.service('sssd')
try:
sssd.stop()
except CalledProcessError:
@@ -654,8 +654,8 @@ def uninstall(options, env):
ipautil.restore_hostname(statestore)
unconfigure_nisdomain()
- nscd = ipaservices.knownservices.nscd
- nslcd = ipaservices.knownservices.nslcd
+ nscd = services.knownservices.nscd
+ nslcd = services.knownservices.nslcd
for service in (nscd, nslcd):
if service.is_installed():
@@ -686,16 +686,16 @@ def uninstall(options, env):
pass
if not ntp_enabled:
- ipaservices.knownservices.ntpd.stop()
- ipaservices.knownservices.ntpd.disable()
+ services.knownservices.ntpd.stop()
+ services.knownservices.ntpd.disable()
else:
if restored:
- ipaservices.knownservices.ntpd.restart()
+ services.knownservices.ntpd.restart()
ipaclient.ntpconf.restore_forced_ntpd(statestore)
- if was_sshd_configured and ipaservices.knownservices.sshd.is_running():
- ipaservices.knownservices.sshd.restart()
+ if was_sshd_configured and services.knownservices.sshd.is_running():
+ services.knownservices.sshd.restart()
# Remove the Firefox configuration
if statestore.has_state('firefox'):
@@ -890,7 +890,7 @@ def configure_nslcd_conf(fstore, cli_basedn, cli_realm, cli_domain, cli_server,
root_logger.error("Creation of %s failed: %s", filename, str(e))
return (1, None, None)
- nslcd = ipaservices.knownservices.nslcd
+ nslcd = services.knownservices.nslcd
if nslcd.is_installed():
try:
nslcd.restart()
@@ -1067,7 +1067,7 @@ def configure_certmonger(fstore, subject_base, cli_realm, hostname, options,
started = True
principal = 'host/%s@%s' % (hostname, cli_realm)
- messagebus = ipaservices.knownservices.messagebus
+ messagebus = services.knownservices.messagebus
try:
messagebus.start()
except Exception, e:
@@ -1075,7 +1075,7 @@ 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.
- cmonger = ipaservices.knownservices.certmonger
+ cmonger = services.knownservices.certmonger
try:
cmonger.restart()
except Exception, e:
@@ -1172,7 +1172,7 @@ def configure_sssd_conf(fstore, cli_realm, cli_domain, cli_server, options, clie
sssdconfig.new_config()
domain = sssdconfig.new_domain(cli_domain)
- ssh_dir = ipaservices.knownservices.sshd.get_config_dir()
+ ssh_dir = services.knownservices.sshd.get_config_dir()
ssh_config = os.path.join(ssh_dir, 'ssh_config')
sshd_config = os.path.join(ssh_dir, 'sshd_config')
@@ -1314,7 +1314,7 @@ def change_ssh_config(filename, changes, sections):
return True
def configure_ssh_config(fstore, options):
- ssh_dir = ipaservices.knownservices.sshd.get_config_dir()
+ ssh_dir = services.knownservices.sshd.get_config_dir()
ssh_config = os.path.join(ssh_dir, 'ssh_config')
if not file_exists(ssh_config):
@@ -1338,7 +1338,7 @@ def configure_ssh_config(fstore, options):
root_logger.info('Configured %s', ssh_config)
def configure_sshd_config(fstore, options):
- sshd = ipaservices.knownservices.sshd
+ sshd = services.knownservices.sshd
ssh_dir = sshd.get_config_dir()
sshd_config = os.path.join(ssh_dir, 'sshd_config')
@@ -1440,14 +1440,14 @@ def configure_nisdomain(options, domain):
# Backup the state of the domainname service
statestore.backup_state("domainname", "enabled",
- ipaservices.knownservices.domainname.is_enabled())
+ services.knownservices.domainname.is_enabled())
# Set the new NIS domain name
tasks.set_nisdomain(domain)
# Enable and start the domainname service
- ipaservices.knownservices.domainname.enable()
- ipaservices.knownservices.domainname.start()
+ services.knownservices.domainname.enable()
+ services.knownservices.domainname.start()
def unconfigure_nisdomain():
@@ -1465,7 +1465,7 @@ def unconfigure_nisdomain():
# Restore the configuration of the domainname service
enabled = statestore.restore_state('domainname', 'enabled')
if not enabled:
- ipaservices.knownservices.domainname.disable()
+ services.knownservices.domainname.disable()
def resolve_ipaddress(server):
@@ -2640,7 +2640,7 @@ def install(options, env, fstore, statestore):
configure_certmonger(fstore, subject_base, cli_realm, hostname,
options, remote_env)
- update_ssh_keys(cli_server[0], hostname, ipaservices.knownservices.sshd.get_config_dir(), options.create_sshfp)
+ update_ssh_keys(cli_server[0], hostname, services.knownservices.sshd.get_config_dir(), options.create_sshfp)
try:
os.remove(CCACHE_FILE)
@@ -2648,7 +2648,7 @@ def install(options, env, fstore, statestore):
pass
#Name Server Caching Daemon. Disable for SSSD, use otherwise (if installed)
- nscd = ipaservices.knownservices.nscd
+ nscd = services.knownservices.nscd
if nscd.is_installed():
save_state(nscd)
@@ -2689,7 +2689,7 @@ def install(options, env, fstore, statestore):
root_logger.info("%s daemon is not installed, skip configuration",
nscd.service_name)
- nslcd = ipaservices.knownservices.nslcd
+ nslcd = services.knownservices.nslcd
if nscd.is_installed():
save_state(nslcd)
@@ -2704,7 +2704,7 @@ def install(options, env, fstore, statestore):
root_logger.info("%s enabled", "SSSD" if options.sssd else "LDAP")
if options.sssd:
- sssd = ipaservices.service('sssd')
+ sssd = services.service('sssd')
try:
sssd.restart()
except CalledProcessError:
diff --git a/ipa-client/ipaclient/ntpconf.py b/ipa-client/ipaclient/ntpconf.py
index 9a68016e5..182c977d2 100644
--- a/ipa-client/ipaclient/ntpconf.py
+++ b/ipa-client/ipaclient/ntpconf.py
@@ -22,6 +22,7 @@ from ipapython import services as ipaservices
import shutil
import os
from ipaplatform import tasks
+from ipaplatform import services
ntp_conf = """# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
@@ -115,7 +116,7 @@ def config_ntp(server_fqdn, fstore = None, sysstore = None):
if sysstore:
module = 'ntp'
- sysstore.backup_state(module, "enabled", ipaservices.knownservices.ntpd.is_enabled())
+ sysstore.backup_state(module, "enabled", services.knownservices.ntpd.is_enabled())
if config_step_tickers:
sysstore.backup_state(module, "step-tickers", True)
@@ -128,10 +129,10 @@ def config_ntp(server_fqdn, fstore = None, sysstore = None):
tasks.restore_context(path_ntp_sysconfig)
# Set the ntpd to start on boot
- ipaservices.knownservices.ntpd.enable()
+ services.knownservices.ntpd.enable()
# Restart ntpd
- ipaservices.knownservices.ntpd.restart()
+ services.knownservices.ntpd.restart()
def synconce_ntp(server_fqdn):
@@ -174,11 +175,11 @@ def check_timedate_services():
https://fedorahosted.org/freeipa/ticket/2974
http://fedoraproject.org/wiki/Features/ChronyDefaultNTP
"""
- for service in ipaservices.timedate_services:
+ for service in services.timedate_services:
if service == 'ntpd':
continue
# Make sure that the service is not enabled
- service = ipaservices.service(service)
+ service = services.service(service)
if service.is_enabled() or service.is_running():
raise NTPConflictingService(conflicting_service=service.service_name)
@@ -187,10 +188,10 @@ def force_ntpd(statestore):
Force ntpd configuration and disable and stop any other conflicting
time&date service
"""
- for service in ipaservices.timedate_services:
+ for service in services.timedate_services:
if service == 'ntpd':
continue
- service = ipaservices.service(service)
+ service = services.service(service)
enabled = service.is_enabled()
running = service.is_running()
@@ -209,11 +210,11 @@ def restore_forced_ntpd(statestore):
Restore from --force-ntpd installation and enable/start service that were
disabled/stopped during installation
"""
- for service in ipaservices.timedate_services:
+ for service in services.timedate_services:
if service == 'ntpd':
continue
if statestore.has_state(service):
- service = ipaservices.service(service)
+ service = services.service(service)
enabled = statestore.restore_state(service.service_name, 'enabled')
running = statestore.restore_state(service.service_name, 'running')
if enabled:
diff --git a/ipaserver/install/adtrustinstance.py b/ipaserver/install/adtrustinstance.py
index f44765a08..170feac46 100644
--- a/ipaserver/install/adtrustinstance.py
+++ b/ipaserver/install/adtrustinstance.py
@@ -40,6 +40,7 @@ from ipapython.ipa_log_manager import *
from ipapython import services as ipaservices
import ipaclient.ipachangeconf
+from ipaplatform import services
ALLOWED_NETBIOS_CHARS = string.ascii_uppercase + string.digits
@@ -730,21 +731,21 @@ class ADTRUSTInstance(service.Service):
def __start(self):
try:
self.start()
- ipaservices.service('winbind').start()
+ services.service('winbind').start()
except:
root_logger.critical("CIFS services failed to start")
def __stop(self):
self.backup_state("running", self.is_running())
try:
- ipaservices.service('winbind').stop()
+ services.service('winbind').stop()
self.stop()
except:
pass
def __restart_dirsrv(self):
try:
- ipaservices.knownservices.dirsrv.restart()
+ services.knownservices.dirsrv.restart()
except:
pass
@@ -889,7 +890,7 @@ class ADTRUSTInstance(service.Service):
self.restore_state("running")
self.restore_state("enabled")
- winbind = ipaservices.service("winbind")
+ winbind = services.service("winbind")
# Always try to stop and disable smb service, since we do not leave
# working configuration after uninstall
try:
diff --git a/ipaserver/install/cainstance.py b/ipaserver/install/cainstance.py
index c6221e5e0..599bfffc8 100644
--- a/ipaserver/install/cainstance.py
+++ b/ipaserver/install/cainstance.py
@@ -59,6 +59,7 @@ from ipaserver.install import certs
from ipaserver.install.installutils import stopped_service
from ipaserver.plugins import ldap2
from ipapython.ipa_log_manager import *
+from ipaplatform import services
HTTPD_CONFD = "/etc/httpd/conf.d/"
DEFAULT_DSPORT = dogtag.install_constants.DS_PORT
@@ -286,7 +287,7 @@ class CADSInstance(service.Service):
running = self.restore_state("running")
if not enabled is None and not enabled:
- ipaservices.knownservices.dirsrv.disable()
+ services.knownservices.dirsrv.disable()
if not serverid is None:
# drop the trailing / off the config_dirname so the directory
@@ -306,8 +307,8 @@ class CADSInstance(service.Service):
def stop_tracking_certificates(dogtag_constants):
"""Stop tracking our certificates. Called on uninstall.
"""
- cmonger = ipaservices.knownservices.certmonger
- ipaservices.knownservices.messagebus.start()
+ cmonger = services.knownservices.certmonger
+ services.knownservices.messagebus.start()
cmonger.start()
for nickname in ['Server-Cert cert-pki-ca',
@@ -1335,8 +1336,8 @@ class CAInstance(service.Service):
# cause files to have a new owner.
user_exists = self.restore_state("user_exists")
- ipaservices.knownservices.messagebus.start()
- cmonger = ipaservices.knownservices.certmonger
+ services.knownservices.messagebus.start()
+ cmonger = services.knownservices.certmonger
cmonger.start()
bus = dbus.SystemBus()
@@ -1388,8 +1389,8 @@ class CAInstance(service.Service):
Create a new CA type for certmonger that will retrieve updated
certificates from the dogtag master server.
"""
- ipaservices.knownservices.messagebus.start()
- cmonger = ipaservices.knownservices.certmonger
+ services.knownservices.messagebus.start()
+ cmonger = services.knownservices.certmonger
cmonger.enable()
cmonger.start()
@@ -1667,7 +1668,7 @@ def install_replica_ca(config, postinstall=False):
# Without the restart, CA service status check would fail due to missing
# proxy
if postinstall:
- ipaservices.knownservices.httpd.restart()
+ services.knownservices.httpd.restart()
# The dogtag DS instance needs to be restarted after installation.
@@ -1682,7 +1683,7 @@ def install_replica_ca(config, postinstall=False):
service.print_msg("Restarting the directory and certificate servers")
ca.stop(dogtag.install_constants.PKI_INSTANCE_NAME)
- ipaservices.knownservices.dirsrv.restart()
+ services.knownservices.dirsrv.restart()
ca.start(dogtag.install_constants.PKI_INSTANCE_NAME)
diff --git a/ipaserver/install/certs.py b/ipaserver/install/certs.py
index 9ee854ebf..c5380e939 100644
--- a/ipaserver/install/certs.py
+++ b/ipaserver/install/certs.py
@@ -42,6 +42,7 @@ from ipapython.dn import DN
from ipalib import pkcs10, x509, api
from ipalib.errors import CertificateOperationError
from ipalib.text import _
+from ipaplatform import services
# Apache needs access to this database so we need to create it
# where apache can reach
@@ -509,9 +510,9 @@ class CertDB(object):
else:
libpath = 'lib'
command = '/usr/%s/ipa/certmonger/%s' % (libpath, command)
- cmonger = ipaservices.knownservices.certmonger
+ cmonger = services.knownservices.certmonger
cmonger.enable()
- ipaservices.knownservices.messagebus.start()
+ services.knownservices.messagebus.start()
cmonger.start()
try:
(stdout, stderr, rc) = certmonger.start_tracking(nickname, self.secdir, password_file, command)
@@ -541,8 +542,8 @@ class CertDB(object):
# Always start certmonger. We can't untrack something if it isn't
# running
- cmonger = ipaservices.knownservices.certmonger
- ipaservices.knownservices.messagebus.start()
+ cmonger = services.knownservices.certmonger
+ services.knownservices.messagebus.start()
cmonger.start()
try:
certmonger.stop_tracking(self.secdir, nickname=nickname)
diff --git a/ipaserver/install/dsinstance.py b/ipaserver/install/dsinstance.py
index b06c13d90..1186edadb 100644
--- a/ipaserver/install/dsinstance.py
+++ b/ipaserver/install/dsinstance.py
@@ -43,6 +43,7 @@ from ipalib import errors
from ipaplatform import tasks
from ipalib.constants import CACERT
from ipapython.dn import DN
+from ipaplatform import services
SERVER_ROOT_64 = "/usr/lib64/dirsrv"
SERVER_ROOT_32 = "/usr/lib/dirsrv"
@@ -145,7 +146,7 @@ def check_ports():
return (ds_unsecure, ds_secure)
def is_ds_running(server_id=''):
- return ipaservices.knownservices.dirsrv.is_running(instance_name=server_id)
+ return services.knownservices.dirsrv.is_running(instance_name=server_id)
def create_ds_user():
@@ -819,7 +820,7 @@ class DsInstance(service.Service):
# (re)start them.
for ds_instance in get_ds_instances():
try:
- ipaservices.knownservices.dirsrv.restart(ds_instance, wait=False)
+ services.knownservices.dirsrv.restart(ds_instance, wait=False)
except Exception, e:
root_logger.error('Unable to restart ds instance %s: %s', ds_instance, e)
@@ -884,7 +885,7 @@ class DsInstance(service.Service):
"""
# Do the platform-specific changes
- proceed = ipaservices.knownservices.dirsrv.tune_nofile_platform(
+ proceed = services.knownservices.dirsrv.tune_nofile_platform(
num=num, fstore=self.fstore)
if proceed:
diff --git a/ipaserver/install/installutils.py b/ipaserver/install/installutils.py
index 7f15d3769..a2de7c1bd 100644
--- a/ipaserver/install/installutils.py
+++ b/ipaserver/install/installutils.py
@@ -43,6 +43,7 @@ from ipalib import errors
from ipapython.dn import DN
from ipaserver.install import certs, service
from ipapython import services as ipaservices
+from ipaplatform import services
# Used to determine install status
IPA_MODULES = [
@@ -833,19 +834,19 @@ def stopped_service(service, instance_name=""):
log_instance_name)
# Figure out if the service is running, if not, yield
- if not ipaservices.knownservices[service].is_running(instance_name):
+ if not services.knownservices[service].is_running(instance_name):
root_logger.debug('Service %s%s is not running, continue.', service,
log_instance_name)
yield
else:
# Stop the service, do the required stuff and start it again
root_logger.debug('Stopping %s%s.', service, log_instance_name)
- ipaservices.knownservices[service].stop(instance_name)
+ services.knownservices[service].stop(instance_name)
try:
yield
finally:
root_logger.debug('Starting %s%s.', service, log_instance_name)
- ipaservices.knownservices[service].start(instance_name)
+ services.knownservices[service].start(instance_name)
def check_entropy():
'''
diff --git a/ipaserver/install/ipa_backup.py b/ipaserver/install/ipa_backup.py
index 1da272fe9..d3f7f178d 100644
--- a/ipaserver/install/ipa_backup.py
+++ b/ipaserver/install/ipa_backup.py
@@ -25,6 +25,7 @@ import time
import pwd
from optparse import OptionGroup
from ConfigParser import SafeConfigParser
+from ipaplatform import services
from ipalib import api, errors
from ipapython import version
@@ -258,7 +259,7 @@ class Backup(admintool.AdminTool):
cwd = os.getcwd()
try:
- dirsrv = ipaservices.knownservices.dirsrv
+ dirsrv = services.knownservices.dirsrv
self.add_instance_specific_data()
diff --git a/ipaserver/install/ipa_restore.py b/ipaserver/install/ipa_restore.py
index 56e522895..d2064d4af 100644
--- a/ipaserver/install/ipa_restore.py
+++ b/ipaserver/install/ipa_restore.py
@@ -40,6 +40,7 @@ from ipapython import services as ipaservices
from ipapython import ipaldap
from ipaplatform import tasks
from ipaserver.install.ipa_backup import BACKUP_DIR
+from ipaplatform import services
def recursive_chown(path, uid, gid):
@@ -204,7 +205,7 @@ class Restore(admintool.AdminTool):
cwd = os.getcwd()
try:
- dirsrv = ipaservices.knownservices.dirsrv
+ dirsrv = services.knownservices.dirsrv
self.read_header()
# These two checks would normally be in the validate method but
@@ -294,13 +295,13 @@ class Restore(admintool.AdminTool):
else:
# explicitly enable then disable the pki tomcatd service to
# re-register its instance. FIXME, this is really wierd.
- ipaservices.knownservices.pki_tomcatd.enable()
- ipaservices.knownservices.pki_tomcatd.disable()
+ services.knownservices.pki_tomcatd.enable()
+ services.knownservices.pki_tomcatd.disable()
self.log.info('Starting IPA services')
run(['ipactl', 'start'])
self.log.info('Restarting SSSD')
- sssd = ipaservices.service('sssd')
+ sssd = services.service('sssd')
sssd.restart()
finally:
try:
diff --git a/ipaserver/install/replication.py b/ipaserver/install/replication.py
index f295fb305..4a484d617 100644
--- a/ipaserver/install/replication.py
+++ b/ipaserver/install/replication.py
@@ -30,6 +30,7 @@ from ipapython import services as ipaservices
from ipapython.ipa_log_manager import *
from ipapython import ipautil, dogtag, ipaldap
from ipapython.dn import DN
+from ipaplatform import services
# the default container used by AD for user entries
WIN_USER_CONTAINER = DN(('cn', 'Users'))
@@ -108,7 +109,7 @@ def enable_replication_version_checking(hostname, realm, dirman_passwd):
conn.modify_s(entry.dn, [(ldap.MOD_REPLACE, 'nsslapd-pluginenabled', 'on')])
conn.unbind()
serverid = "-".join(realm.split("."))
- ipaservices.knownservices.dirsrv.restart(instance_name=serverid)
+ services.knownservices.dirsrv.restart(instance_name=serverid)
else:
conn.unbind()
diff --git a/ipaserver/install/service.py b/ipaserver/install/service.py
index 387cb1cf4..3a6983856 100644
--- a/ipaserver/install/service.py
+++ b/ipaserver/install/service.py
@@ -29,6 +29,7 @@ from ipapython import services as ipaservices
from ipapython.dn import DN
from ipapython.ipa_log_manager import *
from ipalib import errors
+from ipaplatform import services
# Autobind modes
AUTO = 1
@@ -75,7 +76,7 @@ class Service(object):
def __init__(self, service_name, service_desc=None, sstore=None, dm_password=None, ldapi=True, autobind=AUTO):
self.service_name = service_name
self.service_desc = service_desc
- self.service = ipaservices.service(service_name)
+ self.service = services.service(service_name)
self.steps = []
self.output_fd = sys.stdout
self.dm_password = dm_password