summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Basti <mbasti@redhat.com>2015-01-27 11:04:03 +0100
committerMartin Kosek <mkosek@redhat.com>2015-02-18 10:05:45 +0100
commitc3edfa2d8cee8f318837fb31680b495035a8bd2d (patch)
tree28288d817156bd4a27af122e1803b7a49c274e1d
parent76d401bb882283b039de2ceee8300d0c838db473 (diff)
Fix restoring services status during uninstall
Services hasn't been restored correctly, which causes disabling already disabled services, or some service did not start. This patch fix these issues. Ticket: https://fedorahosted.org/freeipa/ticket/4869 Reviewed-By: David Kupka <dkupka@redhat.com>
-rw-r--r--ipaserver/install/bindinstance.py11
-rw-r--r--ipaserver/install/cainstance.py6
-rw-r--r--ipaserver/install/dnskeysyncinstance.py19
-rw-r--r--ipaserver/install/dsinstance.py5
-rw-r--r--ipaserver/install/httpinstance.py15
-rw-r--r--ipaserver/install/krbinstance.py9
-rw-r--r--ipaserver/install/ntpinstance.py14
-rw-r--r--ipaserver/install/odsexporterinstance.py14
-rw-r--r--ipaserver/install/opendnssecinstance.py10
-rw-r--r--ipaserver/install/service.py15
10 files changed, 58 insertions, 60 deletions
diff --git a/ipaserver/install/bindinstance.py b/ipaserver/install/bindinstance.py
index 4e630e8dd..cd1c7e7a6 100644
--- a/ipaserver/install/bindinstance.py
+++ b/ipaserver/install/bindinstance.py
@@ -1179,8 +1179,6 @@ class BindInstance(service.Service):
self.dns_backup.clear_records(api.Backend.ldap2.isconnected())
- if not running is None:
- self.stop()
for f in [NAMED_CONF, RESOLV_CONF]:
try:
@@ -1189,11 +1187,12 @@ class BindInstance(service.Service):
root_logger.debug(error)
pass
- if not enabled is None and not enabled:
- self.disable()
+ # disabled by default, by ldap_enable()
+ if enabled:
+ self.enable()
- if not running is None and running:
- self.start()
+ if running:
+ self.restart()
self.named_regular.unmask()
if named_regular_enabled:
diff --git a/ipaserver/install/cainstance.py b/ipaserver/install/cainstance.py
index a61534d50..8ba6e4616 100644
--- a/ipaserver/install/cainstance.py
+++ b/ipaserver/install/cainstance.py
@@ -1273,8 +1273,10 @@ class CAInstance(DogtagInstance):
def uninstall(self):
enabled = self.restore_state("enabled")
- if not enabled is None and not enabled:
- self.disable()
+
+ # disabled by default, by ldap_enable()
+ if enabled:
+ self.enable()
if self.dogtag_constants.DOGTAG_VERSION >= 10:
DogtagInstance.uninstall(self)
diff --git a/ipaserver/install/dnskeysyncinstance.py b/ipaserver/install/dnskeysyncinstance.py
index 5da65d87b..1396d01a7 100644
--- a/ipaserver/install/dnskeysyncinstance.py
+++ b/ipaserver/install/dnskeysyncinstance.py
@@ -124,8 +124,6 @@ class DNSKeySyncInstance(service.Service):
self.fqdn = fqdn
self.realm = realm_name
self.suffix = ipautil.realm_to_suffix(self.realm)
- self.backup_state("enabled", self.is_enabled())
- self.backup_state("running", self.is_running())
try:
self.stop()
except:
@@ -417,7 +415,6 @@ class DNSKeySyncInstance(service.Service):
self.suffix, self.extra_config)
except errors.DuplicateEntry:
self.logger.error("DNSKeySync service already exists")
- self.enable()
def __setup_principal(self):
assert self.ods_gid is not None
@@ -480,11 +477,13 @@ class DNSKeySyncInstance(service.Service):
self.print_msg("Unconfiguring %s" % self.service_name)
- running = self.restore_state("running")
- enabled = self.restore_state("enabled")
+ # Just eat states
+ self.restore_state("running")
+ self.restore_state("enabled")
- if running is not None:
- self.stop()
+ # stop and disable service (IPA service, we do not need it anymore)
+ self.stop()
+ self.disable()
for f in [paths.SYSCONFIG_NAMED]:
try:
@@ -500,9 +499,3 @@ class DNSKeySyncInstance(service.Service):
os.remove(paths.DNSSEC_SOFTHSM_PIN)
except Exception:
pass
-
- if enabled is not None and not enabled:
- self.disable()
-
- if running is not None and running:
- self.start()
diff --git a/ipaserver/install/dsinstance.py b/ipaserver/install/dsinstance.py
index 1e07c6d0d..6bf31da99 100644
--- a/ipaserver/install/dsinstance.py
+++ b/ipaserver/install/dsinstance.py
@@ -771,8 +771,9 @@ class DsInstance(service.Service):
root_logger.debug(error)
pass
- if not enabled is None and not enabled:
- self.disable()
+ # disabled during IPA installation
+ if enabled:
+ self.enable()
serverid = self.restore_state("serverid")
if serverid is not None:
diff --git a/ipaserver/install/httpinstance.py b/ipaserver/install/httpinstance.py
index cda85ab02..18cf6bb1a 100644
--- a/ipaserver/install/httpinstance.py
+++ b/ipaserver/install/httpinstance.py
@@ -146,7 +146,7 @@ class HTTPInstance(service.Service):
self.restart()
def __enable(self):
- self.backup_state("enabled", self.is_running())
+ self.backup_state("enabled", self.is_enabled())
# We do not let the system start IPA components on its own,
# Instead we reply on the IPA init script to start only enabled
# components as found in our LDAP configuration tree
@@ -388,8 +388,6 @@ class HTTPInstance(service.Service):
running = self.restore_state("running")
enabled = self.restore_state("enabled")
- if not running is None:
- self.stop()
self.stop_tracking_certificates()
@@ -407,9 +405,6 @@ class HTTPInstance(service.Service):
ca_iface.Set('org.fedorahosted.certmonger.ca',
'external-helper', helper)
- if not enabled is None and not enabled:
- self.disable()
-
for f in [paths.HTTPD_IPA_CONF, paths.HTTPD_SSL_CONF, paths.HTTPD_NSS_CONF]:
try:
self.fstore.restore_file(f)
@@ -430,8 +425,12 @@ class HTTPInstance(service.Service):
except ipapython.errors.SetseboolError as e:
self.print_msg('WARNING: ' + str(e))
- if not running is None and running:
- self.start()
+ if running:
+ self.restart()
+
+ # disabled by default, by ldap_enable()
+ if enabled:
+ self.enable()
def stop_tracking_certificates(self):
db = certs.CertDB(api.env.realm)
diff --git a/ipaserver/install/krbinstance.py b/ipaserver/install/krbinstance.py
index 6a480222f..266adb33b 100644
--- a/ipaserver/install/krbinstance.py
+++ b/ipaserver/install/krbinstance.py
@@ -454,11 +454,12 @@ class KrbInstance(service.Service):
root_logger.debug(error)
pass
- if not enabled is None and not enabled:
- self.disable()
+ # disabled by default, by ldap_enable()
+ if enabled:
+ self.enable()
- if not running is None and running:
- self.start()
+ if running:
+ self.restart()
self.kpasswd = KpasswdInstance()
self.kpasswd.uninstall()
diff --git a/ipaserver/install/ntpinstance.py b/ipaserver/install/ntpinstance.py
index f2edf9bc1..cdab0ae26 100644
--- a/ipaserver/install/ntpinstance.py
+++ b/ipaserver/install/ntpinstance.py
@@ -165,8 +165,10 @@ class NTPInstance(service.Service):
running = self.restore_state("running")
enabled = self.restore_state("enabled")
- if not running is None:
- self.stop()
+ # service is not in LDAP, stop and disable service
+ # before restoring configuration
+ self.stop()
+ self.disable()
try:
self.fstore.restore_file(paths.NTP_CONF)
@@ -174,8 +176,8 @@ class NTPInstance(service.Service):
root_logger.debug(error)
pass
- if not enabled is None and not enabled:
- self.disable()
+ if enabled:
+ self.enable()
- if not running is None and running:
- self.start()
+ if running:
+ self.restart()
diff --git a/ipaserver/install/odsexporterinstance.py b/ipaserver/install/odsexporterinstance.py
index 57b1451c0..e01550446 100644
--- a/ipaserver/install/odsexporterinstance.py
+++ b/ipaserver/install/odsexporterinstance.py
@@ -82,7 +82,6 @@ class ODSExporterInstance(service.Service):
self.suffix)
except errors.DuplicateEntry:
root_logger.error("DNSKeyExporter service already exists")
- self.enable()
def __setup_key_exporter(self):
installutils.set_directive(paths.SYSOCNFIG_IPA_ODS_EXPORTER,
@@ -155,14 +154,13 @@ class ODSExporterInstance(service.Service):
self.print_msg("Unconfiguring %s" % self.service_name)
- running = self.restore_state("running")
- enabled = self.restore_state("enabled")
+ # just eat states
+ self.restore_state("running")
+ self.restore_state("enabled")
- if enabled is not None and not enabled:
- self.disable()
-
- if running is not None and running:
- self.start()
+ # stop and disable service (IPA service, we do not need it anymore)
+ self.disable()
+ self.stop()
# restore state of dnssec default signer daemon
signerd_enabled = self.restore_state("singerd_enabled")
diff --git a/ipaserver/install/opendnssecinstance.py b/ipaserver/install/opendnssecinstance.py
index 0d2fb009e..869cf8ffe 100644
--- a/ipaserver/install/opendnssecinstance.py
+++ b/ipaserver/install/opendnssecinstance.py
@@ -149,7 +149,6 @@ class OpenDNSSECInstance(service.Service):
self.suffix, self.extra_config)
except errors.DuplicateEntry:
root_logger.error("DNSSEC service already exists")
- self.enable()
def __setup_conf_files(self):
if not self.fstore.has_file(paths.OPENDNSSEC_CONF_FILE):
@@ -292,8 +291,9 @@ class OpenDNSSECInstance(service.Service):
root_logger.debug(error)
pass
- if enabled is not None and not enabled:
- self.disable()
+ # disabled by default, by ldap_enable()
+ if enabled:
+ self.enable()
- if running is not None and running:
- self.start()
+ if running:
+ self.restart()
diff --git a/ipaserver/install/service.py b/ipaserver/install/service.py
index 3ae43d8f3..836d701a0 100644
--- a/ipaserver/install/service.py
+++ b/ipaserver/install/service.py
@@ -518,11 +518,14 @@ class SimpleServiceInstance(Service):
if self.is_configured():
self.print_msg("Unconfiguring %s" % self.service_name)
+ self.stop()
+ self.disable()
+
running = self.restore_state("running")
- enabled = not self.restore_state("enabled")
+ enabled = self.restore_state("enabled")
- if not running is None and not running:
- self.stop()
- if not enabled is None and not enabled:
- self.disable()
- self.remove()
+ # restore the original state of service
+ if running:
+ self.start()
+ if enabled:
+ self.enable()