diff options
author | Alexander Bokovoy <abokovoy@redhat.com> | 2011-08-30 17:14:49 +0300 |
---|---|---|
committer | Alexander Bokovoy <abokovoy@redhat.com> | 2011-08-30 17:14:49 +0300 |
commit | 762832803f03ac343365276df34fa102f9aead40 (patch) | |
tree | 98ce4890dd4a378535714b169a9942659cd960ca | |
parent | e1fbeed9d46c5fd8c557fe65b2c09a987ae9b8e5 (diff) | |
download | freeipa-762832803f03ac343365276df34fa102f9aead40.tar.gz freeipa-762832803f03ac343365276df34fa102f9aead40.tar.xz freeipa-762832803f03ac343365276df34fa102f9aead40.zip |
Convert ipaserver/install/ bits
-rw-r--r-- | ipaserver/install/bindinstance.py | 2 | ||||
-rw-r--r-- | ipaserver/install/cainstance.py | 26 | ||||
-rw-r--r-- | ipaserver/install/certs.py | 25 | ||||
-rw-r--r-- | ipaserver/install/dsinstance.py | 19 | ||||
-rw-r--r-- | ipaserver/install/httpinstance.py | 9 | ||||
-rw-r--r-- | ipaserver/install/krbinstance.py | 3 | ||||
-rw-r--r-- | ipaserver/install/ntpinstance.py | 5 | ||||
-rw-r--r-- | ipaserver/install/replication.py | 4 |
8 files changed, 39 insertions, 54 deletions
diff --git a/ipaserver/install/bindinstance.py b/ipaserver/install/bindinstance.py index 7f7d67b41..0970709ec 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.service_off() + self.disable() if not running is None and running: self.start() diff --git a/ipaserver/install/cainstance.py b/ipaserver/install/cainstance.py index a5b5500e1..e86583501 100644 --- a/ipaserver/install/cainstance.py +++ b/ipaserver/install/cainstance.py @@ -47,6 +47,7 @@ import nss.nss as nss from ipapython import ipautil from ipapython import nsslib +from ipapython import services as ipaservices from ipaserver import ipaldap from ipaserver.install import service @@ -371,11 +372,7 @@ class CADSInstance(service.Service): def restart_instance(self): try: - # Have to trick the base class to use the right service name - sav_name = self.service_name - self.service_name="dirsrv" - self.restart(self.serverid) - self.service_name=sav_name + ipaservices.knownservices.dirsrv.restart(self.serverid) if not dsinstance.is_ds_running(): logging.critical("Failed to restart the directory server. See the installation log for details.") sys.exit(1) @@ -390,14 +387,12 @@ class CADSInstance(service.Service): running = self.restore_state("running") enabled = self.restore_state("enabled") serverid = self.restore_state("serverid") - sav_name = self.service_name - self.service_name="dirsrv" if not running is None: - self.stop(serverid) + ipaservices.knownservices.dirsrv.stop(self.serverid) if not enabled is None and not enabled: - self.service_off() + ipaservices.knownservices.dirsrv.disable() if not serverid is None: # drop the trailing / off the config_dirname so the directory @@ -407,7 +402,6 @@ class CADSInstance(service.Service): dsdb.untrack_server_cert("Server-Cert") dsinstance.erase_ds_instance_data(serverid) - self.service_name="pkids" user_exists = self.restore_state("user_exists") if user_exists == False: @@ -415,7 +409,6 @@ class CADSInstance(service.Service): ipautil.run(["/usr/sbin/userdel", PKI_DS_USER]) except ipautil.CalledProcessError, e: logging.critical("failed to delete user %s" % e) - self.service_name = sav_name class CAInstance(service.Service): """ @@ -1040,7 +1033,7 @@ class CAInstance(service.Service): # Fix the CRL URI in the profile installutils.set_directive('/var/lib/%s/profiles/ca/caIPAserviceCert.cfg' % PKI_INSTANCE_NAME, 'policyset.serverCertSet.9.default.params.crlDistPointsPointName_0', 'https://%s/ipa/crl/MasterCRL.bin' % self.fqdn, quotes=False, separator='=') - ipautil.run(["/sbin/restorecon", publishdir]) + ipaservices.restore_context(publishdir) def __set_subject_in_config(self): # dogtag ships with an IPA-specific profile that forces a subject @@ -1054,7 +1047,7 @@ class CAInstance(service.Service): enabled = self.restore_state("enabled") if not enabled is None and not enabled: - self.service_off() + self.disable() try: ipautil.run(["/usr/bin/pkiremove", "-pki_instance_root=/var/lib", @@ -1139,14 +1132,11 @@ def install_replica_ca(config, postinstall=False): # internally. In the case of the dogtag DS the name doesn't match the # unix service. - service_name = cs.service_name service.print_msg("Restarting the directory and certificate servers") - cs.service_name = "dirsrv" ca.stop() - cs.stop("PKI-IPA") - cs.start("PKI-IPA") + ipaservices.knownservices.dirsrv.stop("PKI-IPA") + ipaservices.knownservices.dirsrv.start("PKI-IPA") ca.start() - cs.service_name = service_name return (ca, cs) diff --git a/ipaserver/install/certs.py b/ipaserver/install/certs.py index 99045dcbb..950fd04cb 100644 --- a/ipaserver/install/certs.py +++ b/ipaserver/install/certs.py @@ -36,7 +36,7 @@ from ipapython import certmonger from ipapython.certdb import get_ca_nickname from ipalib import pkcs10 from ConfigParser import RawConfigParser, MissingSectionHeaderError -import service +from ipapython import services as ipaservices from ipalib import x509 from ipalib.dn import DN from ipalib.errors import CertificateOperationError @@ -483,29 +483,30 @@ class CertDB(object): """ Tell certmonger to track the given certificate nickname. """ - service.service_on("certmonger") - service.start("messagebus") - service.start("certmonger") + cmonger = ipaservices.knownservices.certmonger + cmonger.enable() + ipaservices.knownservices.messagebus.start() + cmonger.start() try: (stdout, stderr, rc) = certmonger.start_tracking(nickname, self.secdir, password_file) except (ipautil.CalledProcessError, RuntimeError), e: logging.error("certmonger failed starting to track certificate: %s" % str(e)) return - service.stop("certmonger") + cmonger.stop() cert = self.get_cert_from_db(nickname) nsscert = x509.load_certificate(cert, dbdir=self.secdir) subject = str(nsscert.subject) m = re.match('New tracking request "(\d+)" added', stdout) if not m: - logging.error('Didn\'t get new certmonger request, got %s' % stdout) - raise RuntimeError('certmonger did not issue new tracking request for \'%s\' in \'%s\'. Use \'ipa-getcert list\' to list existing certificates.' % (nickname, self.secdir)) + logging.error('Didn\'t get new %s request, got %s' % (cmonger.service_name, stdout)) + raise RuntimeError('%s did not issue new tracking request for \'%s\' in \'%s\'. Use \'ipa-getcert list\' to list existing certificates.' % (cmonger.service_name, nickname, self.secdir)) request_id = m.group(1) certmonger.add_principal(request_id, principal) certmonger.add_subject(request_id, subject) - service.start("certmonger") + cmonger.start() def untrack_server_cert(self, nickname): """ @@ -514,13 +515,14 @@ class CertDB(object): # Always start certmonger. We can't untrack something if it isn't # running - service.start("messagebus") - service.start("certmonger") + cmonger = ipaservices.knownservices.certmonger + ipaservices.knownservices.messagebus.start() + cmonger.start() try: certmonger.stop_tracking(self.secdir, nickname=nickname) except (ipautil.CalledProcessError, RuntimeError), e: logging.error("certmonger failed to stop tracking certificate: %s" % str(e)) - service.stop("certmonger") + cmonger.stop() def create_server_cert(self, nickname, hostname, other_certdb=None, subject=None): """ @@ -770,6 +772,7 @@ class CertDB(object): f.write(pwdfile.read()) f.close() pwdfile.close() + # TODO: replace explicit uid by a platform-specific one self.set_perms(self.pwd_conf, uid="apache") def find_root_cert(self, nickname): diff --git a/ipaserver/install/dsinstance.py b/ipaserver/install/dsinstance.py index deebd221f..fb17629d5 100644 --- a/ipaserver/install/dsinstance.py +++ b/ipaserver/install/dsinstance.py @@ -30,6 +30,7 @@ import tempfile from ipapython import ipautil from ipapython import sysrestore +from ipapython import services as ipaservices import service import installutils @@ -124,18 +125,7 @@ def check_ports(): return (ds_unsecure, ds_secure) def is_ds_running(): - """The DS init script always returns 0 when requesting status so it cannot - be used to determine if the server is running. We have to look at the - output. - """ - ret = True - try: - (sout, serr, rcode) = ipautil.run(["/sbin/service", "dirsrv", "status"]) - if sout.find("is stopped") >= 0: - ret = False - except ipautil.CalledProcessError: - ret = False - return ret + return ipaservices.knownservices.dirsrv.is_running() def has_managed_entries(host_name, dm_password): """Check to see if the Managed Entries plugin is available""" @@ -324,8 +314,7 @@ 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.service_on() - self.service_off() + self.disable() def __setup_sub_dict(self): server_root = find_server_root() @@ -657,7 +646,7 @@ class DsInstance(service.Service): pass if not enabled is None and not enabled: - self.service_off() + self.disable() serverid = self.restore_state("serverid") if not serverid is None: diff --git a/ipaserver/install/httpinstance.py b/ipaserver/install/httpinstance.py index 6a863cb17..8ccde04bb 100644 --- a/ipaserver/install/httpinstance.py +++ b/ipaserver/install/httpinstance.py @@ -30,6 +30,7 @@ import dsinstance import installutils from ipapython import sysrestore from ipapython import ipautil +from ipapython import services as ipaservices from ipalib import util, api HTTPD_DIR = "/etc/httpd" @@ -211,13 +212,13 @@ class HTTPInstance(service.Service): os.chown(certs.NSS_DIR + "/pwdfile.txt", 0, pent.pw_gid ) # Fix SELinux permissions on the database - ipautil.run(["/sbin/restorecon", certs.NSS_DIR + "/cert8.db"]) - ipautil.run(["/sbin/restorecon", certs.NSS_DIR + "/key3.db"]) + ipaservices.restore_context(certs.NSS_DIR + "/cert8.db") + ipaservices.restore_context(certs.NSS_DIR + "/key3.db") # In case this got generated as part of the install, reset the # context if ipautil.file_exists(certs.CA_SERIALNO): - ipautil.run(["/sbin/restorecon", certs.CA_SERIALNO]) + ipaservices.restore_context(certs.CA_SERIALNO) os.chown(certs.CA_SERIALNO, 0, pent.pw_gid) os.chmod(certs.CA_SERIALNO, 0664) @@ -259,7 +260,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.service_off() + self.disable() 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 1f66723c7..c3ebada2d 100644 --- a/ipaserver/install/krbinstance.py +++ b/ipaserver/install/krbinstance.py @@ -30,6 +30,7 @@ import service import installutils from ipapython import sysrestore from ipapython import ipautil +from ipapython import services as ipaservices from ipalib import util from ipalib import errors @@ -572,7 +573,7 @@ class KrbInstance(service.Service): pass if not enabled is None and not enabled: - self.service_off() + self.disable() if not running is None and running: self.start() diff --git a/ipaserver/install/ntpinstance.py b/ipaserver/install/ntpinstance.py index 7fc16d495..7c9400a01 100644 --- a/ipaserver/install/ntpinstance.py +++ b/ipaserver/install/ntpinstance.py @@ -23,6 +23,7 @@ import logging import service from ipapython import sysrestore from ipapython import ipautil +from ipapython import services as ipaservices class NTPInstance(service.Service): def __init__(self, fstore=None): @@ -143,7 +144,7 @@ class NTPInstance(service.Service): def __enable(self): self.backup_state("enabled", self.is_enabled()) - self.service_on() + self.enable() def create_instance(self): @@ -174,7 +175,7 @@ class NTPInstance(service.Service): pass if not enabled is None and not enabled: - self.service_off() + self.disable() if not running is None and running: self.start() diff --git a/ipaserver/install/replication.py b/ipaserver/install/replication.py index fbf9c95b5..961e71330 100644 --- a/ipaserver/install/replication.py +++ b/ipaserver/install/replication.py @@ -23,7 +23,7 @@ import os import sys import ldap from ipaserver import ipaldap -from ipaserver.install.service import restart +from ipapython import services as ipaservices import installutils from ldap import modlist from ipalib import util @@ -106,7 +106,7 @@ def enable_replication_version_checking(hostname, realm, dirman_passwd): conn.modify_s(entry[0].dn, [(ldap.MOD_REPLACE, 'nsslapd-pluginenabled', 'on')]) conn.unbind() serverid = "-".join(realm.split(".")) - restart("dirsrv", instance_name=serverid) + ipaservices.knownservices.dirsrv.restart(instance_name=serverid) installutils.wait_for_open_ports('localhost', [389, 636], 300) else: conn.unbind() |