tmt.steps.prepare.artifact.providers package

Submodules

tmt.steps.prepare.artifact.providers.brew module

Brew Artifact Provider

class tmt.steps.prepare.artifact.providers.brew.BrewArtifactProvider(raw_provider_id: str, logger: Logger)

Bases: KojiArtifactProvider

Provider for downloading artifacts from Brew builds.

Brew builds are just a special case of Koji builds

Note

Only RPMs are supported currently.

provider = BrewArtifactProvider("brew.build:123456", logger)
artifacts = provider.fetch_contents(guest, Path("/tmp"))
property build_provider: BrewBuild | None
class tmt.steps.prepare.artifact.providers.brew.BrewBuild(raw_provider_id: str, logger: Logger)

Bases: BrewArtifactProvider, KojiBuild

class tmt.steps.prepare.artifact.providers.brew.BrewNvr(raw_provider_id: str, logger: Logger)

Bases: BrewArtifactProvider, KojiNvr

class tmt.steps.prepare.artifact.providers.brew.BrewTask(raw_provider_id: str, logger: Logger)

Bases: BrewArtifactProvider, KojiTask

tmt.steps.prepare.artifact.providers.file module

class tmt.steps.prepare.artifact.providers.file.PackageAsFileArtifactInfo(_raw_artifact: str)

Bases: ArtifactInfo

Represents a single local or remote package file or directory.

property id: str

A unique identifier of the artifact.

property location: str
class tmt.steps.prepare.artifact.providers.file.PackageAsFileArtifactProvider(raw_provider_id: str, logger: Logger)

Bases: ArtifactProvider[PackageAsFileArtifactInfo]

Provider for preparing artifacts from local or remote package files.

This provider can handle: - Glob patterns matching multiple package files. - Local package files specified by absolute or relative paths. - Remote package files accessible via URLs. - Directories containing package files (all packages in the directory are included).

Example usage:

prepare:
  - summary: package files
    how: artifact
    stage: prepare
    provide:
      - file:/tmp/*.rpm                    # Local glob
      - file:/build/specific.rpm           # Single file
      - file:https://example.com/pkg.rpm   # Remote URL
      - file:/path/to/packages/            # Directory
SUPPORTED_PREFIX: ClassVar[str] = 'file'
property artifacts: Sequence[PackageAsFileArtifactInfo]

Collect all artifacts available from this provider.

The method is left for derived classes to implement with respect to the actual artifact provider they implement. The list of artifacts will be cached, and is treated as read-only.

Returns:

a list of provided artifacts.

tmt.steps.prepare.artifact.providers.koji module

Koji Artifact Provider

tmt.steps.prepare.artifact.providers.koji.ClientSession: Any
class tmt.steps.prepare.artifact.providers.koji.KojiArtifactProvider(raw_provider_id: str, logger: Logger)

Bases: ArtifactProvider[RpmArtifactInfo]

Provider for downloading artifacts from Koji builds.

Note

Only RPMs are supported currently.

provider = KojiArtifactProvider("koji.build:123456", logger)
artifacts = provider.download_artifacts(guest, Path("/tmp"), [])
property build_id: int | None

Resolve and return the build ID.

There are multiple possible ways of finding a build ID from the artifact provider inputs, individual artifact providers must chose the most fitting one.

Returns:

the build ID, or None if there is no build attached to this provider.

Raises:

GeneralError – when the build should exist, but cannot be found in Koji.

property build_info: dict[str, Any] | None

Fetch and return the build metadata for the resolved build ID.

Returns:

the build metadata, or None if not found.

property build_provider: KojiBuild | None
make_rpm_artifact(rpm_meta: dict[str, str]) RpmArtifactInfo

Create a normal build RPM artifact from metadata returned by listBuildRPMs.

class tmt.steps.prepare.artifact.providers.koji.KojiBuild(raw_provider_id: str, logger: Logger)

Bases: KojiArtifactProvider

property artifacts: Sequence[RpmArtifactInfo]

Collect all artifacts available from this provider.

The method is left for derived classes to implement with respect to the actual artifact provider they implement. The list of artifacts will be cached, and is treated as read-only.

Returns:

a list of provided artifacts.

property build_id: int

Resolve and return the build ID.

There are multiple possible ways of finding a build ID from the artifact provider inputs, individual artifact providers must chose the most fitting one.

Returns:

the build ID, or None if there is no build attached to this provider.

Raises:

GeneralError – when the build should exist, but cannot be found in Koji.

class tmt.steps.prepare.artifact.providers.koji.KojiNvr(raw_provider_id: str, logger: Logger)

Bases: KojiArtifactProvider

property artifacts: Sequence[RpmArtifactInfo]

RPM artifacts for the given NVR.

property build_id: int

Resolve and return the build ID.

There are multiple possible ways of finding a build ID from the artifact provider inputs, individual artifact providers must chose the most fitting one.

Returns:

the build ID, or None if there is no build attached to this provider.

Raises:

GeneralError – when the build should exist, but cannot be found in Koji.

property build_info: dict[str, Any] | None

Fetch and return the build metadata for the nvr.

Returns:

the build metadata, or None if not found.

class tmt.steps.prepare.artifact.providers.koji.KojiTask(raw_provider_id: str, logger: Logger)

Bases: KojiArtifactProvider

property artifacts: Sequence[RpmArtifactInfo]

Collect all artifacts available from this provider.

The method is left for derived classes to implement with respect to the actual artifact provider they implement. The list of artifacts will be cached, and is treated as read-only.

Returns:

a list of provided artifacts.

property build_id: int | None

Resolve and return the build ID.

There are multiple possible ways of finding a build ID from the artifact provider inputs, individual artifact providers must chose the most fitting one.

Returns:

the build ID, or None if there is no build attached to this provider.

Raises:

GeneralError – when the build should exist, but cannot be found in Koji.

make_rpm_artifact(task_id: int, filename: str) ScratchRpmArtifactInfo

Create a scratch RPM artifact from a task output filename.

class tmt.steps.prepare.artifact.providers.koji.RpmArtifactInfo(_raw_artifact: dict[str, str])

Bases: ArtifactInfo

Represents a single RPM package.

property id: str

A koji rpm identifier

property location: str
class tmt.steps.prepare.artifact.providers.koji.ScratchRpmArtifactInfo(_raw_artifact: dict[str, str])

Bases: RpmArtifactInfo

Represents a single RPM url from Koji scratch builds.

property id: str

A koji rpm identifier

tmt.steps.prepare.artifact.providers.koji.import_koji(logger: Logger) None

Import koji module with error handling.

tmt.steps.prepare.artifact.providers.repository module

Artifact provider for discovering RPMs from repository files.

class tmt.steps.prepare.artifact.providers.repository.RepositoryFileProvider(raw_provider_id: str, logger: Logger)

Bases: ArtifactProvider[RpmArtifactInfo]

Provider for making RPM artifacts from a repository discoverable without downloading them.

The provider identifier should start with ‘repository-url:’ followed by a URL to a .repo file, e.g., “repository-url:https://download.docker.com/linux/centos/docker-ce.repo”.

The provider downloads the .repo file to the guest’s /etc/yum.repos.d/ directory, and lists RPMs available in the defined repositories without downloading them, acting as a discovery-only provider. Artifacts are all available RPM packages listed in the repository.

Parameters:
  • raw_provider_id – The full provider identifier, starting with ‘repository-url:’.

  • logger – Logger instance for outputting messages.

Raises:

GeneralError – If the .repo file URL is invalid.

property artifacts: Sequence[RpmArtifactInfo]

List all RPMs discovered from the repositories.

Note

The fetch_contents() method must be called first to populate the artifact list from the guest.

fetch_contents(guest: Guest, download_path: Path, exclude_patterns: list[Pattern[str]] | None = None) list[Path]

Fetch all artifacts to the specified destination.

Parameters:
  • guest – the guest on which the artifact should be downloaded.

  • download_path – path into which the artifact should be downloaded.

  • exclude_patterns – if set, artifacts whose names match any of the given regular expressions would not be downloaded.

Returns:

a list of paths to the downloaded artifacts.

Raises:

GeneralError – Unexpected errors outside the download process.

Note:

Errors during individual artifact downloads are caught, logged as warnings, and ignored.

repository: Repository
tmt.steps.prepare.artifact.providers.repository.create_repository(artifact_dir: Path, guest: Guest, logger: Logger, repo_name: str | None = None, priority: int = 1) Repository

Create a local RPM repository from a directory on the guest.

Creates repository metadata and prepares a Repository object. Does not install the repository on the guest system. Use install_repository() to make it visible to the package manager.

Parameters:
  • artifact_dir – Path to the directory on the guest containing RPM files.

  • guest – Guest instance where the repository metadata will be created.

  • logger – Logger instance for outputting debug and error messages.

  • repo_name – Name for the repository. If not provided, generates a unique name using the format tmt-repo-default-{n}.

  • priority – Repository priority (default: 1). Lower values have higher priority.

Returns:

Repository object representing the newly created repository.

Raises:

PrepareError – If the package manager does not support creating repositories or if metadata creation fails.

tmt.steps.prepare.artifact.providers.repository.parse_rpm_string(pkg_string: str) dict[str, str]

Parses a full RPM package string (N-E:V-R.A) into its components.

Parameters:

pkg_string – The package string, e.g., “docker-ce-1:20.10.7-3.el8.x86_64”.

Raises:

ValueError – if the package string is malformed.

Returns:

A dictionary of RPM components.

Module contents

Abstract base class for artifact providers.

class tmt.steps.prepare.artifact.providers.ArtifactInfo(_raw_artifact: Any)

Bases: ABC

Information about a single artifact, e.g. a package.

abstract property id: str

A unique identifier of the artifact.

abstract property location: str
class tmt.steps.prepare.artifact.providers.ArtifactInfoT

A type variable representing subclasses of ArtifactInfo containers.

alias of TypeVar(‘ArtifactInfoT’, bound=ArtifactInfo)

class tmt.steps.prepare.artifact.providers.ArtifactProvider(raw_provider_id: str, logger: Logger)

Bases: ABC, Generic[ArtifactInfoT]

Base class for artifact providers.

Each provider must implement:

  • parsing and validating the artifact ID,

  • listing available artifacts,

  • downloading a single given artifact.

property artifacts: Sequence[ArtifactInfoT]

Collect all artifacts available from this provider.

The method is left for derived classes to implement with respect to the actual artifact provider they implement. The list of artifacts will be cached, and is treated as read-only.

Returns:

a list of provided artifacts.

fetch_contents(guest: Guest, download_path: Path, exclude_patterns: list[Pattern[str]] | None = None) list[Path]

Fetch all artifacts to the specified destination.

Parameters:
  • guest – the guest on which the artifact should be downloaded.

  • download_path – path into which the artifact should be downloaded.

  • exclude_patterns – if set, artifacts whose names match any of the given regular expressions would not be downloaded.

Returns:

a list of paths to the downloaded artifacts.

Raises:

GeneralError – Unexpected errors outside the download process.

Note:

Errors during individual artifact downloads are caught, logged as warnings, and ignored.

id: str

Identifier of this artifact provider. It is valid and unique in the domain of this provider. koji.build:12345. URL for a repository, and so on.

tmt.steps.prepare.artifact.providers.ArtifactProviderId

A type of an artifact provider identifier.

exception tmt.steps.prepare.artifact.providers.DownloadError(message: str, causes: list[Exception] | None = None, *args: Any, **kwargs: Any)

Bases: GeneralError

Raised when download fails.

General error.

Parameters:
  • message – error message.

  • causes – optional list of exceptions that caused this one. Since raise ... from ... allows only for a single cause, and some of our workflows may raise exceptions triggered by more than one exception, we need a mechanism for storing them. Our reporting will honor this field, and report causes the same way as __cause__.

class tmt.steps.prepare.artifact.providers.Repository(content: str, name: str, repo_ids: list[str] = <factory>)

Bases: object

Thin wrapper/holder for .repo file content

content: str

Content of the repository

property filename: str

The name of the .repo file (e.g., ‘my-repo.repo’).

classmethod from_content(content: str, name: str, logger: Logger) Repository

Create a Repository instance directly from provided content string.

Parameters:
  • content – The string content of the repository.

  • name – The name for the repository (required when using content).

  • logger – Logger to use for the operation.

Returns:

A Repository instance.

Raises:

GeneralError – If the name is empty.

classmethod from_file_path(file_path: Path, logger: Logger, name: str | None = None) Repository

Create a Repository instance by reading content from a local file path.

Parameters:
  • file_path – The local path to the repository file.

  • logger – Logger to use for the operation.

  • name – Optional name for the repository. If not provided, derived from the file path.

Returns:

A Repository instance.

Raises:

GeneralError – If reading the file fails.

classmethod from_url(url: str, logger: Logger, name: str | None = None) Repository

Create a Repository instance by fetching content from a URL.

Parameters:
  • url – The URL to fetch the repository content from.

  • logger – Logger to use for the operation.

  • name – Optional name for the repository. If not provided, derived from the URL.

Returns:

A Repository instance.

Raises:

GeneralError – If fetching or parsing fails.

name: str

Uniquely identifiable name

repo_ids: list[str]

repository_ids present in the .repo file