summaryrefslogtreecommitdiffstats
path: root/ipaserver/install/installutils.py
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2011-08-29 11:16:52 -0400
committerRob Crittenden <rcritten@redhat.com>2011-08-29 16:49:52 -0400
commit91c9e8320932124ff77178383a0531fb2b218f2f (patch)
tree7b0b634de14e385f76cd9fddb5af6f9cad786fdf /ipaserver/install/installutils.py
parent28e6d137afa65f638ea6e748eb39bce9aa83e403 (diff)
downloadfreeipa-91c9e8320932124ff77178383a0531fb2b218f2f.tar.gz
freeipa-91c9e8320932124ff77178383a0531fb2b218f2f.tar.xz
freeipa-91c9e8320932124ff77178383a0531fb2b218f2f.zip
Add common is_installed() fn, better uninstall logging, check for errors.
The installer and ipactl used two different methods to determine whether IPA was configured, unify them. When uninstalling report any thing that looks suspicious and warn that a re-install may fail. This includes any remaining 389-ds instances and any state or files that remains after all the module uninstallers are complete. Add wrappers for removing files and directories to log failures. https://fedorahosted.org/freeipa/ticket/1715
Diffstat (limited to 'ipaserver/install/installutils.py')
-rw-r--r--ipaserver/install/installutils.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/ipaserver/install/installutils.py b/ipaserver/install/installutils.py
index df63b8e8c..d7eb65104 100644
--- a/ipaserver/install/installutils.py
+++ b/ipaserver/install/installutils.py
@@ -30,10 +30,14 @@ import fcntl
import netaddr
import time
import tempfile
+import shutil
from ConfigParser import SafeConfigParser
from ipapython import ipautil, dnsclient, sysrestore
+# Used to determine install status
+IPA_MODULES = ['httpd', 'ipa_kpasswd', 'dirsrv', 'pki-cad', 'pkids', 'install', 'krb5kdc', 'ntpd', 'named']
+
class HostnameLocalhost(Exception):
pass
@@ -508,3 +512,48 @@ def check_server_configuration():
server_fstore = sysrestore.FileStore('/var/lib/ipa/sysrestore')
if not server_fstore.has_files():
raise RuntimeError("IPA is not configured on this system.")
+
+def remove_file(filename):
+ """
+ Remove a file and log any exceptions raised.
+ """
+ try:
+ if os.path.exists(filename):
+ os.unlink(filename)
+ except Exception, e:
+ logging.error('Error removing %s: %s' % (filename, str(e)))
+
+def rmtree(path):
+ """
+ Remove a directory structure and log any exceptions raised.
+ """
+ try:
+ if os.path.exists(path):
+ shutil.rmtree(path)
+ except Exception, e:
+ logging.error('Error removing %s: %s' % (path, str(e)))
+
+def is_ipa_configured():
+ """
+ Using the state and index install files determine if IPA is already
+ configured.
+ """
+ installed = False
+
+ sstore = sysrestore.StateFile('/var/lib/ipa/sysrestore')
+ fstore = sysrestore.FileStore('/var/lib/ipa/sysrestore')
+
+ for module in IPA_MODULES:
+ if sstore.has_state(module):
+ logging.debug('%s is configured' % module)
+ installed = True
+ else:
+ logging.debug('%s is not configured' % module)
+
+ if fstore.has_files():
+ logging.debug('filestore has files')
+ installed = True
+ else:
+ logging.debug('filestore is tracking no files')
+
+ return installed