From 8d9f0b7577e1b4f94089c3917ec29beaff782f11 Mon Sep 17 00:00:00 2001 From: Katerina Koukiou Date: Wed, 21 Aug 2024 09:20:36 +0200 Subject: [PATCH] pyanaconda: remove code paths around module command parsing as this was deprecated Remove also the related tests as these are no longer relevant. Also bump the pykickstart required version which marks 'module' as Deprecated. --- anaconda.spec.in | 2 +- pyanaconda/modules/payloads/kickstart.py | 37 ---------------- .../payloads/payload/dnf/dnf_manager.py | 38 ---------------- .../payloads/payload/dnf/validation.py | 6 --- .../payload/test_module_payload_dnf.py | 19 -------- .../test_module_payload_dnf_installation.py | 3 -- .../test_module_payload_dnf_manager.py | 44 ------------------- .../modules/payloads/test_module_payloads.py | 1 - 8 files changed, 1 insertion(+), 149 deletions(-) diff --git a/anaconda.spec.in b/anaconda.spec.in index 7f2d1f5d8d1c..709ab7fcc23f 100644 --- a/anaconda.spec.in +++ b/anaconda.spec.in @@ -38,7 +38,7 @@ Source0: https://github.com/rhinstaller/%{name}/releases/download/%{name}-%{vers %define libxklavierver 5.4 %define mehver 0.23-1 %define nmver 1.0 -%define pykickstartver 3.52-1 +%define pykickstartver 3.58-1 %define pypartedver 2.5-2 %define pythonblivetver 1:3.9.0-1 %define rpmver 4.15.0 diff --git a/pyanaconda/modules/payloads/kickstart.py b/pyanaconda/modules/payloads/kickstart.py index 70617e7656c7..5771547bfaf3 100644 --- a/pyanaconda/modules/payloads/kickstart.py +++ b/pyanaconda/modules/payloads/kickstart.py @@ -193,17 +193,6 @@ def convert_ks_data_to_packages_selection(ks_data): for group in ks_data.packages.excludedGroupList: selection.excluded_groups.append(group.name) - for module in ks_data.module.dataList(): - name = module.name - - if module.stream: - name += ":" + module.stream - - if module.enable: - selection.modules.append(name) - else: - selection.disabled_modules.append(name) - return selection @@ -248,30 +237,6 @@ def convert_packages_selection_to_ksdata(selection, ks_data): ) ks_data.packages.excludedGroupList.append(ks_group) - for name in selection.modules: - ks_module = create_ks_module(name) - ks_data.module.dataList().append(ks_module) - - for name in selection.disabled_modules: - ks_module = create_ks_module(name, enabled=False) - ks_data.module.dataList().append(ks_module) - - -def create_ks_module(name, enabled=True): - """Create a new instance of a kickstart module. - - :param name: a name of the module - :param enabled: True if the module is enabled, otherwise False - :return: a kickstart module object - """ - names = name.split(":", maxsplit=1) + [""] - - return COMMANDS.ModuleData( - name=names[0], - stream=names[1], - enable=enabled, - ) - def create_ks_group(name, include=GROUP_DEFAULT): """Create a new instance of a kickstart group. @@ -291,7 +256,6 @@ class PayloadKickstartSpecification(KickstartSpecification): "harddrive": COMMANDS.HardDrive, "hmc": COMMANDS.Hmc, "liveimg": COMMANDS.Liveimg, - "module": COMMANDS.Module, "nfs": COMMANDS.NFS, "ostreecontainer": COMMANDS.OSTreeContainer, "ostreesetup": COMMANDS.OSTreeSetup, @@ -300,7 +264,6 @@ class PayloadKickstartSpecification(KickstartSpecification): } commands_data = { - "ModuleData": COMMANDS.ModuleData, "RepoData": COMMANDS.RepoData, } diff --git a/pyanaconda/modules/payloads/payload/dnf/dnf_manager.py b/pyanaconda/modules/payloads/payload/dnf/dnf_manager.py index 79122ef0fa1c..a7ae0cf09970 100644 --- a/pyanaconda/modules/payloads/payload/dnf/dnf_manager.py +++ b/pyanaconda/modules/payloads/payload/dnf/dnf_manager.py @@ -506,44 +506,6 @@ def match_available_packages(self, pattern): packages = self._base.sack.query().available().filter(name__glob=pattern) return [p.name for p in packages] - def enable_modules(self, module_specs): - """Mark module streams for enabling. - - Mark module streams matching the module_specs list and also - all required modular dependencies for enabling. For specs - that do not specify the stream, the default stream is used. - - :param module_specs: a list of specs - :raise MissingSpecsError: if there are missing specs - :raise BrokenSpecsError: if there are broken specs - """ - log.debug("Enabling modules: %s", module_specs) - - try: - module_base = dnf.module.module_base.ModuleBase(self._base) - module_base.enable(module_specs) - except dnf.exceptions.MarkingErrors as e: - log.error("Failed to enable modules!\n%s", str(e)) - self._handle_marking_errors(e) - - def disable_modules(self, module_specs): - """Mark modules for disabling. - - Mark modules matching the module_specs list for disabling. - Only the name part of the module specification is relevant. - - :param module_specs: a list of specs to disable - :raise MissingSpecsError: if there are missing specs - :raise BrokenSpecsError: if there are broken specs - """ - log.debug("Disabling modules: %s", module_specs) - try: - module_base = dnf.module.module_base.ModuleBase(self._base) - module_base.disable(module_specs) - except dnf.exceptions.MarkingErrors as e: - log.error("Failed to disable modules!\n%s", str(e)) - self._handle_marking_errors(e) - def apply_specs(self, include_list, exclude_list): """Mark packages, groups and modules for installation. diff --git a/pyanaconda/modules/payloads/payload/dnf/validation.py b/pyanaconda/modules/payloads/payload/dnf/validation.py index 49ce63f5af04..f5afb42f801c 100644 --- a/pyanaconda/modules/payloads/payload/dnf/validation.py +++ b/pyanaconda/modules/payloads/payload/dnf/validation.py @@ -130,12 +130,6 @@ def _resolve_selection(self): log.debug("Resolving the software selection.") report = ValidationReport() - with self._reported_errors(report): - self._dnf_manager.disable_modules(self._selection.disabled_modules) - - with self._reported_errors(report): - self._dnf_manager.enable_modules(self._selection.modules) - with self._reported_errors(report): self._dnf_manager.apply_specs(self._include_list, self._exclude_list) diff --git a/tests/unit_tests/pyanaconda_tests/modules/payloads/payload/test_module_payload_dnf.py b/tests/unit_tests/pyanaconda_tests/modules/payloads/payload/test_module_payload_dnf.py index 049f504caaf6..45ba9d850a74 100644 --- a/tests/unit_tests/pyanaconda_tests/modules/payloads/payload/test_module_payload_dnf.py +++ b/tests/unit_tests/pyanaconda_tests/modules/payloads/payload/test_module_payload_dnf.py @@ -466,25 +466,6 @@ def test_repo_disabled(self): payload.repositories[1].enabled = False self._test_kickstart(None, ks_out, expected_publish_calls=0) - def test_module_kickstart(self): - ks_in = """ - module --name=nodejs - module --name=django --stream=1.6 - module --name=postgresql --disable - module --name=mysql --stream=8.0 --disable - """ - ks_out = """ - module --name=nodejs - module --name=django --stream=1.6 - module --name=postgresql --disable - module --name=mysql --stream=8.0 --disable - - %packages - - %end - """ - self._test_kickstart(ks_in, ks_out) - def test_packages_section_empty_kickstart(self): """Test the empty packages section.""" ks_in = """ diff --git a/tests/unit_tests/pyanaconda_tests/modules/payloads/payload/test_module_payload_dnf_installation.py b/tests/unit_tests/pyanaconda_tests/modules/payloads/payload/test_module_payload_dnf_installation.py index 8a89ba8a184b..42d87960833c 100644 --- a/tests/unit_tests/pyanaconda_tests/modules/payloads/payload/test_module_payload_dnf_installation.py +++ b/tests/unit_tests/pyanaconda_tests/modules/payloads/payload/test_module_payload_dnf_installation.py @@ -380,8 +380,6 @@ def test_resolve(self, kernel_getter, req_getter1, req_getter2, req_getter3, req task.run() dnf_manager.clear_selection.assert_called_once_with() - dnf_manager.disable_modules.assert_called_once_with([]) - dnf_manager.enable_modules.assert_called_once_with([]) dnf_manager.apply_specs.assert_called_once_with( ["@core", "@r1", "@r2", "r4", "r5"], ["@r3", "r6"] ) @@ -416,7 +414,6 @@ def test_fail(self, kernel_getter, req_getter1, req_getter2, req_getter3, req_ge expected = "e1\n\ne2" assert str(cm.value) == expected - dnf_manager.enable_modules.side_effect = BrokenSpecsError("e3") dnf_manager.resolve_selection.side_effect = InvalidSelectionError("e4") with pytest.raises(PayloadInstallationError) as cm: diff --git a/tests/unit_tests/pyanaconda_tests/modules/payloads/payload/test_module_payload_dnf_manager.py b/tests/unit_tests/pyanaconda_tests/modules/payloads/payload/test_module_payload_dnf_manager.py index cbd600ed0113..1af0d4a1d34e 100644 --- a/tests/unit_tests/pyanaconda_tests/modules/payloads/payload/test_module_payload_dnf_manager.py +++ b/tests/unit_tests/pyanaconda_tests/modules/payloads/payload/test_module_payload_dnf_manager.py @@ -235,50 +235,6 @@ def test_get_download_size(self): assert size == Size("450 MiB") - @patch("dnf.module.module_base.ModuleBase.enable") - def test_enable_modules(self, module_base_enable): - """Test the enable_modules method.""" - self.dnf_manager.enable_modules( - module_specs=["m1", "m2:latest"] - ) - module_base_enable.assert_called_once_with( - ["m1", "m2:latest"] - ) - - @patch("dnf.module.module_base.ModuleBase.enable") - def test_enable_modules_error(self, module_base_enable): - """Test the failed enable_modules method.""" - module_base_enable.side_effect = MarkingErrors( - module_depsolv_errors=["e1", "e2"] - ) - - with pytest.raises(BrokenSpecsError): - self.dnf_manager.enable_modules( - module_specs=["m1", "m2:latest"] - ) - - @patch("dnf.module.module_base.ModuleBase.disable") - def test_disable_modules(self, module_base_disable): - """Test the enable_modules method.""" - self.dnf_manager.disable_modules( - module_specs=["m1", "m2:latest"] - ) - module_base_disable.assert_called_once_with( - ["m1", "m2:latest"] - ) - - @patch("dnf.module.module_base.ModuleBase.disable") - def test_disable_modules_error(self, module_base_disable): - """Test the failed enable_modules method.""" - module_base_disable.side_effect = MarkingErrors( - module_depsolv_errors=["e1", "e2"] - ) - - with pytest.raises(BrokenSpecsError): - self.dnf_manager.disable_modules( - module_specs=["m1", "m2:latest"] - ) - @patch("dnf.base.Base.install_specs") def test_apply_specs(self, install_specs): """Test the apply_specs method.""" diff --git a/tests/unit_tests/pyanaconda_tests/modules/payloads/test_module_payloads.py b/tests/unit_tests/pyanaconda_tests/modules/payloads/test_module_payloads.py index 3e1834351a30..3d5469e41417 100644 --- a/tests/unit_tests/pyanaconda_tests/modules/payloads/test_module_payloads.py +++ b/tests/unit_tests/pyanaconda_tests/modules/payloads/test_module_payloads.py @@ -63,7 +63,6 @@ def test_kickstart_properties(self): "harddrive", "hmc", "liveimg", - "module", "nfs", "ostreecontainer", "ostreesetup",