Skip to content

Commit

Permalink
aws 8>9: copy dnf plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
mhecko committed Aug 29, 2023
1 parent 35358f0 commit b942d87
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'},
Expand Down
2 changes: 1 addition & 1 deletion repos/system_upgrade/common/libraries/rhui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit b942d87

Please sign in to comment.