예제 #1
0
    def process(self):
        # TODO: Think about Beta and Alpha repositories. How will we tell we
        # + want to go to GA, Alpha, Beta, ... repos?

        custom_repos = []
        for repo in self.consume(CustomTargetRepository):
            custom_repos.append(repo)

        enabled_repos = []
        for repos in self.consume(RepositoriesFacts):
            for repo_file in repos.repositories:
                for repo in repo_file.data:
                    enabled_repos.append(repo.repoid)

        rhel_repos = []
        for repos_map in self.consume(RepositoriesMap):
            for repo_map in repos_map.repositories:
                # Check if repository map architecture matches system architecture
                if platform.machine() != repo_map.arch:
                    continue

                if repo_map.from_id in enabled_repos:
                    rhel_repos.append(
                        RHELTargetRepository(repoid=repo_map.to_id))

        for task in self.consume(RepositoriesSetupTasks):
            for repo in task.to_enable:
                rhel_repos.append(RHELTargetRepository(repoid=repo))

        repos_blacklisted = set()
        for blacklist in self.consume(RepositoriesBlacklisted):
            repos_blacklisted.update(blacklist.repoids)
        rhel_repos = [
            repo for repo in rhel_repos if repo.repoid not in repos_blacklisted
        ]
        custom_repos = [
            repo for repo in custom_repos
            if repo.repoid not in repos_blacklisted
        ]

        self.produce(
            TargetRepositories(
                rhel_repos=rhel_repos,
                custom_repos=custom_repos,
            ))

        # TODO: Some informational messages would be added for the report and
        # + logs, so we and user will know exactly what is going on.

        return
예제 #2
0
    def process(self):
        # FIXME: currently we will use always only two repositories, unaffected
        # + by the current list of enabled repositories.
        # TODO: Should use CSV file as the source of information for upgrade
        # + from source system to the target system
        # TODO: Think about Beta and Alpha repositories. How will we tell we
        # + want to go to GA, Alpha, Beta, ... repos?

        custom_repos = []
        for repo in self.consume(CustomTargetRepository):
            custom_repos.append(repo)

        rhel_repos = []
        for repo_uid in ("rhel-8-for-x86_64-baseos-htb-rpms", "rhel-8-for-x86_64-appstream-htb-rpms"):
            rhel_repos.append(RHELTargetRepository(uid=repo_uid))

        self.produce(TargetRepositories(
            rhel_repos=rhel_repos,
            custom_repos=custom_repos,
        ))

        # TODO: Some informational messages would be added for the report and
        # + logs, so we and user will know exactly what is going on.

        return
예제 #3
0
def process():
    # load all data / messages
    used_repoids_dict = _get_used_repo_dict()
    enabled_repoids = _get_enabled_repoids()
    excluded_repoids = _get_blacklisted_repoids()
    custom_repos = _get_custom_target_repos()

    # TODO(pstodulk): isn't that a potential issue that we map just enabled repos
    # instead of enabled + used repos??
    # initialise basic data
    repomap = _setup_repomap_handler(enabled_repoids)
    mapped_repoids = _get_mapped_repoids(repomap, enabled_repoids)
    skipped_repoids = enabled_repoids & set(
        used_repoids_dict.keys()) - mapped_repoids

    # Now get the info what should be the target RHEL repositories
    expected_repos = repomap.get_expected_target_pesid_repos(enabled_repoids)
    target_rhel_repoids = set()
    for target_pesid, target_pesidrepo in expected_repos.items():
        if not target_pesidrepo:
            # With the original repomap data, this should not happen (this should
            # currently point to a problem in our data
            # TODO(pstodulk): add report? inhibitor? what should be in the report?
            api.current_logger().error(
                'Missing target repository from the {} family (PES ID).'.
                format(target_pesid))
            continue
        if target_pesidrepo.repoid in excluded_repoids:
            api.current_logger().debug(
                'Skipping the {} repo (excluded).'.format(
                    target_pesidrepo.repoid))
            continue
        target_rhel_repoids.add(target_pesidrepo.repoid)

    # FIXME: this could possibly result into a try to enable multiple repositories
    # from the same family (pesid). But unless we have a bug in previous actors,
    # it should not happen :) it's not blocker error anyway, so survive it.
    # - We expect to deliver the fix as part of the refactoring when we merge
    # setuptargetrepos & peseventsscanner actors together (+ blacklistrepos?)
    for task in api.consume(RepositoriesSetupTasks):
        for repo in task.to_enable:
            if repo in excluded_repoids:
                api.current_logger().debug(
                    'Skipping the {} repo from setup task (excluded).'.format(
                        repo))
                continue
            target_rhel_repoids.add(repo)

    # create the final lists and sort them (for easier testing)
    rhel_repos = [
        RHELTargetRepository(repoid=repoid)
        for repoid in sorted(target_rhel_repoids)
    ]
    custom_repos = [
        repo for repo in custom_repos if repo.repoid not in excluded_repoids
    ]
    custom_repos = sorted(custom_repos, key=lambda x: x.repoid)

    if skipped_repoids:
        pkgs = set()
        for repo in skipped_repoids:
            pkgs.update(used_repoids_dict[repo])
        api.produce(
            SkippedRepositories(repos=sorted(skipped_repoids),
                                packages=sorted(pkgs)))

    api.produce(
        TargetRepositories(
            rhel_repos=rhel_repos,
            custom_repos=custom_repos,
        ))
예제 #4
0
    def process(self):
        # TODO: Think about Beta and Alpha repositories. How will we tell we
        # + want to go to GA, Alpha, Beta, ... repos?

        custom_repos = []
        for repo in self.consume(CustomTargetRepository):
            custom_repos.append(repo)

        enabled_repos = set()
        for repos in self.consume(RepositoriesFacts):
            for repo_file in repos.repositories:
                for repo in repo_file.data:
                    if repo.enabled:
                        enabled_repos.add(repo.repoid)

        rhel_repos = []
        mapped_repos = set()
        for repos_map in self.consume(RepositoriesMap):
            for repo_map in repos_map.repositories:
                # Check if repository map architecture matches system architecture
                if platform.machine() != repo_map.arch:
                    continue

                mapped_repos.add(repo_map.from_repoid)
                if repo_map.from_repoid in enabled_repos:
                    rhel_repos.append(
                        RHELTargetRepository(repoid=repo_map.to_repoid))

        skipped_repos = enabled_repos.difference(mapped_repos)

        used = {}
        for used_repos in self.consume(UsedRepositories):
            for used_repo in used_repos.repositories:
                used[used_repo.repository] = used_repo.packages
                for repo in repo_file.data:
                    enabled_repos.add(repo.repoid)

        skipped_repos = skipped_repos.intersection(set(used.keys()))

        if skipped_repos:
            pkgs = set()
            for repo in skipped_repos:
                pkgs.update(used[repo])
            self.produce(
                SkippedRepositories(repos=list(skipped_repos),
                                    packages=list(pkgs)))

        for task in self.consume(RepositoriesSetupTasks):
            for repo in task.to_enable:
                rhel_repos.append(RHELTargetRepository(repoid=repo))

        repos_blacklisted = set()
        for blacklist in self.consume(RepositoriesBlacklisted):
            repos_blacklisted.update(blacklist.repoids)
        rhel_repos = [
            repo for repo in rhel_repos if repo.repoid not in repos_blacklisted
        ]
        custom_repos = [
            repo for repo in custom_repos
            if repo.repoid not in repos_blacklisted
        ]

        self.produce(
            TargetRepositories(
                rhel_repos=rhel_repos,
                custom_repos=custom_repos,
            ))
예제 #5
0
    def __init__(self, *args):
        self._msgs = []
        for arg in args:
            if not arg:
                continue
            if isinstance(arg, list):
                self._msgs.extend(arg)
            else:
                self._msgs.append(arg)

    def __call__(self, model):
        return iter([msg for msg in self._msgs if isinstance(msg, model)])


_RHEL_REPOS = [
    RHELTargetRepository(repoid='repo1'),
    RHELTargetRepository(repoid='repo2'),
    RHELTargetRepository(repoid='repo3'),
    RHELTargetRepository(repoid='repo4'),
]

_CUSTOM_REPOS = [
    CustomTargetRepository(repoid='repo1',
                           name='repo1name',
                           baseurl='repo1url',
                           enabled=True),
    CustomTargetRepository(repoid='repo2',
                           name='repo2name',
                           baseurl='repo2url',
                           enabled=False),
    CustomTargetRepository(repoid='repo3',