diff options
author | Tomas Babej <tbabej@redhat.com> | 2014-06-09 13:45:48 +0200 |
---|---|---|
committer | Petr Viktorin <pviktori@redhat.com> | 2014-06-16 19:48:21 +0200 |
commit | 3b4ab8b4f224db67613544923a608c51ad476748 (patch) | |
tree | 90abd1db31e6f76bdac204242b09e7163f146d71 /ipaplatform/fedora | |
parent | 8a5e2a816667587bf767990dc2715d6996975d44 (diff) | |
download | freeipa-3b4ab8b4f224db67613544923a608c51ad476748.tar.gz freeipa-3b4ab8b4f224db67613544923a608c51ad476748.tar.xz freeipa-3b4ab8b4f224db67613544923a608c51ad476748.zip |
ipaplatform: Move hardcoded paths from Fedora platform files to path namespace
Part of: https://fedorahosted.org/freeipa/ticket/4052
Reviewed-By: Petr Viktorin <pviktori@redhat.com>
Diffstat (limited to 'ipaplatform/fedora')
-rw-r--r-- | ipaplatform/fedora/services.py | 15 | ||||
-rw-r--r-- | ipaplatform/fedora/tasks.py | 16 |
2 files changed, 15 insertions, 16 deletions
diff --git a/ipaplatform/fedora/services.py b/ipaplatform/fedora/services.py index 788f62a16..d98c2d6d7 100644 --- a/ipaplatform/fedora/services.py +++ b/ipaplatform/fedora/services.py @@ -31,6 +31,7 @@ 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 # to their actual systemd service names @@ -97,9 +98,7 @@ class FedoraDirectoryService(FedoraService): Returns False if the setting of the nofile limit needs to be skipped. """ - dirsrv_systemd = "/etc/sysconfig/dirsrv.systemd" - - if os.path.exists(dirsrv_systemd): + if os.path.exists(paths.SYSCONFIG_DIRSRV_SYSTEMD): # We need to enable LimitNOFILE=8192 in the dirsrv@.service # Since 389-ds-base-1.2.10-0.8.a7 the configuration of the # service parameters is performed via @@ -107,10 +106,10 @@ class FedoraDirectoryService(FedoraService): # into dirsrv@.service unit replacevars = {'LimitNOFILE': str(num)} - ipautil.inifile_replace_variables(dirsrv_systemd, + ipautil.inifile_replace_variables(paths.SYSCONFIG_DIRSRV_SYSTEMD, 'service', replacevars=replacevars) - tasks.restore_context(dirsrv_systemd) + tasks.restore_context(paths.SYSCONFIG_DIRSRV_SYSTEMD) ipautil.run(["/bin/systemctl", "--system", "daemon-reload"], raiseonerr=False) @@ -129,9 +128,9 @@ class FedoraDirectoryService(FedoraService): if instance_name: elements = self.systemd_name.split("@") - srv_etc = os.path.join(self.SYSTEMD_ETC_PATH, + srv_etc = os.path.join(paths.ETC_SYSTEMD_SYSTEM_DIR, self.systemd_name) - srv_tgt = os.path.join(self.SYSTEMD_ETC_PATH, + srv_tgt = os.path.join(paths.ETC_SYSTEMD_SYSTEM_DIR, self.SYSTEMD_SRV_TARGET % (elements[0])) srv_lnk = os.path.join(srv_tgt, self.service_instance(instance_name)) @@ -169,7 +168,7 @@ class FedoraCAService(FedoraService): # TODO: Use a cleaner solution use_proxy = True if not (os.path.exists('/etc/httpd/conf.d/ipa.conf') and - os.path.exists('/etc/httpd/conf.d/ipa-pki-proxy.conf')): + os.path.exists(paths.HTTPD_IPA_PKI_PROXY_CONF)): root_logger.debug( 'The httpd proxy is not installed, wait on local port') use_proxy = False diff --git a/ipaplatform/fedora/tasks.py b/ipaplatform/fedora/tasks.py index 525e550ce..a3a507364 100644 --- a/ipaplatform/fedora/tasks.py +++ b/ipaplatform/fedora/tasks.py @@ -41,7 +41,7 @@ from ipaplatform.base.tasks import * class FedoraTaskNamespace(BaseTaskNamespace): - def restore_context(self, filepath, restorecon='/sbin/restorecon'): + def restore_context(self, filepath, restorecon=paths.SBIN_RESTORECON): """ restore security context on the file path SELinux equivalent is /path/to/restorecon <filepath> @@ -157,7 +157,7 @@ class FedoraTaskNamespace(BaseTaskNamespace): # Add the CA to the systemwide CA trust database try: shutil.copy(cacert_path, new_cacert_path) - ipautil.run(['/usr/bin/update-ca-trust']) + ipautil.run([paths.UPDATE_CA_TRUST]) except OSError, e: root_logger.info("Failed to copy %s to %s" % (cacert_path, new_cacert_path)) @@ -181,7 +181,7 @@ class FedoraTaskNamespace(BaseTaskNamespace): if os.path.exists(new_cacert_path): try: os.remove(new_cacert_path) - ipautil.run(['/usr/bin/update-ca-trust']) + ipautil.run([paths.UPDATE_CA_TRUST]) except OSError, e: root_logger.error('Could not remove: %s, %s' % (new_cacert_path, str(e))) @@ -198,12 +198,12 @@ class FedoraTaskNamespace(BaseTaskNamespace): def backup_and_replace_hostname(self, fstore, statestore, hostname): old_hostname = socket.gethostname() try: - ipautil.run(['/bin/hostname', hostname]) + ipautil.run([paths.BIN_HOSTNAME, hostname]) except ipautil.CalledProcessError, e: print >>sys.stderr, ("Failed to set this machine hostname to " "%s (%s)." % (hostname, str(e))) - filepath = '/etc/hostname' + filepath = paths.ETC_HOSTNAME if os.path.exists(filepath): # read old hostname with open(filepath, 'r') as f: @@ -227,7 +227,7 @@ class FedoraTaskNamespace(BaseTaskNamespace): statestore.backup_state('network', 'hostname', old_hostname) def restore_network_configuration(self, fstore, statestore): - old_filepath = '/etc/sysconfig/network' + old_filepath = paths.SYSCONFIG_NETWORK old_hostname = statestore.get_state('network', 'hostname') hostname_was_configured = False @@ -235,13 +235,13 @@ class FedoraTaskNamespace(BaseTaskNamespace): # This is Fedora >=18 instance that was upgraded from previous # Fedora version which held network configuration # in /etc/sysconfig/network - old_filepath_restore = '/etc/sysconfig/network.ipabkp' + old_filepath_restore = paths.SYSCONFIG_NETWORK_IPABKP fstore.restore_file(old_filepath, old_filepath_restore) print "Deprecated configuration file '%s' was restored to '%s'" \ % (old_filepath, old_filepath_restore) hostname_was_configured = True - filepath = '/etc/hostname' + filepath = paths.ETC_HOSTNAME if fstore.has_file(filepath): fstore.restore_file(filepath) hostname_was_configured = True |