def process(self): self.produce( RepositoriesBlacklisted(repoids=[ 'rhel8-buildroot', # As seem at PES Events 'rhel8-crb', # As seem at PES Events 'codeready-builder-for-rhel-8-x86_64-rpms' ]))
def test_custom_repos(monkeypatch): """ Tests whether the CustomRepos provided to the actor are propagated to the TargetRepositories after blacklist filtering is applied on them. """ custom = CustomTargetRepository( repoid='rhel-8-server-rpms', name='RHEL 8 Server (RPMs)', baseurl='https://.../dist/rhel/server/8/os', enabled=True) blacklisted = CustomTargetRepository( repoid='rhel-8-blacklisted-rpms', name='RHEL 8 Blacklisted (RPMs)', baseurl='https://.../dist/rhel/blacklisted/8/os', enabled=True) repos_blacklisted = RepositoriesBlacklisted( repoids=['rhel-8-blacklisted-rpms']) repositories_mapping = RepositoriesMapping(mapping=[], repositories=[]) msgs = [custom, blacklisted, repos_blacklisted, repositories_mapping] monkeypatch.setattr(api, 'current_actor', CurrentActorMocked(msgs=msgs)) monkeypatch.setattr(api, 'produce', produce_mocked()) setuptargetrepos.process() assert api.produce.called custom_repos = api.produce.model_instances[0].custom_repos assert len(custom_repos) == 1 assert custom_repos[0].repoid == 'rhel-8-server-rpms'
def test_custom_repos(current_actor_context): custom = CustomTargetRepository( repoid='rhel-8-server-rpms', name='RHEL 8 Server (RPMs)', baseurl='https://.../dist/rhel/server/8/os', enabled=True) blacklisted = CustomTargetRepository( repoid='rhel-8-blacklisted-rpms', name='RHEL 8 Blacklisted (RPMs)', baseurl='https://.../dist/rhel/blacklisted/8/os', enabled=True) repos_blacklisted = RepositoriesBlacklisted( repoids=['rhel-8-blacklisted-rpms']) current_actor_context.feed(custom) current_actor_context.feed(blacklisted) current_actor_context.feed(repos_blacklisted) current_actor_context.run() assert current_actor_context.consume(TargetRepositories) custom_repos = current_actor_context.consume( TargetRepositories)[0].custom_repos assert len(custom_repos) == 1 assert custom_repos[0].repoid == 'rhel-8-server-rpms'
def process(): # blacklist CRB repo if optional repo is not enabled reposid_blacklist = _get_disabled_optional_repo() if reposid_blacklist: api.current_logger().info( "The optional repository is not enabled. Blacklisting the CRB repository." ) api.produce(RepositoriesBlacklisted(repoids=reposid_blacklist)) report = [ reporting.Title("Excluded RHEL 8 repositories"), reporting.Summary( "The following repositories are not supported by " "Red Hat and are excluded from the list of repositories " "used during the upgrade.\n- {}".format( "\n- ".join(reposid_blacklist))), reporting.Severity(reporting.Severity.INFO), reporting.Tags([reporting.Tags.REPOSITORY]), reporting.Flags([reporting.Flags.FAILURE]), reporting.ExternalLink( url=("https://access.redhat.com/documentation/en-us/" "red_hat_enterprise_linux/8/html/package_manifest/" "codereadylinuxbuilder-repository."), title="CodeReady Linux Builder repository", ), ] reporting.create_report(report)
def process(): # blacklist CRB repo if optional repo is not enabled reposid_blacklist = _get_disabled_optional_repo() if reposid_blacklist: api.current_logger().info( "The optional repository is not enabled. Blacklisting the CRB repository." ) api.produce(RepositoriesBlacklisted(repoids=reposid_blacklist))
def process(self): # blacklist CRB repo if optional repo is not enabled if not (self._is_repo_enabled('rhel-7-server-optional-rpms') or self._is_repo_enabled('rhel-7-server-eus-optional-rpms')): self.log.info( "The optional repository is not enabled. Blacklisting the CRB repository." ) self.produce( RepositoriesBlacklisted( repoids=['codeready-builder-for-rhel-8-x86_64-rpms']))
def test_repos_mapping(current_actor_context): repos_data = [ RepositoryData(repoid='rhel-7-server-rpms', name='RHEL 7 Server'), RepositoryData(repoid='rhel-7-blacklisted-rpms', name='RHEL 7 Blacklisted') ] repos_files = [ RepositoryFile(file='/etc/yum.repos.d/redhat.repo', data=repos_data) ] facts = RepositoriesFacts(repositories=repos_files) arch = stdlib.run(['uname', '-m'])['stdout'].strip() mapping = [ RepositoryMap(from_repoid='rhel-7-server-rpms', to_repoid='rhel-8-for-{}-baseos-htb-rpms'.format(arch), to_pes_repo='rhel8-baseos', from_minor_version='all', to_minor_version='all', arch=arch, repo_type='rpm'), RepositoryMap( from_repoid='rhel-7-server-rpms', to_repoid='rhel-8-for-{}-appstream-htb-rpms'.format(arch), to_pes_repo='rhel8-appstream', from_minor_version='all', to_minor_version='all', arch=arch, repo_type='rpm'), RepositoryMap(from_repoid='rhel-7-blacklist-rpms', to_repoid='rhel-8-blacklist-rpms', to_pes_repo='rhel8-blacklist', from_minor_version='all', to_minor_version='all', arch=arch, repo_type='rpm') ] repos_map = RepositoriesMap(repositories=mapping) repos_blacklisted = RepositoriesBlacklisted( repoids=['rhel-8-blacklisted-rpms']) current_actor_context.feed(facts) current_actor_context.feed(repos_map) current_actor_context.feed(repos_blacklisted) current_actor_context.run() assert current_actor_context.consume(TargetRepositories) rhel_repos = current_actor_context.consume( TargetRepositories)[0].rhel_repos assert len(rhel_repos) == 2 assert {repo.repoid for repo in rhel_repos} == { 'rhel-8-for-x86_64-baseos-htb-rpms', 'rhel-8-for-x86_64-appstream-htb-rpms' }
def test_repos_mapping(current_actor_context): repos_data = [ RepositoryData(repoid='rhel-7-server-rpms', name='RHEL 7 Server'), RepositoryData(repoid='rhel-7-blacklisted-rpms', name='RHEL 7 Blacklisted') ] repos_files = [ RepositoryFile(file='/etc/yum.repos.d/redhat.repo', data=repos_data) ] facts = RepositoriesFacts(repositories=repos_files) mapping = [ RepositoryMap(from_id='rhel-7-server-rpms', to_id='rhel-8-for-x86_64-baseos-htb-rpms', from_minor_version='all', to_minor_version='all', arch='x86_64', repo_type='rpm'), RepositoryMap(from_id='rhel-7-server-rpms', to_id='rhel-8-for-x86_64-appstream-htb-rpms', from_minor_version='all', to_minor_version='all', arch='x86_64', repo_type='rpm'), RepositoryMap(from_id='rhel-7-blacklist-rpms', to_id='rhel-8-blacklist-rpms', from_minor_version='all', to_minor_version='all', arch='x86_64', repo_type='rpm') ] repos_map = RepositoriesMap(repositories=mapping) repos_blacklisted = RepositoriesBlacklisted( repoids=['rhel-8-blacklisted-rpms']) current_actor_context.feed(facts) current_actor_context.feed(repos_map) current_actor_context.feed(repos_blacklisted) current_actor_context.run() assert current_actor_context.consume(TargetRepositories) rhel_repos = current_actor_context.consume( TargetRepositories)[0].rhel_repos assert len(rhel_repos) == 2 assert set([repo.repoid for repo in rhel_repos]) == set([ 'rhel-8-for-x86_64-baseos-htb-rpms', 'rhel-8-for-x86_64-appstream-htb-rpms' ])
def test_repositories_setup_tasks(current_actor_context): repositories_setup_tasks = RepositoriesSetupTasks( to_enable=['rhel-8-server-rpms', 'rhel-8-blacklisted-rpms']) repos_blacklisted = RepositoriesBlacklisted( repoids=['rhel-8-blacklisted-rpms']) current_actor_context.feed(repositories_setup_tasks) current_actor_context.feed(repos_blacklisted) current_actor_context.run() assert current_actor_context.consume(TargetRepositories) rhel_repos = current_actor_context.consume( TargetRepositories)[0].rhel_repos assert len(rhel_repos) == 1 assert rhel_repos[0].repoid == 'rhel-8-server-rpms'
def process(): """ Exclude target repositories provided by Red Hat without support. Conditions to exclude: - there are not such repositories already enabled on the source system (e.g. "Optional" repositories) - such repositories are not required for the upgrade explicitly by the user (e.g. via the --enablerepo option or via the /etc/leapp/files/leapp_upgrade_repositories.repo file) E.g. CRB repository is provided by Red Hat but it is without the support. """ repo_mapping = next(api.consume(RepositoriesMapping), None) repos_facts = next(api.consume(RepositoriesFacts), None) # Handle required messages not received missing_messages = [] if not repo_mapping: missing_messages.append('RepositoriesMapping') if not repos_facts: missing_messages.append('RepositoriesFacts') if missing_messages: raise StopActorExecutionError( 'Actor didn\'t receive required messages: {0}'.format( ', '.join(missing_messages))) if not _are_optional_repos_disabled(repo_mapping, repos_facts): # nothing to do - an optional repository is enabled return # Optional repos are either not present or they are present, but disabled -> blacklist them on target system repos_to_exclude = _get_repoids_to_exclude(repo_mapping) # Do not exclude repos manually enabled from the CLI manually_enabled_repos = _get_manually_enabled_repos() & repos_to_exclude filtered_repos_to_exclude = repos_to_exclude - manually_enabled_repos if manually_enabled_repos: _report_using_unsupported_repos(manually_enabled_repos) if filtered_repos_to_exclude: _report_excluded_repos(filtered_repos_to_exclude) api.produce( RepositoriesBlacklisted(repoids=list(filtered_repos_to_exclude)))
def process(): """ Exclude target repositories provided by Red Hat without support. Conditions to exclude: - there are not such repositories already enabled on the source system (e.g. "Optional" repositories) - such repositories are not required for the upgrade explicitly by the user (e.g. via the --enablerepo option or via the /etc/leapp/files/leapp_upgrade_repositories.repo file) E.g. CRB repository is provided by Red Hat but it is without the support. """ repos_to_exclude = _get_repos_to_exclude() manually_enabled_repos = _get_manually_enabled_repos() & repos_to_exclude overriden_repos_to_exclude = repos_to_exclude - manually_enabled_repos if manually_enabled_repos: _report_using_unsupported_repos(manually_enabled_repos) if overriden_repos_to_exclude: _report_excluded_repos(overriden_repos_to_exclude) api.produce(RepositoriesBlacklisted(repoids=list(overriden_repos_to_exclude)))
def test_repositories_setup_tasks(monkeypatch): """ Tests whether the actor propagates repositories received via a RepositoriesSetupTasks message to the resulting TargetRepositories (and blacklist filtering is applied to them). """ repositories_setup_tasks = RepositoriesSetupTasks( to_enable=['rhel-8-server-rpms', 'rhel-8-blacklisted-rpms']) repos_blacklisted = RepositoriesBlacklisted( repoids=['rhel-8-blacklisted-rpms']) repositories_mapping = RepositoriesMapping(mapping=[], repositories=[]) msgs = [repositories_setup_tasks, repos_blacklisted, repositories_mapping] monkeypatch.setattr(api, 'current_actor', CurrentActorMocked(msgs=msgs)) monkeypatch.setattr(api, 'produce', produce_mocked()) setuptargetrepos.process() assert api.produce.called rhel_repos = api.produce.model_instances[0].rhel_repos assert len(rhel_repos) == 1 assert rhel_repos[0].repoid == 'rhel-8-server-rpms'
def test_repos_mapping(monkeypatch): """ Tests whether actor correctly determines what repositories should be enabled on target based on the information about what repositories are enabled on the source system using the RepositoriesMapping information. """ repos_data = [ RepositoryData(repoid='rhel-7-server-rpms', name='RHEL 7 Server'), RepositoryData(repoid='rhel-7-blacklisted-rpms', name='RHEL 7 Blacklisted') ] repos_files = [ RepositoryFile(file='/etc/yum.repos.d/redhat.repo', data=repos_data) ] facts = RepositoriesFacts(repositories=repos_files) repomap = RepositoriesMapping( mapping=[ RepoMapEntry( source='rhel7-base', target=['rhel8-baseos', 'rhel8-appstream', 'rhel8-blacklist']) ], repositories=[ PESIDRepositoryEntry(pesid='rhel7-base', repoid='rhel-7-server-rpms', major_version='7', arch='x86_64', repo_type='rpm', channel='ga', rhui=''), PESIDRepositoryEntry(pesid='rhel8-baseos', repoid='rhel-8-for-x86_64-baseos-htb-rpms', major_version='8', arch='x86_64', repo_type='rpm', channel='ga', rhui=''), PESIDRepositoryEntry(pesid='rhel8-appstream', repoid='rhel-8-for-x86_64-appstream-htb-rpms', major_version='8', arch='x86_64', repo_type='rpm', channel='ga', rhui=''), PESIDRepositoryEntry(pesid='rhel8-blacklist', repoid='rhel-8-blacklisted-rpms', major_version='8', arch='x86_64', repo_type='rpm', channel='ga', rhui=''), ]) repos_blacklisted = RepositoriesBlacklisted( repoids=['rhel-8-blacklisted-rpms']) msgs = [facts, repomap, repos_blacklisted] monkeypatch.setattr(api, 'current_actor', CurrentActorMocked(msgs=msgs)) monkeypatch.setattr(api, 'produce', produce_mocked()) setuptargetrepos.process() assert api.produce.called rhel_repos = api.produce.model_instances[0].rhel_repos assert len(rhel_repos) == 2 produced_rhel_repoids = {repo.repoid for repo in rhel_repos} expected_rhel_repoids = { 'rhel-8-for-x86_64-baseos-htb-rpms', 'rhel-8-for-x86_64-appstream-htb-rpms' } assert produced_rhel_repoids == expected_rhel_repoids