From 50a2c45760d51e7a13888702e1a047a113bc1f5e Mon Sep 17 00:00:00 2001 From: Martin Kosek Date: Mon, 18 Jul 2011 09:33:57 +0200 Subject: Check IPA configuration in install tools Install tools may fail with unexpected error when IPA server is not installed on a system. Improve user experience by implementing a check to affected tools. https://fedorahosted.org/freeipa/ticket/1327 https://fedorahosted.org/freeipa/ticket/1347 --- ipaserver/install/installutils.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'ipaserver') diff --git a/ipaserver/install/installutils.py b/ipaserver/install/installutils.py index 68fce7e69..ba49eb8b7 100644 --- a/ipaserver/install/installutils.py +++ b/ipaserver/install/installutils.py @@ -32,8 +32,7 @@ import time import tempfile from ConfigParser import SafeConfigParser -from ipapython import ipautil -from ipapython import dnsclient +from ipapython import ipautil, dnsclient, sysrestore class HostnameLocalhost(Exception): pass @@ -499,3 +498,19 @@ def read_replica_info(dir, rconfig): rconfig.domain_name = config.get("realm", "domain_name") rconfig.host_name = config.get("realm", "destination_host") rconfig.subject_base = config.get("realm", "subject_base") + +def check_server_configuration(): + """ + Check if IPA server is configured on the system. + + This is done by checking if there are system restore (uninstall) files + present on the system. Note that this check can only be run with root + privileges. + + When IPA is not configured, this function raises a RuntimeError exception. + Most convenient use case for the function is in install tools that require + configured IPA for its function. + """ + server_fstore = sysrestore.FileStore('/var/lib/ipa/sysrestore') + if not server_fstore.has_files(): + raise RuntimeError("IPA is not configured on this system.") -- cgit