From b942d8781251088d1ab4156664ec5c539cdd1b47 Mon Sep 17 00:00:00 2001 From: mhecko Date: Tue, 29 Aug 2023 11:33:50 +0200 Subject: [PATCH] aws 8>9: copy dnf plugin --- .../cloud/checkrhui/libraries/checkrhui.py | 14 +++++++++++++ .../tests/component_test_checkrhui.py | 20 +++++++++++++++++++ repos/system_upgrade/common/libraries/rhui.py | 2 +- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/repos/system_upgrade/common/actors/cloud/checkrhui/libraries/checkrhui.py b/repos/system_upgrade/common/actors/cloud/checkrhui/libraries/checkrhui.py index fff7b2d233..84ab40e353 100644 --- a/repos/system_upgrade/common/actors/cloud/checkrhui/libraries/checkrhui.py +++ b/repos/system_upgrade/common/actors/cloud/checkrhui/libraries/checkrhui.py @@ -136,6 +136,19 @@ def customize_rhui_setup_for_gcp(rhui_family, setup_info): setup_info.preinstall_tasks.files_to_remove.append('/etc/yum.repos.d/google-cloud.repo') +def customize_rhui_setup_for_aws(rhui_family, setup_info): + if rhui_family.provider != rhui.RHUIProvider.AWS: + return + + target_version = version.get_target_major_version() + if target_version == '8': + return # The rhel8 plugin is packed into leapp-rhui-aws as we need python2 compatible client + + amazon_plugin_copy_task = CopyFile(src='/usr/lib/python3.9/site-packages/dnf-plugins/amazon-id.py', + dst='/usr/lib/python3.6/site-packages/dnf-plugins/') + setup_info.postinstall_tasks.files_to_copy.append(amazon_plugin_copy_task) + + def produce_rhui_info_to_setup_target(rhui_family, source_setup_desc, target_setup_desc): rhui_files_location = os.path.join(api.get_common_folder_path('rhui'), rhui_family.client_files_folder) @@ -167,6 +180,7 @@ def produce_rhui_info_to_setup_target(rhui_family, source_setup_desc, target_set ) customize_rhui_setup_for_gcp(rhui_family, target_client_setup_info) + customize_rhui_setup_for_aws(rhui_family, target_client_setup_info) rhui_info = RHUIInfo( provider=rhui_family.provider.lower(), diff --git a/repos/system_upgrade/common/actors/cloud/checkrhui/tests/component_test_checkrhui.py b/repos/system_upgrade/common/actors/cloud/checkrhui/tests/component_test_checkrhui.py index a51c5f1fe4..93f13a004a 100644 --- a/repos/system_upgrade/common/actors/cloud/checkrhui/tests/component_test_checkrhui.py +++ b/repos/system_upgrade/common/actors/cloud/checkrhui/tests/component_test_checkrhui.py @@ -157,6 +157,26 @@ def test_google_specific_customization(provider, should_mutate): assert setup_info == mk_setup_info() +@pytest.mark.parametrize( + ('rhui_family', 'target_major', 'should_mutate'), + [ + (RHUIFamily(rhui.RHUIProvider.AWS), '8', False), + (RHUIFamily(rhui.RHUIProvider.AWS), '9', True), + (RHUIFamily(rhui.RHUIProvider.AWS, variant=rhui.RHUIVariant.SAP), '9', True), + (RHUIFamily('azure'), '9', False), + ] +) +def test_aws_specific_customization(monkeypatch, rhui_family, target_major, should_mutate): + dst_ver = '{major}.0'.format(major=target_major) + monkeypatch.setattr(api, 'current_actor', CurrentActorMocked(dst_ver=dst_ver)) + + setup_info = mk_setup_info() + checkrhui_lib.customize_rhui_setup_for_aws(rhui_family, setup_info) + + was_mutated = not are_setup_infos_eq(setup_info, mk_setup_info()) + assert should_mutate == was_mutated + + def produce_rhui_info_to_setup_target(monkeypatch): source_rhui_setup = mk_rhui_setup( clients={'src_pkg'}, diff --git a/repos/system_upgrade/common/libraries/rhui.py b/repos/system_upgrade/common/libraries/rhui.py index 705ba4dc5e..1c9898b741 100644 --- a/repos/system_upgrade/common/libraries/rhui.py +++ b/repos/system_upgrade/common/libraries/rhui.py @@ -110,7 +110,7 @@ def mk_rhui_setup(clients=None, leapp_pkg='', mandatory_files=None, optional_fil # Since the default optional files are not [], we cannot use the same construction as above # to allow the caller to specify empty optional files - default_opt_files = [('content.crt', RHUI_PKI_PRODUCT_DIR), ('key.pem', RHUI_PKI_DIR)] + default_opt_files = [('content-leapp.crt', RHUI_PKI_PRODUCT_DIR), ('key-leapp.pem', RHUI_PKI_DIR)] optional_files = default_opt_files if optional_files is None else optional_files return RHUISetup(clients=clients, leapp_pkg=leapp_pkg, mandatory_files=mandatory_files, arch=arch,