Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RHELC-1626] Use no_rhsm to detect if enablerepos should be disabled #1289

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions convert2rhel/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,29 @@ def get_rhel_repoids():


def get_rhel_repos_to_disable():
"""Get the list of repositories which should be disabled when performing pre-conversion checks. Avoid downloading
backup and up-to-date checks from them. The output list can looks like:
['rhel*', 'user-provided', 'user-provided1']
"""Get the list of repositories which should be disabled when performing pre-conversion checks.

Avoid downloading backup and up-to-date checks from them. The output list can looks like: ["rhel*"]

.. note::
If --enablerepo switch is used together with the --no-rhsm, we will return a combination of repositories to disable as following:

>>> # tool_opts.enablerepo comes from the CLI option `--enablerepo`.
>>> repos_to_disable = ["rhel*"]
>>> repos_to_disable.extend(tool_opts.enablerepo) # returns: ["rhel*", "my-rhel-repo-mirror"]

:return: List of repositories to disable when performing checks.
:rtype: List[str]
:rtype: list[str]
"""
# RHELC-884 disable the RHEL repos to avoid reaching them when checking original system.
# Also disable repositories enabled by the user for the conversion.
return ["rhel*"] + tool_opts.enablerepo
repos_to_disable = ["rhel*"]

# this is for the case where the user configures e.g. [my-rhel-repo-mirror] on the system and leaves it enabled
# before running convert2rhel - we want to prevent the checks from accessing it as it contains packages for RHEL
if tool_opts.no_rhsm:
repos_to_disable.extend(tool_opts.enablerepo)

return repos_to_disable


def get_rhel_disable_repos_command(disable_repos):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,6 @@ def test_is_loaded_kernel_latest_system_exit(self, monkeypatch, is_loaded_kernel
"--setopt=exclude=",
"--quiet",
"--disablerepo=rhel*",
"--disablerepo=test-repo",
"--qf",
"C2R\\t%{BUILDTIME}\\t%{VERSION}-%{RELEASE}\\t%{REPOID}",
"kernel",
Expand Down
17 changes: 13 additions & 4 deletions convert2rhel/unit_tests/repo_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,21 @@ def test_get_rhel_repoids_el7(pretend_os, is_els_release, expected, monkeypatch)
assert repos == expected


@pytest.mark.parametrize(("enablerepo", "disablerepos"), (([], ["rhel*"]), (["test-repo"], ["rhel*", "test-repo"])))
def test_get_rhel_repos_to_disable(monkeypatch, enablerepo, disablerepos):
monkeypatch.setattr(repo.tool_opts, "enablerepo", enablerepo)
@pytest.mark.parametrize(
("no_rhsm", "enablerepo", "disablerepos"),
(
(False, [], ["rhel*"]),
(True, ["test-repo"], ["rhel*", "test-repo"]),
(True, [], ["rhel*"]),
(False, ["test-repo"], ["rhel*"]),
),
)
def test_get_rhel_repos_to_disable(monkeypatch, global_tool_opts, no_rhsm, enablerepo, disablerepos):
monkeypatch.setattr(repo, "tool_opts", global_tool_opts)
global_tool_opts.enablerepo = enablerepo
global_tool_opts.no_rhsm = no_rhsm

repos = repo.get_rhel_repos_to_disable()

assert repos == disablerepos


Expand Down
Loading