Blob Blame History Raw
From c40e32b9d0ac49806b8336bd5065350574d29672 Mon Sep 17 00:00:00 2001
From: Rob Crittenden <rcritten@redhat.com>
Date: Mon, 18 Nov 2019 12:51:27 -0500
Subject: [PATCH 3/5] Abstract ServiceCheck to not be IPA-specific

It is up to the implementor to check for services running for now.
---
 src/ipahealthcheck/core/main.py     |  9 +--------
 src/ipahealthcheck/core/service.py  | 10 ++++++++++
 src/ipahealthcheck/meta/services.py | 29 +++++++++++++++--------------
 3 files changed, 26 insertions(+), 22 deletions(-)
 create mode 100644 src/ipahealthcheck/core/service.py

diff --git a/src/ipahealthcheck/core/main.py b/src/ipahealthcheck/core/main.py
index f59a8a8..2b818d4 100644
--- a/src/ipahealthcheck/core/main.py
+++ b/src/ipahealthcheck/core/main.py
@@ -15,18 +15,11 @@ from ipahealthcheck.core.config import read_config
 from ipahealthcheck.core.plugin import Result, Results, json_to_results
 from ipahealthcheck.core.output import output_registry
 from ipahealthcheck.core import constants
+from ipahealthcheck.core.service import ServiceCheck
 
 logging.basicConfig(format='%(message)s')
 logger = logging.getLogger()
 
-try:
-    from ipaserver.install.installutils import is_ipa_configured
-except ImportError:
-    logging.error("IPA server packages are not installed on this system.")
-    sys.exit(1)
-else:
-    from ipahealthcheck.meta.services import ServiceCheck
-
 
 def find_registries(entry_points):
     registries = {}
diff --git a/src/ipahealthcheck/core/service.py b/src/ipahealthcheck/core/service.py
new file mode 100644
index 0000000..f9e2645
--- /dev/null
+++ b/src/ipahealthcheck/core/service.py
@@ -0,0 +1,10 @@
+#
+# Copyright (C) 2019 FreeIPA Contributors see COPYING for license
+#
+
+from ipahealthcheck.core.plugin import Plugin
+
+
+class ServiceCheck(Plugin):
+    def check(self, instance=''):
+        raise NotImplementedError
diff --git a/src/ipahealthcheck/meta/services.py b/src/ipahealthcheck/meta/services.py
index d375066..a987108 100644
--- a/src/ipahealthcheck/meta/services.py
+++ b/src/ipahealthcheck/meta/services.py
@@ -6,7 +6,8 @@ import logging
 
 from ipahealthcheck.core import constants
 from ipahealthcheck.core.plugin import Result, duration
-from ipahealthcheck.meta.plugin import Plugin, registry
+from ipahealthcheck.core.service import ServiceCheck
+from ipahealthcheck.meta.plugin import registry
 try:
     from ipapython.ipaldap import realm_to_serverid
 except ImportError:
@@ -20,7 +21,7 @@ from ipaserver.install import cainstance
 logger = logging.getLogger()
 
 
-class ServiceCheck(Plugin):
+class IPAServiceCheck(ServiceCheck):
     @duration
     def check(self, instance=''):
         try:
@@ -47,7 +48,7 @@ class ServiceCheck(Plugin):
 
 
 @registry
-class certmonger(ServiceCheck):
+class certmonger(IPAServiceCheck):
     def check(self):
         self.service_name = 'certmonger'
 
@@ -55,7 +56,7 @@ class certmonger(ServiceCheck):
 
 
 @registry
-class dirsrv(ServiceCheck):
+class dirsrv(IPAServiceCheck):
     def check(self):
         self.service_name = 'dirsrv'
 
@@ -63,7 +64,7 @@ class dirsrv(ServiceCheck):
 
 
 @registry
-class gssproxy(ServiceCheck):
+class gssproxy(IPAServiceCheck):
     def check(self):
         self.service_name = 'gssproxy'
 
@@ -71,7 +72,7 @@ class gssproxy(ServiceCheck):
 
 
 @registry
-class httpd(ServiceCheck):
+class httpd(IPAServiceCheck):
     def check(self):
         self.service_name = 'httpd'
 
@@ -79,7 +80,7 @@ class httpd(ServiceCheck):
 
 
 @registry
-class ipa_custodia(ServiceCheck):
+class ipa_custodia(IPAServiceCheck):
     def check(self):
         self.service_name = 'ipa-custodia'
 
@@ -87,7 +88,7 @@ class ipa_custodia(ServiceCheck):
 
 
 @registry
-class ipa_dnskeysyncd(ServiceCheck):
+class ipa_dnskeysyncd(IPAServiceCheck):
     def check(self):
         self.service_name = 'ipa-dnskeysyncd'
 
@@ -98,7 +99,7 @@ class ipa_dnskeysyncd(ServiceCheck):
 
 
 @registry
-class ipa_otpd(ServiceCheck):
+class ipa_otpd(IPAServiceCheck):
     def check(self):
         self.service_name = 'ipa-otpd'
 
@@ -106,7 +107,7 @@ class ipa_otpd(ServiceCheck):
 
 
 @registry
-class kadmin(ServiceCheck):
+class kadmin(IPAServiceCheck):
     def check(self):
         self.service_name = 'kadmin'
 
@@ -114,7 +115,7 @@ class kadmin(ServiceCheck):
 
 
 @registry
-class krb5kdc(ServiceCheck):
+class krb5kdc(IPAServiceCheck):
     def check(self):
         self.service_name = 'krb5kdc'
 
@@ -122,7 +123,7 @@ class krb5kdc(ServiceCheck):
 
 
 @registry
-class named(ServiceCheck):
+class named(IPAServiceCheck):
     def check(self):
         self.service_name = 'named'
 
@@ -133,7 +134,7 @@ class named(ServiceCheck):
 
 
 @registry
-class pki_tomcatd(ServiceCheck):
+class pki_tomcatd(IPAServiceCheck):
     def check(self):
         self.service_name = 'pki_tomcatd'
 
@@ -145,7 +146,7 @@ class pki_tomcatd(ServiceCheck):
 
 
 @registry
-class sssd(ServiceCheck):
+class sssd(IPAServiceCheck):
     def check(self):
         self.service_name = 'sssd'
 
-- 
2.20.1