def perform():
    # NOTE: this one action is out of unit-tests completely; we do not use
    # in unit tests the LEAPP_DEVEL_SKIP_RHSM envar anymore
    _check_deprecated_rhsm_skip()

    indata = _InputData()
    prod_cert_path = _get_product_certificate_path()
    with overlaygen.create_source_overlay(mounts_dir=constants.MOUNTS_DIR,
                                          scratch_dir=constants.SCRATCH_DIR,
                                          storage_info=indata.storage_info,
                                          xfs_info=indata.xfs_info) as overlay:
        with overlay.nspawn() as context:
            target_repoids = _gather_target_repositories(
                context, indata, prod_cert_path)
            _create_target_userspace(context, indata.packages, indata.files,
                                     target_repoids)
            # TODO: this is tmp solution as proper one needs significant refactoring
            target_repo_facts = repofileutils.get_parsed_repofiles(context)
            api.produce(
                TMPTargetRepositoriesFacts(repositories=target_repo_facts))
            # ## TODO ends here
            api.produce(
                UsedTargetRepositories(repos=[
                    UsedTargetRepository(repoid=repo)
                    for repo in target_repoids
                ]))
            api.produce(
                TargetUserSpaceInfo(path=_get_target_userspace(),
                                    scratch=constants.SCRATCH_DIR,
                                    mounts=constants.MOUNTS_DIR))
Example #2
0
def perform():
    packages = {'dnf'}
    for message in api.consume(RequiredTargetUserspacePackages):
        packages.update(message.packages)

    rhsm_info = next(api.consume(SourceRHSMInfo), None)
    if not rhsm_info and not rhsm.skip_rhsm():
        api.current_logger().warn(
            'Could not receive RHSM information - Is this system registered?')
        return

    xfs_info = next(api.consume(XFSPresence), XFSPresence())
    storage_info = next(api.consume(StorageInfo), None)
    if not storage_info:
        api.current_logger.error('No storage info available cannot proceed.')

    prod_cert_path = _get_product_certificate_path()
    with overlaygen.create_source_overlay(mounts_dir=constants.MOUNTS_DIR,
                                          scratch_dir=constants.SCRATCH_DIR,
                                          storage_info=storage_info,
                                          xfs_info=xfs_info) as overlay:
        with overlay.nspawn() as context:
            target_version = api.current_actor().configuration.version.target
            with rhsm.switched_certificate(context, rhsm_info, prod_cert_path,
                                           target_version) as target_rhsm_info:
                api.current_logger().debug(
                    'Target RHSM Info: SKUs: {skus} Repositories: {repos}'.
                    format(repos=target_rhsm_info.enabled_repos,
                           skus=rhsm_info.attached_skus if rhsm_info else []))
                target_repoids = gather_target_repositories(target_rhsm_info)
                api.current_logger().debug(
                    "Gathered target repositories: {}".format(
                        ', '.join(target_repoids)))
                if not target_repoids:
                    raise StopActorExecutionError(
                        message=
                        'There are no enabled target repositories for the upgrade process to proceed.',
                        details={
                            'hint':
                            ('Ensure your system is correctly registered with the subscription manager and that'
                             ' your current subscription is entitled to install the requested target version {version}'
                             ).format(version=api.current_actor().
                                      configuration.version.target)
                        })
                prepare_target_userspace(context, constants.TARGET_USERSPACE,
                                         target_repoids, list(packages))
                _prep_repository_access(context, constants.TARGET_USERSPACE)
                dnfplugin.install(constants.TARGET_USERSPACE)
                api.produce(
                    UsedTargetRepositories(repos=[
                        UsedTargetRepository(repoid=repo)
                        for repo in target_repoids
                    ]))
                api.produce(target_rhsm_info)
                api.produce(
                    TargetUserSpaceInfo(path=constants.TARGET_USERSPACE,
                                        scratch=constants.SCRATCH_DIR,
                                        mounts=constants.MOUNTS_DIR))
def test_unit_localreposinhibit(current_actor_context, baseurl, mirrorlist, metalink, exp_msgs_len):
    """Ensure the Report is generated when local path is used as a baseurl.

    :type current_actor_context: ActorContext
    """
    with pytest.deprecated_call():
        current_actor_context.feed(
            TMPTargetRepositoriesFacts(
                repositories=[
                    RepositoryFile(
                        file="the/path/to/some/file",
                        data=[
                            RepositoryData(
                                name="BASEOS",
                                baseurl=(
                                    "http://example.com/path/to/repo/BaseOS/x86_64/os/"
                                ),
                                repoid="BASEOS",
                            ),
                            RepositoryData(
                                name="APPSTREAM",
                                baseurl=(
                                    "http://example.com/path/to/repo/AppStream/x86_64/os/"
                                ),
                                repoid="APPSTREAM",
                            ),
                            RepositoryData(
                                name="CRB", repoid="CRB", baseurl=baseurl,
                                mirrorlist=mirrorlist, metalink=metalink
                            ),
                        ],
                    )
                ]
            )
        )
    current_actor_context.feed(
        UsedTargetRepositories(
            repos=[
                UsedTargetRepository(repoid="BASEOS"),
                UsedTargetRepository(repoid="CRB"),
            ]
        )
    )
    current_actor_context.run()
    assert len(current_actor_context.messages()) == exp_msgs_len
Example #4
0
    def produce_used_target_repos(self):
        """
        Produce list of used repositories

        We need to know exactly which repositories should be used inside
        the initramdisk. For this purpose, produce list of used repositories
        (just repoids) to use same setup of the upgrade transaction as during
        this precalculation.
        """
        used_repos = []
        for used_repoid in self.target_repoids:
            used_repos.append(UsedTargetRepository(repoid=used_repoid))
        self.produce(UsedTargetRepositories(repos=used_repos))
def perform():
    packages, rhsm_info, xfs_info, storage_info = _consume_data()
    prod_cert_path = _get_product_certificate_path()
    with overlaygen.create_source_overlay(mounts_dir=constants.MOUNTS_DIR,
                                          scratch_dir=constants.SCRATCH_DIR,
                                          storage_info=storage_info,
                                          xfs_info=xfs_info) as overlay:
        with overlay.nspawn() as context:
            target_repoids = _gather_target_repositories(
                context, rhsm_info, prod_cert_path)
            _create_target_userspace(context, packages, target_repoids)
            api.produce(
                UsedTargetRepositories(repos=[
                    UsedTargetRepository(repoid=repo)
                    for repo in target_repoids
                ]))
            api.produce(
                TargetUserSpaceInfo(path=constants.TARGET_USERSPACE,
                                    scratch=constants.SCRATCH_DIR,
                                    mounts=constants.MOUNTS_DIR))
def construct_UTRepo_consume(repoids):
    repos = [UsedTargetRepository(repoid=repoid) for repoid in repoids]
    return lambda *x: (x for x in (UsedTargetRepositories(repos=repos),))