Skip to content

Commit

Permalink
pyanaconda: remove code paths around module command parsing as this w…
Browse files Browse the repository at this point in the history
…as deprecated

Remove also the related tests as these are no longer relevant.

Also bump the pykickstart required version which marks 'module' as
Deprecated.
  • Loading branch information
KKoukiou committed Aug 21, 2024
1 parent e2262be commit 8d9f0b7
Show file tree
Hide file tree
Showing 8 changed files with 1 addition and 149 deletions.
2 changes: 1 addition & 1 deletion anaconda.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 0 additions & 37 deletions pyanaconda/modules/payloads/kickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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.
Expand All @@ -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,
Expand All @@ -300,7 +264,6 @@ class PayloadKickstartSpecification(KickstartSpecification):
}

commands_data = {
"ModuleData": COMMANDS.ModuleData,
"RepoData": COMMANDS.RepoData,
}

Expand Down
38 changes: 0 additions & 38 deletions pyanaconda/modules/payloads/payload/dnf/dnf_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 0 additions & 6 deletions pyanaconda/modules/payloads/payload/dnf/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
)
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def test_kickstart_properties(self):
"harddrive",
"hmc",
"liveimg",
"module",
"nfs",
"ostreecontainer",
"ostreesetup",
Expand Down

0 comments on commit 8d9f0b7

Please sign in to comment.