From 4aa1ca8221e660b21d8afcc6c5acebf48d51d628 Mon Sep 17 00:00:00 2001 From: Tomas Jelinek Date: Mon, 14 Jun 2021 11:39:14 +0200 Subject: [PATCH 2/3] remove clufter commands --- .gitlab-ci.yml | 1 - CHANGELOG.md | 13 + Makefile.am | 4 +- README.md | 2 - configure.ac | 5 - mypy.ini | 6 - pcs/cli/common/parse_args.py | 4 - pcs/cli/routing/config.py | 14 - pcs/config.py | 377 ------------------- pcs/pcs.8.in | 2 - pcs/settings.py.in | 3 - pcs_test/Makefile.am | 1 - pcs_test/resources/cluster.conf | 27 -- pcs_test/tier0/cli/common/test_parse_args.py | 2 - pcsd/Makefile.am | 1 - pcsd/test/cluster.conf | 27 -- rpm/pcs.spec.in | 15 - 17 files changed, 14 insertions(+), 490 deletions(-) delete mode 100644 pcs_test/resources/cluster.conf delete mode 100644 pcsd/test/cluster.conf diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8a36b509..6602ea46 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,7 +5,6 @@ variables: python3-cryptography python3-dateutil python3-devel - python3-distro python3-lxml python3-pip python3-pycurl diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a7f4315..75d148a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Change Log +## [0.11.0] + +### Changed +- Pcs no longer depends on python3-distro package + +### Removed +- Deprecated obsolete commands `pcs config import-cman` and `pcs config export + pcs-commands|pcs-commands-verbose` have been removed ([rhbz#1881064]) + +[rhbz#1881064]: https://bugzilla.redhat.com/show_bug.cgi?id=1881064 + + ## [Unreleased] ### Added @@ -29,6 +41,7 @@ [rhbz#1927404]: https://bugzilla.redhat.com/show_bug.cgi?id=1927404 [rhbz#1930886]: https://bugzilla.redhat.com/show_bug.cgi?id=1930886 + ## [0.10.8] - 2021-02-01 ### Added diff --git a/Makefile.am b/Makefile.am index 6a7cc553..cba77d8d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -369,12 +369,10 @@ $(SPEC): $(SPEC).in .version config.status stamps/download_python_deps stamps/do pylist="`ls rpm/*.tar.gz | grep -v ^rpm/pyagentx- | grep -v ^rpm/pcs- | sed -e 's#rpm/##g' -e 's#.tar.gz##'`" && \ pysrc="`base=42; for i in $$pylist; do echo 'Source'$$base': '$$i'.tar.gz' && let "base=base+1"; done`" && \ $(AWK) -i inplace -v r="$$pysrc" '{gsub(/@pysrc@/,r)}1' $@-t; \ - pybundle="`for i in $$pylist; do echo $$i | grep -v ^distro- | grep -v ^dataclasses- | sed 's/\(.*\)-\(.*\)/Provides: bundled(\1) = \2/'; done`" && \ + pybundle="`for i in $$pylist; do echo $$i | grep -v ^dataclasses- | sed 's/\(.*\)-\(.*\)/Provides: bundled(\1) = \2/'; done`" && \ $(AWK) -i inplace -v r="$$pybundle" '{gsub(/@pybundle@/,r)}1' $@-t; \ pydataclassesbundle="`for i in $$pylist; do echo $$i | grep ^dataclasses- | sed 's/\(.*\)-\(.*\)/Provides: bundled(\1) = \2/'; done`" && \ $(AWK) -i inplace -v r="$$pydataclassesbundle" '{gsub(/@pydataclassesbundle@/,r)}1' $@-t; \ - pydistrobundle="`for i in $$pylist; do echo $$i | grep ^distro- | sed 's/\(.*\)-\(.*\)/Provides: bundled(\1) = \2/'; done`" && \ - $(AWK) -i inplace -v r="$$pydistrobundle" '{gsub(/@pydistrobundle@/,r)}1' $@-t; \ pycache="`echo $(MKDIR_P) $(PCS_BUNDLED_DIR_LOCAL)/src; base=41; for i in $$pylist pyagentx; do echo 'cp -f %SOURCE'$$base' rpm/' && let "base=base+1"; done`" && \ $(AWK) -i inplace -v r="$$pycache" '{gsub(/@pycache@/,r)}1' $@-t; \ gemlist="`for i in $$($(FIND) rpm/ -type f -name '*.gem'); do echo $$i | sed -e 's#rpm/##g' -e 's#.gem##g'; done`" && \ diff --git a/README.md b/README.md index efca6deb..85ab1099 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,6 @@ These are the runtime dependencies of pcs and pcsd: * python 3.6+ * python3-cryptography * python3-dateutil 2.7.0+ -* python3-distro (for python 3.8+) * python3-lxml * python3-pycurl * python3-setuptools @@ -41,7 +40,6 @@ These are the runtime dependencies of pcs and pcsd: * pacemaker 2.x It is also recommended to have these: -* python3-clufter * liberation fonts (package liberation-sans-fonts or fonts-liberation or fonts-liberation2) * overpass fonts (package overpass-fonts) diff --git a/configure.ac b/configure.ac index 39ce5f36..60605c08 100644 --- a/configure.ac +++ b/configure.ac @@ -304,11 +304,6 @@ if test "$PYTHON_VERSION" = "3.6"; then PCS_CHECK_PYMOD([dataclasses], [], [yes]) fi -# python 3.8+ needs distro as well (removed from upstream lib) -if printf '%s\n%s\n' "3.8" "$PYTHON_VERSION" | sort -V -C; then - PCS_CHECK_PYMOD([distro], [], [yes]) -fi - # special case, because we need to download from github AC_PIP_MODULE([pyagentx]) diff --git a/mypy.ini b/mypy.ini index 33d1e469..f3246735 100644 --- a/mypy.ini +++ b/mypy.ini @@ -123,15 +123,9 @@ ignore_errors = True # External libraries -[mypy-clufter.*] -ignore_missing_imports = True - [mypy-dacite] ignore_missing_imports = True -[mypy-distro] -ignore_missing_imports = True - [mypy-pyagentx] ignore_errors = True ignore_missing_imports = True diff --git a/pcs/cli/common/parse_args.py b/pcs/cli/common/parse_args.py index e3c829c7..767fdf7f 100644 --- a/pcs/cli/common/parse_args.py +++ b/pcs/cli/common/parse_args.py @@ -27,8 +27,6 @@ PCS_LONG_OPTIONS = [ "fullhelp", "force", "skip-offline", - # TODO remove, deprecated command 'pcs config import-cman' - "interactive", "autodelete", "simulate", "all", @@ -464,8 +462,6 @@ class InputModifiers: # used only in deprecated 'pcs resource|stonith show' "--groups": "--groups" in options, "--hide-inactive": "--hide-inactive" in options, - # TODO remove, deprecated command 'pcs config import-cman' - "--interactive": "--interactive" in options, "--local": "--local" in options, "--master": "--master" in options, "--monitor": "--monitor" in options, diff --git a/pcs/cli/routing/config.py b/pcs/cli/routing/config.py index 5d2663bd..7f878f4d 100644 --- a/pcs/cli/routing/config.py +++ b/pcs/cli/routing/config.py @@ -21,20 +21,6 @@ config_cmd = create_router( ["config", "checkpoint"], default_cmd="list", ), - # TODO remove, deprecated command - "import-cman": config.config_import_cman, - # TODO remove, deprecated command - "export": create_router( - { - "pcs-commands": config.config_export_pcs_commands, - "pcs-commands-verbose": lambda lib, argv, modifiers: ( - config.config_export_pcs_commands( - lib, argv, modifiers, verbose=True - ) - ), - }, - ["config", "export"], - ), }, ["config"], default_cmd="show", diff --git a/pcs/config.py b/pcs/config.py index 8e37fc4b..521af8fd 100644 --- a/pcs/config.py +++ b/pcs/config.py @@ -7,7 +7,6 @@ from io import BytesIO import tarfile import json from xml.dom.minidom import parse -import logging import pwd import grp import tempfile @@ -15,25 +14,6 @@ import time import shutil import difflib -try: - import distro - - no_distro_package = False -except ImportError: - no_distro_package = True - import platform - -# TODO remove, deprecated -try: - import clufter.facts - import clufter.format_manager - import clufter.filter_manager - import clufter.command_manager - - no_clufter = False -except ImportError: - no_clufter = True - from pcs import ( cluster, constraint, @@ -51,7 +31,6 @@ from pcs.cli.common.errors import CmdLineInputError from pcs.cli.constraint import command as constraint_command from pcs.cli.nvset import nvset_dto_list_to_lines from pcs.cli.reports import process_library_reports -from pcs.cli.reports.output import warn from pcs.common.reports import constraints as constraints_reports from pcs.common.str_tools import indent from pcs.lib.commands import quorum as lib_quorum @@ -807,359 +786,3 @@ def config_checkpoint_restore(lib, argv, modifiers): except Exception as e: utils.err("unable to read the checkpoint: %s" % e) utils.replace_cib_configuration(snapshot_dom) - - -# TODO remove, deprecated command -def config_import_cman(lib, argv, modifiers): - """ - Options: - * --force - skip checks, overwrite files - * --interactive - interactive issue resolving - * --request-timeout - effective only when ouput is not specified - """ - # pylint: disable=no-member - del lib - warn("This command is deprecated and will be removed.") - modifiers.ensure_only_supported( - "--force", - "interactive", - "--request-timeout", - ) - if no_clufter: - utils.err( - "Unable to perform a CMAN cluster conversion due to missing " - "python-clufter package" - ) - clufter_supports_corosync3 = hasattr(clufter.facts, "cluster_pcs_camelback") - - # prepare convertor options - cluster_conf = settings.cluster_conf_file - dry_run_output = None - output_format = "corosync.conf" - dist = None - invalid_args = False - for arg in argv: - if "=" in arg: - name, value = arg.split("=", 1) - if name == "input": - cluster_conf = value - elif name == "output": - dry_run_output = value - elif name == "output-format": - if value in ( - "corosync.conf", - "pcs-commands", - "pcs-commands-verbose", - ): - output_format = value - else: - invalid_args = True - elif name == "dist": - dist = value - else: - invalid_args = True - else: - invalid_args = True - if output_format not in ("pcs-commands", "pcs-commands-verbose") and ( - dry_run_output and not dry_run_output.endswith(".tar.bz2") - ): - dry_run_output += ".tar.bz2" - if invalid_args or not dry_run_output: - usage.config(["import-cman"]) - sys.exit(1) - debug = modifiers.get("--debug") - force = modifiers.get("--force") - interactive = modifiers.get("--interactive") - - if dist is not None: - if not clufter_supports_corosync3: - utils.err( - "Unable to perform a CMAN cluster conversion due to clufter " - "not supporting Corosync 3. Please, upgrade clufter packages." - ) - if not clufter.facts.cluster_pcs_camelback("linux", dist.split(",")): - utils.err("dist does not match output-format") - elif output_format == "corosync.conf": - dist = _get_linux_dist() - else: - # for output-format=pcs-command[-verbose] - dist = _get_linux_dist() - - clufter_args = { - "input": str(cluster_conf), - "cib": {"passin": "bytestring"}, - "nocheck": force, - "batch": True, - "sys": "linux", - "dist": dist, - } - if interactive: - if "EDITOR" not in os.environ: - utils.err("$EDITOR environment variable is not set") - clufter_args["batch"] = False - clufter_args["editor"] = os.environ["EDITOR"] - if debug: - logging.getLogger("clufter").setLevel(logging.DEBUG) - if output_format == "corosync.conf": - clufter_args["coro"] = {"passin": "struct"} - cmd_name = "ccs2pcs-camelback" - elif output_format in ("pcs-commands", "pcs-commands-verbose"): - clufter_args["output"] = {"passin": "bytestring"} - clufter_args["start_wait"] = "60" - clufter_args["tmp_cib"] = "tmp-cib.xml" - clufter_args["force"] = force - clufter_args["text_width"] = "80" - clufter_args["silent"] = True - clufter_args["noguidance"] = True - if output_format == "pcs-commands-verbose": - clufter_args["text_width"] = "-1" - clufter_args["silent"] = False - clufter_args["noguidance"] = False - if clufter.facts.cluster_pcs_flatiron("linux", dist.split(",")): - cmd_name = "ccs2pcscmd-flatiron" - elif clufter.facts.cluster_pcs_needle("linux", dist.split(",")): - cmd_name = "ccs2pcscmd-needle" - elif clufter_supports_corosync3 and clufter.facts.cluster_pcs_camelback( - "linux", dist.split(",") - ): - cmd_name = "ccs2pcscmd-camelback" - else: - utils.err( - "unrecognized dist, try something recognized" - + " (e. g. rhel,6.8 or redhat,7.3 or debian,7 or ubuntu,trusty)" - ) - clufter_args_obj = type(str("ClufterOptions"), (object,), clufter_args) - - # run convertor - run_clufter( - cmd_name, - clufter_args_obj, - debug, - force, - "Error: unable to import cluster configuration", - ) - - # save commands - if output_format in ("pcs-commands", "pcs-commands-verbose"): - ok, message = utils.write_file( - dry_run_output, clufter_args_obj.output["passout"].decode() - ) - if not ok: - utils.err(message) - return - - # put new config files into tarball - file_list = config_backup_path_list() - for file_item in file_list.values(): - file_item["attrs"]["uname"] = "root" - file_item["attrs"]["gname"] = "root" - file_item["attrs"]["uid"] = 0 - file_item["attrs"]["gid"] = 0 - file_item["attrs"]["mode"] = 0o600 - tar_data = BytesIO() - try: - with tarfile.open(fileobj=tar_data, mode="w|bz2") as tarball: - config_backup_add_version_to_tarball(tarball) - utils.tar_add_file_data( - tarball, - clufter_args_obj.cib["passout"], - "cib.xml", - **file_list["cib.xml"]["attrs"], - ) - # put uidgid into separate files - fmt_simpleconfig = clufter.format_manager.FormatManager.init_lookup( - "simpleconfig" - ).plugins["simpleconfig"] - corosync_struct = [] - uidgid_list = [] - for section in clufter_args_obj.coro["passout"][2]: - if section[0] == "uidgid": - uidgid_list.append(section[1]) - else: - corosync_struct.append(section) - corosync_conf_data = fmt_simpleconfig( - "struct", ("corosync", (), corosync_struct) - )("bytestring") - utils.tar_add_file_data( - tarball, - corosync_conf_data, - "corosync.conf", - **file_list["corosync.conf"]["attrs"], - ) - for uidgid in uidgid_list: - uid = "" - gid = "" - for item in uidgid: - if item[0] == "uid": - uid = item[1] - if item[0] == "gid": - gid = item[1] - filename = utils.get_uid_gid_file_name(uid, gid) - uidgid_data = fmt_simpleconfig( - "struct", ("corosync", (), [("uidgid", uidgid, None)]) - )("bytestring") - utils.tar_add_file_data( - tarball, - uidgid_data, - "uidgid.d/" + filename, - **file_list["uidgid.d"]["attrs"], - ) - except (tarfile.TarError, EnvironmentError) as e: - utils.err("unable to create tarball: %s" % e) - tar_data.seek(0) - - # save tarball / remote restore - if dry_run_output: - ok, message = utils.write_file( - dry_run_output, tar_data.read(), permissions=0o600, binary=True - ) - if not ok: - utils.err(message) - else: - config_restore_remote(None, tar_data) - tar_data.close() - - -def _get_linux_dist(): - if no_distro_package: - # For Python 3.8+, python3-distro is a required dependency and we - # should never get here. Pylint, of course, cannot know that. - # pylint: disable=deprecated-method - # pylint: disable=no-member - distribution = platform.linux_distribution(full_distribution_name=False) - else: - distribution = distro.linux_distribution(full_distribution_name=False) - return ",".join(distribution) - - -# TODO remove, deprecated command -def config_export_pcs_commands(lib, argv, modifiers, verbose=False): - """ - Options: - * --force - skip checks, overwrite files - * --interactive - interactive issue resolving - * -f - CIB file - * --corosync_conf - """ - del lib - warn("This command is deprecated and will be removed.") - modifiers.ensure_only_supported( - "--force", "--interactive", "-f", "--corosync_conf" - ) - if no_clufter: - utils.err( - "Unable to perform export due to missing python-clufter package" - ) - - # parse options - debug = modifiers.get("--debug") - force = modifiers.get("--force") - interactive = modifiers.get("--interactive") - invalid_args = False - output_file = None - dist = None - for arg in argv: - if "=" in arg: - name, value = arg.split("=", 1) - if name == "output": - output_file = value - elif name == "dist": - dist = value - else: - invalid_args = True - else: - invalid_args = True - # check options - if invalid_args: - usage.config(["export pcs-commands"]) - sys.exit(1) - # complete optional options - if dist is None: - dist = _get_linux_dist() - - # prepare convertor options - clufter_args = { - "nocheck": force, - "batch": True, - "sys": "linux", - "dist": dist, - "coro": settings.corosync_conf_file, - "start_wait": "60", - "tmp_cib": "tmp-cib.xml", - "force": force, - "text_width": "80", - "silent": True, - "noguidance": True, - } - if output_file: - clufter_args["output"] = {"passin": "bytestring"} - else: - clufter_args["output"] = "-" - if interactive: - if "EDITOR" not in os.environ: - utils.err("$EDITOR environment variable is not set") - clufter_args["batch"] = False - clufter_args["editor"] = os.environ["EDITOR"] - if debug: - logging.getLogger("clufter").setLevel(logging.DEBUG) - if utils.usefile: - clufter_args["cib"] = os.path.abspath(utils.filename) - else: - clufter_args["cib"] = ("bytestring", utils.get_cib()) - if verbose: - clufter_args["text_width"] = "-1" - clufter_args["silent"] = False - clufter_args["noguidance"] = False - clufter_args_obj = type(str("ClufterOptions"), (object,), clufter_args) - cmd_name = "pcs2pcscmd-camelback" - - # run convertor - run_clufter( - cmd_name, - clufter_args_obj, - debug, - force, - "Error: unable to export cluster configuration", - ) - - # save commands if not printed to stdout by clufter - if output_file: - # pylint: disable=no-member - ok, message = utils.write_file( - output_file, clufter_args_obj.output["passout"].decode() - ) - if not ok: - utils.err(message) - - -# TODO remove, deprecated -def run_clufter(cmd_name, cmd_args, debug, force, err_prefix): - """ - Commandline options: no options used but messages which include --force, - --debug and --interactive are generated - """ - # pylint: disable=broad-except - try: - result = None - cmd_manager = clufter.command_manager.CommandManager.init_lookup( - cmd_name - ) - result = cmd_manager.commands[cmd_name](cmd_args) - error_message = "" - except Exception as e: - error_message = str(e) - if error_message or result != 0: - hints = [] - hints.append("--interactive to solve the issues manually") - if not debug: - hints.append("--debug to get more information") - if not force: - hints.append("--force to override") - hints_string = "\nTry using %s." % ", ".join(hints) if hints else "" - sys.stderr.write( - err_prefix - + (": %s" % error_message if error_message else "") - + hints_string - + "\n" - ) - sys.exit(1 if result is None else result) diff --git a/pcs/pcs.8.in b/pcs/pcs.8.in index 205fdc4e..b72c2197 100644 --- a/pcs/pcs.8.in +++ b/pcs/pcs.8.in @@ -1382,5 +1382,3 @@ http://clusterlabs.org/doc/ .BR boothd (8), .BR sbd (8) - -.BR clufter (1) diff --git a/pcs/settings.py.in b/pcs/settings.py.in index 6df12997..68b18a53 100644 --- a/pcs/settings.py.in +++ b/pcs/settings.py.in @@ -31,9 +31,6 @@ pcsd_token_max_bytes = 256 booth_authkey_file_mode = 0o600 # Booth does not support keys longer than 64 bytes. booth_authkey_bytes = 64 -# cluster conf is obsoleted and didn't support out-of-tree installation / run -# hence it can stay hardcoded -cluster_conf_file = "/etc/cluster/cluster.conf" fence_agent_binaries = "@FASEXECPREFIX@/sbin" pacemaker_local_state_dir = os.path.join( "/", "@PCMKLOCALSTATEDIR@", "lib/pacemaker" diff --git a/pcs_test/Makefile.am b/pcs_test/Makefile.am index 7cd077f3..b73eb40c 100644 --- a/pcs_test/Makefile.am +++ b/pcs_test/Makefile.am @@ -23,7 +23,6 @@ EXTRA_DIST = \ resources/cib-largefile.xml \ resources/cib-large.xml \ resources/cib-tags.xml \ - resources/cluster.conf \ resources/corosync-3nodes.conf \ resources/corosync-3nodes-qdevice.conf \ resources/corosync-3nodes-qdevice-heuristics.conf \ diff --git a/pcs_test/resources/cluster.conf b/pcs_test/resources/cluster.conf deleted file mode 100644 index 19889712..00000000 --- a/pcs_test/resources/cluster.conf +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pcs_test/tier0/cli/common/test_parse_args.py b/pcs_test/tier0/cli/common/test_parse_args.py index 493461bd..2739a9d3 100644 --- a/pcs_test/tier0/cli/common/test_parse_args.py +++ b/pcs_test/tier0/cli/common/test_parse_args.py @@ -603,8 +603,6 @@ class InputModifiersTest(TestCase): # used only in deprecated 'pcs resource|stonith show' "--groups", "--hide-inactive", - # TODO remove, deprecated command 'pcs config import-cman' - "--interactive", "--local", "--master", "--monitor", diff --git a/pcsd/Makefile.am b/pcsd/Makefile.am index 007d2194..0cd2e90d 100644 --- a/pcsd/Makefile.am +++ b/pcsd/Makefile.am @@ -2,7 +2,6 @@ EXTRA_DIST = \ pam/pcsd.debian \ pam/pcsd.fedora \ test/cib1.xml \ - test/cluster.conf \ test/corosync.conf \ test/crm1.xml \ test/crm2.xml \ diff --git a/pcsd/test/cluster.conf b/pcsd/test/cluster.conf deleted file mode 100644 index 19889712..00000000 --- a/pcsd/test/cluster.conf +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/rpm/pcs.spec.in b/rpm/pcs.spec.in index 918986e0..f421bc53 100644 --- a/rpm/pcs.spec.in +++ b/rpm/pcs.spec.in @@ -36,10 +36,6 @@ Summary: Pacemaker Configuration System %define dataclasses_required 1 %endif -%if "%{python3_version}" >= "3.8" -%define distro_required 1 -%endif - # mangling shebang in /usr/lib/pcsd/vendor/bundle/ruby/gems/rack-2.0.5/test/cgi/test from /usr/bin/env ruby to #!/usr/bin/ruby #*** ERROR: ./usr/lib/pcsd/vendor/bundle/ruby/gems/rack-2.0.5/test/cgi/test.ru has shebang which doesn't start with '/' (../../bin/rackup) #mangling shebang in /usr/lib/pcsd/vendor/bundle/ruby/gems/rack-2.0.5/test/cgi/rackup_stub.rb from /usr/bin/env ruby to #!/usr/bin/ruby @@ -105,14 +101,6 @@ Requires: python3-cryptography Requires: python3-lxml Requires: python3-pycurl Requires: python3-pyparsing -%if 0%{?fedora} <= 32 -# clufter and its dependencies -Requires: python3-clufter => 0.70.0 -%endif -%if 0%{?rhel} < 9 -# clufter and its dependencies -Requires: python3-clufter => 0.70.0 -%endif # ruby and gems for pcsd Requires: ruby >= 2.2.0 Requires: rubygems @@ -140,9 +128,6 @@ Recommends: overpass-fonts %if %{defined dataclasses_required} @pydataclassesbundle@ %endif -%if %{defined distro_required} -@pydistrobundle@ -%endif @gembundle@ -- 2.31.1