|
|
26e6ce |
From 9d5f9d21442ee483044fc55a5c02039af23869d7 Mon Sep 17 00:00:00 2001
|
|
|
ed4527 |
From: Rob Crittenden <rcritten@redhat.com>
|
|
|
26e6ce |
Date: Thu, 1 Dec 2022 14:22:46 -0500
|
|
|
ed4527 |
Subject: [PATCH] Remove ipaclustercheck
|
|
|
ed4527 |
|
|
|
ed4527 |
---
|
|
|
ed4527 |
setup.py | 12 +-
|
|
|
ed4527 |
src/ipaclustercheck/__init__.py | 5 -
|
|
|
ed4527 |
src/ipaclustercheck/core/__init__.py | 0
|
|
|
26e6ce |
src/ipaclustercheck/core/main.py | 32 ------
|
|
|
26e6ce |
src/ipaclustercheck/core/output.py | 68 -----------
|
|
|
ed4527 |
src/ipaclustercheck/ipa/__init__.py | 0
|
|
|
ed4527 |
src/ipaclustercheck/ipa/crlmanager.py | 36 ------
|
|
|
26e6ce |
src/ipaclustercheck/ipa/plugin.py | 117 -------------------
|
|
|
26e6ce |
src/ipaclustercheck/ipa/ruv.py | 155 --------------------------
|
|
|
ed4527 |
tests/test_cluster_ruv.py | 106 ------------------
|
|
|
26e6ce |
10 files changed, 1 insertion(+), 530 deletions(-)
|
|
|
ed4527 |
delete mode 100644 src/ipaclustercheck/__init__.py
|
|
|
ed4527 |
delete mode 100644 src/ipaclustercheck/core/__init__.py
|
|
|
ed4527 |
delete mode 100644 src/ipaclustercheck/core/main.py
|
|
|
ed4527 |
delete mode 100644 src/ipaclustercheck/core/output.py
|
|
|
ed4527 |
delete mode 100644 src/ipaclustercheck/ipa/__init__.py
|
|
|
ed4527 |
delete mode 100644 src/ipaclustercheck/ipa/crlmanager.py
|
|
|
ed4527 |
delete mode 100644 src/ipaclustercheck/ipa/plugin.py
|
|
|
ed4527 |
delete mode 100644 src/ipaclustercheck/ipa/ruv.py
|
|
|
ed4527 |
delete mode 100644 tests/test_cluster_ruv.py
|
|
|
ed4527 |
|
|
|
ed4527 |
diff --git a/setup.py b/setup.py
|
|
|
26e6ce |
index 0cfa486..b9e1ca1 100644
|
|
|
ed4527 |
--- a/setup.py
|
|
|
ed4527 |
+++ b/setup.py
|
|
|
ed4527 |
@@ -4,7 +4,7 @@ from setuptools import find_packages, setup
|
|
|
ed4527 |
setup(
|
|
|
ed4527 |
name='ipahealthcheck',
|
|
|
26e6ce |
version='0.12',
|
|
|
ed4527 |
- namespace_packages=['ipahealthcheck', 'ipaclustercheck'],
|
|
|
ed4527 |
+ namespace_packages=['ipahealthcheck'],
|
|
|
ed4527 |
package_dir={'': 'src'},
|
|
|
ed4527 |
# packages=find_packages(where='src'),
|
|
|
ed4527 |
packages=[
|
|
|
ed4527 |
@@ -14,14 +14,11 @@ setup(
|
|
|
ed4527 |
'ipahealthcheck.ipa',
|
|
|
ed4527 |
'ipahealthcheck.meta',
|
|
|
ed4527 |
'ipahealthcheck.system',
|
|
|
ed4527 |
- 'ipaclustercheck.core',
|
|
|
ed4527 |
- 'ipaclustercheck.ipa',
|
|
|
ed4527 |
],
|
|
|
ed4527 |
entry_points={
|
|
|
ed4527 |
# creates bin/ipahealthcheck
|
|
|
ed4527 |
'console_scripts': [
|
|
|
ed4527 |
'ipa-healthcheck = ipahealthcheck.core.main:main',
|
|
|
ed4527 |
- 'ipa-clustercheck = ipaclustercheck.core.main:main',
|
|
|
ed4527 |
],
|
|
|
ed4527 |
# subsystem registries
|
|
|
ed4527 |
'ipahealthcheck.registry': [
|
|
|
26e6ce |
@@ -72,13 +69,6 @@ setup(
|
|
|
ed4527 |
'ipahealthcheck.system': [
|
|
|
ed4527 |
'filesystemspace = ipahealthcheck.system.filesystemspace',
|
|
|
ed4527 |
],
|
|
|
ed4527 |
- 'ipaclustercheck.registry': [
|
|
|
ed4527 |
- 'ipaclustercheck.ipa = ipaclustercheck.ipa.plugin:registry',
|
|
|
ed4527 |
- ],
|
|
|
ed4527 |
- 'ipaclustercheck.ipa': [
|
|
|
ed4527 |
- 'crl = ipaclustercheck.ipa.crlmanager',
|
|
|
ed4527 |
- 'ruv = ipaclustercheck.ipa.ruv',
|
|
|
ed4527 |
- ],
|
|
|
ed4527 |
},
|
|
|
ed4527 |
classifiers=[
|
|
|
ed4527 |
'Programming Language :: Python :: 3.6',
|
|
|
ed4527 |
diff --git a/src/ipaclustercheck/__init__.py b/src/ipaclustercheck/__init__.py
|
|
|
ed4527 |
deleted file mode 100644
|
|
|
ed4527 |
index 6c91ef7..0000000
|
|
|
ed4527 |
--- a/src/ipaclustercheck/__init__.py
|
|
|
ed4527 |
+++ /dev/null
|
|
|
ed4527 |
@@ -1,5 +0,0 @@
|
|
|
ed4527 |
-#
|
|
|
ed4527 |
-# Copyright (C) 2019 FreeIPA Contributors see COPYING for license
|
|
|
ed4527 |
-#
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-__import__('pkg_resources').declare_namespace(__name__)
|
|
|
ed4527 |
diff --git a/src/ipaclustercheck/core/__init__.py b/src/ipaclustercheck/core/__init__.py
|
|
|
ed4527 |
deleted file mode 100644
|
|
|
ed4527 |
index e69de29..0000000
|
|
|
ed4527 |
diff --git a/src/ipaclustercheck/core/main.py b/src/ipaclustercheck/core/main.py
|
|
|
ed4527 |
deleted file mode 100644
|
|
|
26e6ce |
index f475832..0000000
|
|
|
ed4527 |
--- a/src/ipaclustercheck/core/main.py
|
|
|
ed4527 |
+++ /dev/null
|
|
|
26e6ce |
@@ -1,32 +0,0 @@
|
|
|
ed4527 |
-#
|
|
|
ed4527 |
-# Copyright (C) 2020 FreeIPA Contributors see COPYING for license
|
|
|
ed4527 |
-#
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-import sys
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-from ipaclustercheck.core.output import output_registry
|
|
|
ed4527 |
-from ipahealthcheck.core.core import RunChecks
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-class ClusterChecks(RunChecks):
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- def add_options(self):
|
|
|
ed4527 |
- parser = self.parser
|
|
|
ed4527 |
- parser.add_argument('--directory', dest='dir',
|
|
|
ed4527 |
- help='Directory holding healthcheck logs')
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- def validate_options(self):
|
|
|
26e6ce |
- super().validate_options()
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- if self.options.dir is None:
|
|
|
ed4527 |
- print("--directory containing logs to check is required")
|
|
|
ed4527 |
- return 1
|
|
|
ed4527 |
-
|
|
|
26e6ce |
- return None
|
|
|
26e6ce |
-
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-def main():
|
|
|
ed4527 |
- clusterchecks = ClusterChecks(['ipaclustercheck.registry'],
|
|
|
ed4527 |
- '/etc/ipa/clustercheck.conf',
|
|
|
ed4527 |
- output_registry, 'ansible')
|
|
|
ed4527 |
- sys.exit(clusterchecks.run_healthcheck())
|
|
|
ed4527 |
diff --git a/src/ipaclustercheck/core/output.py b/src/ipaclustercheck/core/output.py
|
|
|
ed4527 |
deleted file mode 100644
|
|
|
26e6ce |
index 909eac4..0000000
|
|
|
ed4527 |
--- a/src/ipaclustercheck/core/output.py
|
|
|
ed4527 |
+++ /dev/null
|
|
|
26e6ce |
@@ -1,68 +0,0 @@
|
|
|
ed4527 |
-#
|
|
|
ed4527 |
-# Copyright (C) 2019 FreeIPA Contributors see COPYING for license
|
|
|
ed4527 |
-#
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-import json
|
|
|
ed4527 |
-from ipahealthcheck.core.output import OutputRegistry, Output
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-output_registry = OutputRegistry()
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-class ClusterOutput(Output):
|
|
|
ed4527 |
- """Base class for writing/display output of cluster results
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- severity doesn't apply in this case so exclude those.
|
|
|
ed4527 |
- """
|
|
|
ed4527 |
- def __init__(self, options):
|
|
|
26e6ce |
- self.filename = options.output_file
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- def strip_output(self, results):
|
|
|
ed4527 |
- """Nothing to strip out"""
|
|
|
26e6ce |
- return list(results.output())
|
|
|
26e6ce |
-
|
|
|
26e6ce |
- def generate(self, data):
|
|
|
26e6ce |
- raise NotImplementedError
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-@output_registry
|
|
|
ed4527 |
-class Ansible(ClusterOutput):
|
|
|
ed4527 |
- """Output information JSON format for consumption by Ansible
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- Required keywords in a Result:
|
|
|
ed4527 |
- name - unique identifier for the return value
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- One of these is required:
|
|
|
ed4527 |
- value - the return value. Type? I dunno yet
|
|
|
ed4527 |
- error - if an error was returned
|
|
|
ed4527 |
- """
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- options = (
|
|
|
ed4527 |
- ('--indent', dict(dest='indent', type=int, default=2,
|
|
|
ed4527 |
- help='Indention level of JSON output')),
|
|
|
ed4527 |
- )
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- def __init__(self, options):
|
|
|
26e6ce |
- super().__init__(options)
|
|
|
ed4527 |
- self.indent = options.indent
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- def generate(self, data):
|
|
|
ed4527 |
- output = []
|
|
|
ed4527 |
- for line in data:
|
|
|
ed4527 |
- kw = line.get('kw')
|
|
|
ed4527 |
- name = kw.get('name')
|
|
|
ed4527 |
- value = kw.get('value')
|
|
|
ed4527 |
- error = kw.get('error')
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- if value and error:
|
|
|
ed4527 |
- value = '%s: %s' % (error, value)
|
|
|
ed4527 |
- elif error:
|
|
|
ed4527 |
- value = error
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- rval = {'%s' % name: value}
|
|
|
ed4527 |
- output.append(rval)
|
|
|
26e6ce |
-
|
|
|
ed4527 |
- output = json.dumps(output, indent=self.indent)
|
|
|
ed4527 |
- if self.filename is None:
|
|
|
ed4527 |
- output += '\n'
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- return output
|
|
|
ed4527 |
diff --git a/src/ipaclustercheck/ipa/__init__.py b/src/ipaclustercheck/ipa/__init__.py
|
|
|
ed4527 |
deleted file mode 100644
|
|
|
ed4527 |
index e69de29..0000000
|
|
|
ed4527 |
diff --git a/src/ipaclustercheck/ipa/crlmanager.py b/src/ipaclustercheck/ipa/crlmanager.py
|
|
|
ed4527 |
deleted file mode 100644
|
|
|
ed4527 |
index 6806d74..0000000
|
|
|
ed4527 |
--- a/src/ipaclustercheck/ipa/crlmanager.py
|
|
|
ed4527 |
+++ /dev/null
|
|
|
ed4527 |
@@ -1,36 +0,0 @@
|
|
|
ed4527 |
-#
|
|
|
ed4527 |
-# Copyright (C) 2019 FreeIPA Contributors see COPYING for license
|
|
|
ed4527 |
-#
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-from ipaclustercheck.ipa.plugin import ClusterPlugin, registry, find_checks
|
|
|
ed4527 |
-from ipahealthcheck.core.plugin import Result, duration
|
|
|
ed4527 |
-from ipahealthcheck.core import constants
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-@registry
|
|
|
ed4527 |
-class ClusterCRLManagerCheck(ClusterPlugin):
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- @duration
|
|
|
ed4527 |
- def check(self):
|
|
|
ed4527 |
- data = self.registry.json
|
|
|
ed4527 |
- crlmanagers = []
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- for fqdn in data.keys():
|
|
|
ed4527 |
- output = find_checks(data[fqdn], 'ipahealthcheck.ipa.roles',
|
|
|
ed4527 |
- 'IPACRLManagerCheck')
|
|
|
ed4527 |
- enabled = output[0].get('kw').get('crlgen_enabled')
|
|
|
ed4527 |
- if enabled:
|
|
|
ed4527 |
- crlmanagers.append(fqdn)
|
|
|
ed4527 |
- if len(crlmanagers) == 0:
|
|
|
ed4527 |
- yield Result(self, constants.ERROR,
|
|
|
ed4527 |
- name='crlmanager',
|
|
|
ed4527 |
- error='No CRL Manager defined')
|
|
|
ed4527 |
- elif len(crlmanagers) == 1:
|
|
|
ed4527 |
- yield Result(self, constants.SUCCESS,
|
|
|
ed4527 |
- name='crlmanager',
|
|
|
ed4527 |
- value=crlmanagers[0])
|
|
|
ed4527 |
- else:
|
|
|
ed4527 |
- yield Result(self, constants.ERROR,
|
|
|
ed4527 |
- name='crlmanager',
|
|
|
ed4527 |
- value=','.join(crlmanagers),
|
|
|
ed4527 |
- error='Multiple CRL Managers defined')
|
|
|
ed4527 |
diff --git a/src/ipaclustercheck/ipa/plugin.py b/src/ipaclustercheck/ipa/plugin.py
|
|
|
ed4527 |
deleted file mode 100644
|
|
|
26e6ce |
index a111988..0000000
|
|
|
ed4527 |
--- a/src/ipaclustercheck/ipa/plugin.py
|
|
|
ed4527 |
+++ /dev/null
|
|
|
26e6ce |
@@ -1,117 +0,0 @@
|
|
|
ed4527 |
-#
|
|
|
ed4527 |
-# Copyright (C) 2020 FreeIPA Contributors see COPYING for license
|
|
|
ed4527 |
-#
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-from copy import deepcopy
|
|
|
ed4527 |
-import json
|
|
|
ed4527 |
-import logging
|
|
|
ed4527 |
-from os import listdir
|
|
|
ed4527 |
-from os.path import isfile, join
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-from ipahealthcheck.core.plugin import Plugin, Registry
|
|
|
ed4527 |
-from ipalib import api
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-logger = logging.getLogger()
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-def find_checks(data, source, check):
|
|
|
ed4527 |
- """Look through the dict for a matching source and check.
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- data: dict of source and check output
|
|
|
ed4527 |
- source: name of source to find
|
|
|
ed4527 |
- check: name of check to find
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- Returns list of contents of source + check or empty list
|
|
|
ed4527 |
- """
|
|
|
ed4527 |
- rval = []
|
|
|
ed4527 |
- for d in data:
|
|
|
ed4527 |
- if d.get('source') == source and d.get('check') == check:
|
|
|
ed4527 |
- rval.append(d)
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- return rval
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-def get_masters(data):
|
|
|
ed4527 |
- """
|
|
|
ed4527 |
- Return the list of known masters
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- This is determined from the list of loaded healthcheck logs. It
|
|
|
ed4527 |
- is possible that mixed versions are used so some may not be
|
|
|
ed4527 |
- reporting the full list of masters, so check them all, and raise
|
|
|
ed4527 |
- an exception if the list cannot be determined.
|
|
|
ed4527 |
- """
|
|
|
ed4527 |
- test_masters = list(data)
|
|
|
ed4527 |
- masters = None
|
|
|
ed4527 |
- for master in test_masters:
|
|
|
ed4527 |
- output = find_checks(data[master], 'ipahealthcheck.ipa.meta',
|
|
|
ed4527 |
- 'IPAMetaCheck')
|
|
|
ed4527 |
- if len(output) == 0:
|
|
|
ed4527 |
- raise ValueError('Unable to determine full list of masters. '
|
|
|
ed4527 |
- 'ipahealthcheck.ipa.meta:IPAMetaCheck not '
|
|
|
ed4527 |
- 'found.')
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- masters = output[0].get('kw').get('masters')
|
|
|
ed4527 |
- if masters:
|
|
|
26e6ce |
- return masters
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- raise ValueError('Unable to determine full list of masters. '
|
|
|
ed4527 |
- 'None of ipahealthcheck.ipa.meta:IPAMetaCheck '
|
|
|
ed4527 |
- 'contain masters.')
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-class ClusterPlugin(Plugin):
|
|
|
26e6ce |
- pass
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-class ClusterRegistry(Registry):
|
|
|
26e6ce |
- def __init__(self):
|
|
|
26e6ce |
- super().__init__()
|
|
|
26e6ce |
- self.json = None
|
|
|
26e6ce |
-
|
|
|
26e6ce |
- def initialize(self, framework, config, options=None):
|
|
|
26e6ce |
- super().initialize(framework, config, options)
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- self.json = {}
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- self.load_files(options.dir)
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- if not api.isdone('finalize'):
|
|
|
ed4527 |
- if not api.isdone('bootstrap'):
|
|
|
ed4527 |
- api.bootstrap(in_server=True,
|
|
|
ed4527 |
- context='ipahealthcheck',
|
|
|
ed4527 |
- log=None)
|
|
|
ed4527 |
- if not api.isdone('finalize'):
|
|
|
ed4527 |
- api.finalize()
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- def load_files(self, dir):
|
|
|
ed4527 |
- if self.json:
|
|
|
ed4527 |
- return
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- files = [f for f in listdir(dir) if isfile(join(dir, f))]
|
|
|
ed4527 |
- for file in files:
|
|
|
ed4527 |
- fname = join(dir, file)
|
|
|
ed4527 |
- logger.debug("Reading %s", fname)
|
|
|
ed4527 |
- try:
|
|
|
ed4527 |
- with open(fname, 'r') as fd:
|
|
|
ed4527 |
- data = fd.read()
|
|
|
ed4527 |
- except Exception as e:
|
|
|
ed4527 |
- logger.error("Unable to read %s: %s", fname, e)
|
|
|
ed4527 |
- continue
|
|
|
26e6ce |
-
|
|
|
ed4527 |
- try:
|
|
|
ed4527 |
- data = json.loads(data)
|
|
|
ed4527 |
- except Exception as e:
|
|
|
ed4527 |
- logger.error("Unable to parse JSON in %s: %s", fname, e)
|
|
|
ed4527 |
- continue
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- meta = find_checks(data, 'ipahealthcheck.meta.core',
|
|
|
ed4527 |
- 'MetaCheck')
|
|
|
ed4527 |
- if meta:
|
|
|
ed4527 |
- fqdn = meta[0].get('kw').get('fqdn')
|
|
|
ed4527 |
- self.json[fqdn] = deepcopy(data)
|
|
|
ed4527 |
- else:
|
|
|
ed4527 |
- logger.error("No fqdn defined in JSON in %s", fname)
|
|
|
ed4527 |
- continue
|
|
|
26e6ce |
-
|
|
|
26e6ce |
-
|
|
|
ed4527 |
-registry = ClusterRegistry()
|
|
|
ed4527 |
diff --git a/src/ipaclustercheck/ipa/ruv.py b/src/ipaclustercheck/ipa/ruv.py
|
|
|
ed4527 |
deleted file mode 100644
|
|
|
26e6ce |
index 6477738..0000000
|
|
|
ed4527 |
--- a/src/ipaclustercheck/ipa/ruv.py
|
|
|
ed4527 |
+++ /dev/null
|
|
|
26e6ce |
@@ -1,155 +0,0 @@
|
|
|
ed4527 |
-#
|
|
|
ed4527 |
-# Copyright (C) 2019 FreeIPA Contributors see COPYING for license
|
|
|
ed4527 |
-#
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-import logging
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-from ipaclustercheck.ipa.plugin import (
|
|
|
ed4527 |
- ClusterPlugin,
|
|
|
ed4527 |
- registry,
|
|
|
ed4527 |
- find_checks,
|
|
|
ed4527 |
- get_masters
|
|
|
ed4527 |
-)
|
|
|
ed4527 |
-from ipahealthcheck.core.plugin import Result, duration
|
|
|
ed4527 |
-from ipahealthcheck.core import constants
|
|
|
ed4527 |
-from ipalib import api
|
|
|
ed4527 |
-from ipapython.dn import DN
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-logger = logging.getLogger()
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-@registry
|
|
|
ed4527 |
-class ClusterRUVCheck(ClusterPlugin):
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- # TODO: confirm that all masters are represented, otherwise the
|
|
|
ed4527 |
- # trustworthiness of dangling RUV is mixed.
|
|
|
ed4527 |
- #
|
|
|
ed4527 |
- # gah, need to provide full list of all masters in a check.
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- @duration
|
|
|
ed4527 |
- def check(self):
|
|
|
ed4527 |
- data = self.registry.json
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- # Start with the list of masters from the file(s) collected
|
|
|
ed4527 |
- # and find a MetaCheck with a full list of masters. For
|
|
|
ed4527 |
- # backwards compatibility.
|
|
|
ed4527 |
- try:
|
|
|
ed4527 |
- masters = get_masters(data)
|
|
|
ed4527 |
- except ValueError as e:
|
|
|
ed4527 |
- yield Result(self, constants.ERROR,
|
|
|
ed4527 |
- name='dangling_ruv',
|
|
|
ed4527 |
- error=str(e))
|
|
|
ed4527 |
- return
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- if len(data.keys()) < len(masters):
|
|
|
ed4527 |
- yield Result(self, constants.ERROR,
|
|
|
ed4527 |
- name='dangling_ruv',
|
|
|
ed4527 |
- error='Unable to determine list of RUVs, missing '
|
|
|
ed4527 |
- 'some masters: %s' %
|
|
|
ed4527 |
- ''.join(set(masters) - set(data.keys())))
|
|
|
ed4527 |
- return
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- # collect the full set of known RUVs for each master
|
|
|
ed4527 |
- info = {}
|
|
|
ed4527 |
- for master in masters:
|
|
|
ed4527 |
- info[master] = {
|
|
|
ed4527 |
- 'ca': False, # does the host have ca configured?
|
|
|
ed4527 |
- 'ruvs': set(), # ruvs on the host
|
|
|
ed4527 |
- 'csruvs': set(), # csruvs on the host
|
|
|
ed4527 |
- 'clean_ruv': set(), # ruvs to be cleaned from the host
|
|
|
ed4527 |
- 'clean_csruv': set() # csruvs to be cleaned from the host
|
|
|
ed4527 |
- }
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- for fqdn in data.keys():
|
|
|
ed4527 |
- outputs = find_checks(data[fqdn], 'ipahealthcheck.ds.ruv',
|
|
|
ed4527 |
- 'KnownRUVCheck')
|
|
|
ed4527 |
- for output in outputs:
|
|
|
ed4527 |
- if not 'suffix' in output.get('kw'):
|
|
|
ed4527 |
- continue
|
|
|
ed4527 |
- basedn = DN(output.get('kw').get('suffix'))
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- ruvset = set()
|
|
|
ed4527 |
- ruvtmp = output.get('kw').get('ruvs')
|
|
|
ed4527 |
- for ruv in ruvtmp:
|
|
|
ed4527 |
- ruvset.add(tuple(ruv))
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- if basedn == DN('o=ipaca'):
|
|
|
ed4527 |
- info[fqdn]['ca'] = True
|
|
|
ed4527 |
- info[fqdn]['csruvs'] = ruvset
|
|
|
ed4527 |
- elif basedn == api.env.basedn:
|
|
|
ed4527 |
- info[fqdn]['ruvs'] = ruvset
|
|
|
ed4527 |
- else:
|
|
|
ed4527 |
- yield Result(self, constants.WARNING,
|
|
|
ed4527 |
- name='dangling_ruv',
|
|
|
ed4527 |
- error='Unknown suffix found %s expected %s'
|
|
|
ed4527 |
- % (basedn, api.env.basedn))
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- # Collect the nsDS5ReplicaID for each master
|
|
|
ed4527 |
- ruvs = set()
|
|
|
ed4527 |
- csruvs = set()
|
|
|
ed4527 |
- for fqdn in data.keys():
|
|
|
ed4527 |
- outputs = find_checks(data[fqdn], 'ipahealthcheck.ds.ruv',
|
|
|
ed4527 |
- 'RUVCheck')
|
|
|
ed4527 |
- for output in outputs:
|
|
|
ed4527 |
- if not 'key' in output.get('kw'):
|
|
|
ed4527 |
- continue
|
|
|
ed4527 |
- basedn = DN(output.get('kw').get('key'))
|
|
|
ed4527 |
- ruv = (fqdn, (output.get('kw').get('ruv')))
|
|
|
ed4527 |
- if basedn == DN('o=ipaca'):
|
|
|
ed4527 |
- csruvs.add(ruv)
|
|
|
ed4527 |
- elif basedn == api.env.basedn:
|
|
|
ed4527 |
- ruvs.add(ruv)
|
|
|
ed4527 |
- else:
|
|
|
ed4527 |
- yield Result(self, constants.WARNING,
|
|
|
ed4527 |
- name='dangling_ruv',
|
|
|
ed4527 |
- error='Unknown suffix found %s expected %s'
|
|
|
ed4527 |
- % (basedn, api.env.basedn))
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- dangles = False
|
|
|
ed4527 |
- # get the dangling RUVs
|
|
|
ed4527 |
- for master_info in info.values():
|
|
|
ed4527 |
- for ruv in master_info['ruvs']:
|
|
|
ed4527 |
- if ruv not in ruvs:
|
|
|
ed4527 |
- master_info['clean_ruv'].add(ruv)
|
|
|
ed4527 |
- dangles = True
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- # if ca is not configured, there will be no csruvs in master_info
|
|
|
ed4527 |
- for csruv in master_info['csruvs']:
|
|
|
ed4527 |
- if csruv not in csruvs:
|
|
|
ed4527 |
- master_info['clean_csruv'].add(csruv)
|
|
|
ed4527 |
- dangles = True
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- clean_csruvs = set()
|
|
|
ed4527 |
- clean_ruvs = set()
|
|
|
ed4527 |
- if dangles:
|
|
|
26e6ce |
- for _unused, master_info in info.items():
|
|
|
ed4527 |
- for ruv in master_info['clean_ruv']:
|
|
|
26e6ce |
- logger.debug(
|
|
|
26e6ce |
- "Dangling RUV id: %s, hostname: %s", ruv[1], ruv[0]
|
|
|
26e6ce |
- )
|
|
|
ed4527 |
- clean_ruvs.add(ruv[1])
|
|
|
ed4527 |
- for csruv in master_info['clean_csruv']:
|
|
|
26e6ce |
- logger.debug(
|
|
|
26e6ce |
- "Dangling CS RUV id: %s, hostname: %s",
|
|
|
26e6ce |
- csruv[1],
|
|
|
26e6ce |
- csruv[0]
|
|
|
26e6ce |
- )
|
|
|
ed4527 |
- clean_csruvs.add(csruv[1])
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- if clean_ruvs:
|
|
|
ed4527 |
- yield Result(self, constants.ERROR,
|
|
|
ed4527 |
- name='dangling_ruv',
|
|
|
ed4527 |
- value=', '.join(clean_ruvs))
|
|
|
ed4527 |
- else:
|
|
|
ed4527 |
- yield Result(self, constants.SUCCESS,
|
|
|
ed4527 |
- name='dangling_ruv',
|
|
|
ed4527 |
- value='No dangling RUVs found')
|
|
|
ed4527 |
- if clean_csruvs:
|
|
|
ed4527 |
- yield Result(self, constants.ERROR,
|
|
|
ed4527 |
- name='dangling_csruv',
|
|
|
ed4527 |
- value=', '.join(clean_csruvs))
|
|
|
ed4527 |
- else:
|
|
|
ed4527 |
- yield Result(self, constants.SUCCESS,
|
|
|
ed4527 |
- name='dangling_csruv',
|
|
|
ed4527 |
- value='No dangling CS RUVs found')
|
|
|
ed4527 |
diff --git a/tests/test_cluster_ruv.py b/tests/test_cluster_ruv.py
|
|
|
ed4527 |
deleted file mode 100644
|
|
|
ed4527 |
index 7583c84..0000000
|
|
|
ed4527 |
--- a/tests/test_cluster_ruv.py
|
|
|
ed4527 |
+++ /dev/null
|
|
|
ed4527 |
@@ -1,106 +0,0 @@
|
|
|
ed4527 |
-#
|
|
|
ed4527 |
-# Copyright (C) 2019 FreeIPA Contributors see COPYING for license
|
|
|
ed4527 |
-#
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-from base import BaseTest
|
|
|
ed4527 |
-from util import capture_results
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-from ipahealthcheck.core import config
|
|
|
ed4527 |
-from ipaclustercheck.ipa.plugin import ClusterRegistry
|
|
|
ed4527 |
-from ipaclustercheck.ipa.ruv import ClusterRUVCheck
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-import clusterdata
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-class RUVRegistry(ClusterRegistry):
|
|
|
ed4527 |
- def load_files(self, dir):
|
|
|
ed4527 |
- self.json = dir
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-class Options:
|
|
|
ed4527 |
- def __init__(self, data):
|
|
|
ed4527 |
- self.data = data
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- @property
|
|
|
ed4527 |
- def dir(self):
|
|
|
ed4527 |
- return self.data
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-registry = RUVRegistry()
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-
|
|
|
ed4527 |
-class TestClusterRUV(BaseTest):
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- def test_no_ruvs(self):
|
|
|
ed4527 |
- """Single master test that has never created a replica
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- This type of master will have no RUVs created at all.
|
|
|
ed4527 |
- """
|
|
|
ed4527 |
- framework = object()
|
|
|
ed4527 |
- registry.initialize(framework, config.Config,
|
|
|
ed4527 |
- Options(clusterdata.ONE_MASTER))
|
|
|
ed4527 |
- f = ClusterRUVCheck(registry)
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- self.results = capture_results(f)
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- assert len(self.results) == 2
|
|
|
ed4527 |
- result = self.results.results[0]
|
|
|
ed4527 |
- assert result.kw.get('name') == 'dangling_ruv'
|
|
|
ed4527 |
- assert result.kw.get('value') == 'No dangling RUVs found'
|
|
|
ed4527 |
- result = self.results.results[1]
|
|
|
ed4527 |
- assert result.kw.get('name') == 'dangling_csruv'
|
|
|
ed4527 |
- assert result.kw.get('value') == 'No dangling CS RUVs found'
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- def test_six_ruvs_ok(self):
|
|
|
ed4527 |
- """Three master test with each having a CA, no dangling
|
|
|
ed4527 |
- """
|
|
|
ed4527 |
- framework = object()
|
|
|
ed4527 |
- registry.initialize(framework, config.Config,
|
|
|
ed4527 |
- Options(clusterdata.THREE_MASTERS_OK))
|
|
|
ed4527 |
- f = ClusterRUVCheck(registry)
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- self.results = capture_results(f)
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- assert len(self.results) == 2
|
|
|
ed4527 |
- result = self.results.results[0]
|
|
|
ed4527 |
- assert result.kw.get('name') == 'dangling_ruv'
|
|
|
ed4527 |
- assert result.kw.get('value') == 'No dangling RUVs found'
|
|
|
ed4527 |
- result = self.results.results[1]
|
|
|
ed4527 |
- assert result.kw.get('name') == 'dangling_csruv'
|
|
|
ed4527 |
- assert result.kw.get('value') == 'No dangling CS RUVs found'
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- def test_six_ruvs_ipa_bad(self):
|
|
|
ed4527 |
- """Three master test with each having a CA, dangling IPA RUV
|
|
|
ed4527 |
- """
|
|
|
ed4527 |
- framework = object()
|
|
|
ed4527 |
- registry.initialize(framework, config.Config,
|
|
|
ed4527 |
- Options(clusterdata.THREE_MASTERS_BAD_IPA_RUV))
|
|
|
ed4527 |
- f = ClusterRUVCheck(registry)
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- self.results = capture_results(f)
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- assert len(self.results) == 2
|
|
|
ed4527 |
- result = self.results.results[0]
|
|
|
ed4527 |
- assert result.kw.get('name') == 'dangling_ruv'
|
|
|
ed4527 |
- assert result.kw.get('value') == '9'
|
|
|
ed4527 |
- result = self.results.results[1]
|
|
|
ed4527 |
- assert result.kw.get('name') == 'dangling_csruv'
|
|
|
ed4527 |
- assert result.kw.get('value') == 'No dangling CS RUVs found'
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- def test_six_ruvs_cs_bad(self):
|
|
|
ed4527 |
- """Three master test with each having a CA, dangling CA RUV
|
|
|
ed4527 |
- """
|
|
|
ed4527 |
- framework = object()
|
|
|
ed4527 |
- registry.initialize(framework, config.Config,
|
|
|
ed4527 |
- Options(clusterdata.THREE_MASTERS_BAD_CS_RUV))
|
|
|
ed4527 |
- f = ClusterRUVCheck(registry)
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- self.results = capture_results(f)
|
|
|
ed4527 |
-
|
|
|
ed4527 |
- assert len(self.results) == 2
|
|
|
ed4527 |
- result = self.results.results[0]
|
|
|
ed4527 |
- assert result.kw.get('name') == 'dangling_ruv'
|
|
|
ed4527 |
- assert result.kw.get('value') == 'No dangling RUVs found'
|
|
|
ed4527 |
- result = self.results.results[1]
|
|
|
ed4527 |
- assert result.kw.get('name') == 'dangling_csruv'
|
|
|
ed4527 |
- assert result.kw.get('value') == '9'
|
|
|
ed4527 |
--
|
|
|
26e6ce |
2.38.1
|
|
|
ed4527 |
|