diff options
| author | Christian Heimes <cheimes@redhat.com> | 2016-11-18 15:42:23 +0100 |
|---|---|---|
| committer | Martin Basti <mbasti@redhat.com> | 2016-11-24 16:30:32 +0100 |
| commit | 6409abf1a60f3548203e6607a2b157ff72af2c89 (patch) | |
| tree | 2d1c06b3fc85d91f9d4bea67162a1ab9dcdca07e /ipaplatform/redhat | |
| parent | 2cbaf156045769b54150e4d4c3c1071f164a16fb (diff) | |
| download | freeipa-6409abf1a60f3548203e6607a2b157ff72af2c89.tar.gz freeipa-6409abf1a60f3548203e6607a2b157ff72af2c89.tar.xz freeipa-6409abf1a60f3548203e6607a2b157ff72af2c89.zip | |
Break ipaplatform / ipalib import cycle of hell
Here is an attempt to break the import cycle of hell between ipaplatform
and ipalib. All services now pass an ipalib.api object to
services.service(). RedHatServices.__init__() still needs to do a local
import because it initializes its wellknown service dict with service
instances.
Signed-off-by: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Martin Basti <mbasti@redhat.com>
Diffstat (limited to 'ipaplatform/redhat')
| -rw-r--r-- | ipaplatform/redhat/services.py | 29 | ||||
| -rw-r--r-- | ipaplatform/redhat/tasks.py | 4 |
2 files changed, 16 insertions, 17 deletions
diff --git a/ipaplatform/redhat/services.py b/ipaplatform/redhat/services.py index 24325347c..99904ce9f 100644 --- a/ipaplatform/redhat/services.py +++ b/ipaplatform/redhat/services.py @@ -31,7 +31,6 @@ from ipaplatform.base import services as base_services from ipapython import ipautil, dogtag from ipapython.ipa_log_manager import root_logger -from ipalib import api from ipaplatform.paths import paths # Mappings from service names as FreeIPA code references to these services @@ -76,7 +75,7 @@ redhat_system_units['ods_signerd'] = redhat_system_units['ods-signerd'] class RedHatService(base_services.SystemdService): system_units = redhat_system_units - def __init__(self, service_name): + def __init__(self, service_name, api=None): systemd_name = service_name if service_name in self.system_units: systemd_name = self.system_units[service_name] @@ -86,7 +85,7 @@ class RedHatService(base_services.SystemdService): # and not a foo.target. Thus, not correct service name for # systemd, default to foo.service style then systemd_name = "%s.service" % (service_name) - super(RedHatService, self).__init__(service_name, systemd_name) + super(RedHatService, self).__init__(service_name, systemd_name, api) class RedHatDirectoryService(RedHatService): @@ -195,12 +194,12 @@ class RedHatSSHService(RedHatService): class RedHatCAService(RedHatService): def wait_until_running(self): root_logger.debug('Waiting until the CA is running') - timeout = float(api.env.startup_timeout) + timeout = float(self.api.env.startup_timeout) op_timeout = time.time() + timeout while time.time() < op_timeout: try: # check status of CA instance on this host, not remote ca_host - status = dogtag.ca_status(api.env.host) + status = dogtag.ca_status(self.api.env.host) except Exception as e: status = 'check interrupted due to error: %s' % e root_logger.debug('The CA status is: %s' % status) @@ -244,31 +243,31 @@ class RedHatCAService(RedHatService): # Function that constructs proper Red Hat OS family-specific server classes for # services of specified name -def redhat_service_class_factory(name): +def redhat_service_class_factory(name, api=None): if name == 'dirsrv': - return RedHatDirectoryService(name) + return RedHatDirectoryService(name, api) if name == 'ipa': - return RedHatIPAService(name) + return RedHatIPAService(name, api) if name == 'sshd': - return RedHatSSHService(name) + return RedHatSSHService(name, api) if name in ('pki-tomcatd', 'pki_tomcatd'): - return RedHatCAService(name) - return RedHatService(name) + return RedHatCAService(name, api) + return RedHatService(name, api) # Magicdict containing RedHatService instances. class RedHatServices(base_services.KnownServices): - def service_class_factory(self, name): - return redhat_service_class_factory(name) - def __init__(self): + import ipalib # FixMe: break import cycle services = dict() for s in base_services.wellknownservices: - services[s] = self.service_class_factory(s) + services[s] = self.service_class_factory(s, ipalib.api) # Call base class constructor. This will lock services to read-only super(RedHatServices, self).__init__(services) + def service_class_factory(self, name, api=None): + return redhat_service_class_factory(name, api) # Objects below are expected to be exported by platform module diff --git a/ipaplatform/redhat/tasks.py b/ipaplatform/redhat/tasks.py index 5d627becf..3766eb344 100644 --- a/ipaplatform/redhat/tasks.py +++ b/ipaplatform/redhat/tasks.py @@ -44,8 +44,6 @@ from ipapython.ipa_log_manager import root_logger, log_mgr from ipapython import ipautil import ipapython.errors -from ipalib import x509 # FIXME: do not import from ipalib - from ipaplatform.constants import constants from ipaplatform.paths import paths from ipaplatform.redhat.authconfig import RedHatAuthConfig @@ -220,6 +218,8 @@ class RedHatTaskNamespace(BaseTaskNamespace): return True def insert_ca_certs_into_systemwide_ca_store(self, ca_certs): + from ipalib import x509 # FixMe: break import cycle + new_cacert_path = paths.SYSTEMWIDE_IPA_CA_CRT if os.path.exists(new_cacert_path): |
