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 _create_target_userspace(context, packages, target_repoids): """Create the target userspace.""" prepare_target_userspace(context, constants.TARGET_USERSPACE, target_repoids, list(packages)) _prep_repository_access(context, constants.TARGET_USERSPACE) dnfplugin.install(constants.TARGET_USERSPACE) # and do not forget to set the rhsm into the container mode again with mounting.NspawnActions(constants.TARGET_USERSPACE) as target_context: rhsm.set_container_mode(target_context)
def _create_target_userspace(context, packages, files, target_repoids): """Create the target userspace.""" prepare_target_userspace(context, _get_target_userspace(), target_repoids, list(packages)) _prep_repository_access(context, _get_target_userspace()) _copy_files(context, files) dnfplugin.install(_get_target_userspace()) # and do not forget to set the rhsm into the container mode again with mounting.NspawnActions(_get_target_userspace()) as target_context: rhsm.set_container_mode(target_context)