Blame SOURCES/0003-Abstract-ServiceCheck-to-not-be-IPA-specific.patch

9a84c2
From c40e32b9d0ac49806b8336bd5065350574d29672 Mon Sep 17 00:00:00 2001
9a84c2
From: Rob Crittenden <rcritten@redhat.com>
9a84c2
Date: Mon, 18 Nov 2019 12:51:27 -0500
9a84c2
Subject: [PATCH 3/5] Abstract ServiceCheck to not be IPA-specific
9a84c2
9a84c2
It is up to the implementor to check for services running for now.
9a84c2
---
9a84c2
 src/ipahealthcheck/core/main.py     |  9 +--------
9a84c2
 src/ipahealthcheck/core/service.py  | 10 ++++++++++
9a84c2
 src/ipahealthcheck/meta/services.py | 29 +++++++++++++++--------------
9a84c2
 3 files changed, 26 insertions(+), 22 deletions(-)
9a84c2
 create mode 100644 src/ipahealthcheck/core/service.py
9a84c2
9a84c2
diff --git a/src/ipahealthcheck/core/main.py b/src/ipahealthcheck/core/main.py
9a84c2
index f59a8a8..2b818d4 100644
9a84c2
--- a/src/ipahealthcheck/core/main.py
9a84c2
+++ b/src/ipahealthcheck/core/main.py
9a84c2
@@ -15,18 +15,11 @@ from ipahealthcheck.core.config import read_config
9a84c2
 from ipahealthcheck.core.plugin import Result, Results, json_to_results
9a84c2
 from ipahealthcheck.core.output import output_registry
9a84c2
 from ipahealthcheck.core import constants
9a84c2
+from ipahealthcheck.core.service import ServiceCheck
9a84c2
 
9a84c2
 logging.basicConfig(format='%(message)s')
9a84c2
 logger = logging.getLogger()
9a84c2
 
9a84c2
-try:
9a84c2
-    from ipaserver.install.installutils import is_ipa_configured
9a84c2
-except ImportError:
9a84c2
-    logging.error("IPA server packages are not installed on this system.")
9a84c2
-    sys.exit(1)
9a84c2
-else:
9a84c2
-    from ipahealthcheck.meta.services import ServiceCheck
9a84c2
-
9a84c2
 
9a84c2
 def find_registries(entry_points):
9a84c2
     registries = {}
9a84c2
diff --git a/src/ipahealthcheck/core/service.py b/src/ipahealthcheck/core/service.py
9a84c2
new file mode 100644
9a84c2
index 0000000..f9e2645
9a84c2
--- /dev/null
9a84c2
+++ b/src/ipahealthcheck/core/service.py
9a84c2
@@ -0,0 +1,10 @@
9a84c2
+#
9a84c2
+# Copyright (C) 2019 FreeIPA Contributors see COPYING for license
9a84c2
+#
9a84c2
+
9a84c2
+from ipahealthcheck.core.plugin import Plugin
9a84c2
+
9a84c2
+
9a84c2
+class ServiceCheck(Plugin):
9a84c2
+    def check(self, instance=''):
9a84c2
+        raise NotImplementedError
9a84c2
diff --git a/src/ipahealthcheck/meta/services.py b/src/ipahealthcheck/meta/services.py
9a84c2
index d375066..a987108 100644
9a84c2
--- a/src/ipahealthcheck/meta/services.py
9a84c2
+++ b/src/ipahealthcheck/meta/services.py
9a84c2
@@ -6,7 +6,8 @@ import logging
9a84c2
 
9a84c2
 from ipahealthcheck.core import constants
9a84c2
 from ipahealthcheck.core.plugin import Result, duration
9a84c2
-from ipahealthcheck.meta.plugin import Plugin, registry
9a84c2
+from ipahealthcheck.core.service import ServiceCheck
9a84c2
+from ipahealthcheck.meta.plugin import registry
9a84c2
 try:
9a84c2
     from ipapython.ipaldap import realm_to_serverid
9a84c2
 except ImportError:
9a84c2
@@ -20,7 +21,7 @@ from ipaserver.install import cainstance
9a84c2
 logger = logging.getLogger()
9a84c2
 
9a84c2
 
9a84c2
-class ServiceCheck(Plugin):
9a84c2
+class IPAServiceCheck(ServiceCheck):
9a84c2
     @duration
9a84c2
     def check(self, instance=''):
9a84c2
         try:
9a84c2
@@ -47,7 +48,7 @@ class ServiceCheck(Plugin):
9a84c2
 
9a84c2
 
9a84c2
 @registry
9a84c2
-class certmonger(ServiceCheck):
9a84c2
+class certmonger(IPAServiceCheck):
9a84c2
     def check(self):
9a84c2
         self.service_name = 'certmonger'
9a84c2
 
9a84c2
@@ -55,7 +56,7 @@ class certmonger(ServiceCheck):
9a84c2
 
9a84c2
 
9a84c2
 @registry
9a84c2
-class dirsrv(ServiceCheck):
9a84c2
+class dirsrv(IPAServiceCheck):
9a84c2
     def check(self):
9a84c2
         self.service_name = 'dirsrv'
9a84c2
 
9a84c2
@@ -63,7 +64,7 @@ class dirsrv(ServiceCheck):
9a84c2
 
9a84c2
 
9a84c2
 @registry
9a84c2
-class gssproxy(ServiceCheck):
9a84c2
+class gssproxy(IPAServiceCheck):
9a84c2
     def check(self):
9a84c2
         self.service_name = 'gssproxy'
9a84c2
 
9a84c2
@@ -71,7 +72,7 @@ class gssproxy(ServiceCheck):
9a84c2
 
9a84c2
 
9a84c2
 @registry
9a84c2
-class httpd(ServiceCheck):
9a84c2
+class httpd(IPAServiceCheck):
9a84c2
     def check(self):
9a84c2
         self.service_name = 'httpd'
9a84c2
 
9a84c2
@@ -79,7 +80,7 @@ class httpd(ServiceCheck):
9a84c2
 
9a84c2
 
9a84c2
 @registry
9a84c2
-class ipa_custodia(ServiceCheck):
9a84c2
+class ipa_custodia(IPAServiceCheck):
9a84c2
     def check(self):
9a84c2
         self.service_name = 'ipa-custodia'
9a84c2
 
9a84c2
@@ -87,7 +88,7 @@ class ipa_custodia(ServiceCheck):
9a84c2
 
9a84c2
 
9a84c2
 @registry
9a84c2
-class ipa_dnskeysyncd(ServiceCheck):
9a84c2
+class ipa_dnskeysyncd(IPAServiceCheck):
9a84c2
     def check(self):
9a84c2
         self.service_name = 'ipa-dnskeysyncd'
9a84c2
 
9a84c2
@@ -98,7 +99,7 @@ class ipa_dnskeysyncd(ServiceCheck):
9a84c2
 
9a84c2
 
9a84c2
 @registry
9a84c2
-class ipa_otpd(ServiceCheck):
9a84c2
+class ipa_otpd(IPAServiceCheck):
9a84c2
     def check(self):
9a84c2
         self.service_name = 'ipa-otpd'
9a84c2
 
9a84c2
@@ -106,7 +107,7 @@ class ipa_otpd(ServiceCheck):
9a84c2
 
9a84c2
 
9a84c2
 @registry
9a84c2
-class kadmin(ServiceCheck):
9a84c2
+class kadmin(IPAServiceCheck):
9a84c2
     def check(self):
9a84c2
         self.service_name = 'kadmin'
9a84c2
 
9a84c2
@@ -114,7 +115,7 @@ class kadmin(ServiceCheck):
9a84c2
 
9a84c2
 
9a84c2
 @registry
9a84c2
-class krb5kdc(ServiceCheck):
9a84c2
+class krb5kdc(IPAServiceCheck):
9a84c2
     def check(self):
9a84c2
         self.service_name = 'krb5kdc'
9a84c2
 
9a84c2
@@ -122,7 +123,7 @@ class krb5kdc(ServiceCheck):
9a84c2
 
9a84c2
 
9a84c2
 @registry
9a84c2
-class named(ServiceCheck):
9a84c2
+class named(IPAServiceCheck):
9a84c2
     def check(self):
9a84c2
         self.service_name = 'named'
9a84c2
 
9a84c2
@@ -133,7 +134,7 @@ class named(ServiceCheck):
9a84c2
 
9a84c2
 
9a84c2
 @registry
9a84c2
-class pki_tomcatd(ServiceCheck):
9a84c2
+class pki_tomcatd(IPAServiceCheck):
9a84c2
     def check(self):
9a84c2
         self.service_name = 'pki_tomcatd'
9a84c2
 
9a84c2
@@ -145,7 +146,7 @@ class pki_tomcatd(ServiceCheck):
9a84c2
 
9a84c2
 
9a84c2
 @registry
9a84c2
-class sssd(ServiceCheck):
9a84c2
+class sssd(IPAServiceCheck):
9a84c2
     def check(self):
9a84c2
         self.service_name = 'sssd'
9a84c2
 
9a84c2
-- 
9a84c2
2.20.1
9a84c2