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_id: str, repository_priority: int, logger: Logger, parent: PrepareArtifact)
Bases:
KojiArtifactProviderProvider 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"))
- class tmt.steps.prepare.artifact.providers.brew.BrewBuild(raw_id: str, repository_priority: int, logger: Logger, parent: PrepareArtifact)
Bases:
BrewArtifactProvider,KojiBuild
- class tmt.steps.prepare.artifact.providers.brew.BrewNvr(raw_id: str, repository_priority: int, logger: Logger, parent: PrepareArtifact)
Bases:
BrewArtifactProvider,KojiNvr
- class tmt.steps.prepare.artifact.providers.brew.BrewTask(raw_id: str, repository_priority: int, logger: Logger, parent: PrepareArtifact)
Bases:
BrewArtifactProvider,KojiTask
tmt.steps.prepare.artifact.providers.copr_build module
Copr Build Artifact Provider
- tmt.steps.prepare.artifact.providers.copr_build.Client: Any
- class tmt.steps.prepare.artifact.providers.copr_build.CoprBuildArtifactProvider(raw_id: str, repository_priority: int, logger: Logger, parent: PrepareArtifact)
Bases:
ArtifactProviderProvider for downloading artifacts from Copr builds.
Identifier format: build-id:chroot-name
Example usage:
prepare: - summary: copr build artifacts how: artifact provide: - copr.build:1784470:fedora-32-x86_64
- property artifacts: Sequence[ArtifactInfo]
Collect all artifacts available from this provider.
- Returns:
a list of provided artifacts.
- build_id: int
- property build_info: Munch | None
Fetch and return the build metadata.
- Returns:
the build metadata, or
Noneif not found.
- property build_packages: Sequence[Munch]
- chroot: str
Contribute artifacts to the shared repository.
This is the main interface for providers to contribute their artifacts to the shared repository. Providers should override this method to implement their specific contribution logic.
- Parameters:
guest – the guest to run the commands on.
source_path – path where the artifacts are located (source for contribution).
shared_repo_dir – path to the shared repository directory where artifacts should be contributed.
exclude_patterns – if set, artifacts whose names match any of the given regular expressions would not be contributed.
- property is_pulp: bool
Check if the build is stored in Pulp.
- make_rpm_artifact(rpm_meta: dict[str, str]) ArtifactInfo
- property result_url: str
Fetch and return the result URL for the build chroot.
tmt.steps.prepare.artifact.providers.copr_repository module
Copr Repository Artifact Provider
- class tmt.steps.prepare.artifact.providers.copr_repository.CoprRepo(is_group: bool, name: str, project: str)
Bases:
object- classmethod from_id(copr_repo: str) Self
Parse a COPR repository identifier into its components.
- is_group: bool
- name: str
- project: str
- class tmt.steps.prepare.artifact.providers.copr_repository.CoprRepositoryProvider(raw_id: str, repository_priority: int, logger: Logger, parent: PrepareArtifact, repository: Repository | None = None)
Bases:
ArtifactProviderProvider for enabling Copr repositories and making their packages available.
Identifier format: @group/project or user/project
Example usage:
prepare: - summary: enable copr repository how: artifact provide: - copr.repository:@teemtee/stable
- fetch_contents(guest: Guest, download_path: Path, exclude_patterns: list[Pattern[str]] | None = None) list[Path]
Enable the Copr repository on the guest and retrieve the resulting
.repofile content.
- get_repositories() list[Repository]
Return a list of
Repositorythat this provider manages.
- repository: Repository | None = None
tmt.steps.prepare.artifact.providers.file module
- class tmt.steps.prepare.artifact.providers.file.PackageAsFileArtifactProvider(raw_id: str, repository_priority: int, logger: Logger, parent: PrepareArtifact)
Bases:
ArtifactProviderProvider 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[ArtifactInfo]
Collect all artifacts available from this provider.
- Returns:
a list of provided artifacts.
Contribute artifacts to the shared repository.
This is the main interface for providers to contribute their artifacts to the shared repository. Providers should override this method to implement their specific contribution logic.
- Parameters:
guest – the guest to run the commands on.
source_path – path where the artifacts are located (source for contribution).
shared_repo_dir – path to the shared repository directory where artifacts should be contributed.
exclude_patterns – if set, artifacts whose names match any of the given regular expressions would not be contributed.
- make_rpm_artifact(path: str) ArtifactInfo
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_id: str, repository_priority: int, logger: Logger, parent: PrepareArtifact)
Bases:
ArtifactProviderProvider 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
Noneif 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
Noneif not found.
Contribute artifacts to the shared repository.
This is the main interface for providers to contribute their artifacts to the shared repository. Providers should override this method to implement their specific contribution logic.
- Parameters:
guest – the guest to run the commands on.
source_path – path where the artifacts are located (source for contribution).
shared_repo_dir – path to the shared repository directory where artifacts should be contributed.
exclude_patterns – if set, artifacts whose names match any of the given regular expressions would not be contributed.
- make_rpm_artifact(rpm_meta: dict[str, Any]) ArtifactInfo
Create a normal build RPM artifact from metadata returned by listBuildRPMs.
- class tmt.steps.prepare.artifact.providers.koji.KojiBuild(raw_id: str, repository_priority: int, logger: Logger, parent: PrepareArtifact)
Bases:
KojiArtifactProvider- property artifacts: Sequence[ArtifactInfo]
Collect all artifacts available from this provider.
- 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
Noneif 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_id: str, repository_priority: int, logger: Logger, parent: PrepareArtifact)
Bases:
KojiArtifactProvider- property artifacts: Sequence[ArtifactInfo]
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
Noneif 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
Noneif not found.
- class tmt.steps.prepare.artifact.providers.koji.KojiTask(raw_id: str, repository_priority: int, logger: Logger, parent: PrepareArtifact)
Bases:
KojiArtifactProvider- property artifacts: Sequence[ArtifactInfo]
Collect all artifacts available from this provider.
- 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
Noneif 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) ArtifactInfo
Create a scratch RPM artifact from a task output filename.
tmt.steps.prepare.artifact.providers.repository module
Artifact provider for discovering RPMs from repository files.
- class tmt.steps.prepare.artifact.providers.repository.RepositoryFileProvider(raw_id: str, repository_priority: int, logger: Logger, parent: PrepareArtifact)
Bases:
ArtifactProviderProvider for making RPM artifacts from a repository discoverable without downloading them.
The provider identifier should start with ‘repository-file:’ followed by a URL to a .repo file, e.g., “repository-file: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_id – The full provider identifier, starting with ‘repository-file:’.
logger – Logger instance for outputting messages.
- Raises:
GeneralError – If the .repo file URL is invalid.
- 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.
- get_repositories() list[Repository]
Return a list of
Repositorythat this provider manages.
- repository: Repository
- tmt.steps.prepare.artifact.providers.repository.create_repository(artifact_dir: Path, guest: Guest, logger: Logger, priority: int, repo_name: str | None = None) 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. 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_url module
Artifact provider for creating DNF repositories from baseurl.
- class tmt.steps.prepare.artifact.providers.repository_url.RepositoryUrlProvider(raw_id: str, repository_priority: int, logger: Logger, parent: PrepareArtifact)
Bases:
ArtifactProviderProvider for making RPM artifacts from a repository discoverable without downloading them.
The provider identifier should start with ‘repository-url:’ followed by a baseurl to a DNF repository, e.g., “repository-url:https://example.com/repo/”.
The provider generates a .repo file with the given baseurl, which will be installed to the guest’s
/etc/yum.repos.d/directory, and lists RPMs available in the repository without downloading them, acting as a discovery-only provider. Artifacts are all available RPM packages listed in the repository.- Parameters:
raw_id – The full provider identifier, starting with ‘repository-url:’.
logger – Logger instance for outputting messages.
- Raises:
ValueError – If the provider identifier format is invalid or the baseurl is missing.
- 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.
- get_repositories() list[Repository]
Return a list of
Repositorythat this provider manages.
- repository: Repository
Module contents
Abstract base class for artifact providers.
- class tmt.steps.prepare.artifact.providers.ArtifactInfo(version: Version, location: str, provider: ArtifactProvider, repo_id: str = 'tmt-artifact-shared')
Bases:
objectInformation about a single artifact, e.g. a package.
- property filename: str
This is the filename of the artifact.
- property id: str
A unique identifier of the artifact.
TODO: Transient for now, modify based on the decision made here: https://github.com/teemtee/tmt/issues/4546
- location: str
- property name: str
- provider: ArtifactProvider
- repo_id: str = 'tmt-artifact-shared'
Repository ID this artifact is available from. Used during verification to confirm the artifact was installed from the expected repository.
- class tmt.steps.prepare.artifact.providers.ArtifactProvider(raw_id: str, repository_priority: int, logger: Logger, parent: PrepareArtifact)
Bases:
ABCBase class for artifact providers.
Two provider patterns exist:
Download providers (e.g.
koji.build): overrideartifactsas a@cached_property, implement_download_artifact()andcontribute_to_shared_repo(). Do not use_artifacts.Repository providers (e.g.
copr.repository): implementget_repositories(). After installation,enumerate_artifacts()queries the package manager and populates_artifacts.
- property artifact_metadata: list[dict[str, Any]]
Get metadata for the artifacts provided by this provider.
- Returns:
List of artifact metadata dictionaries.
- property artifacts: Sequence[ArtifactInfo]
Collect all artifacts available from this provider.
- Returns:
a list of provided artifacts.
Contribute artifacts to the shared repository.
This is the main interface for providers to contribute their artifacts to the shared repository. Providers should override this method to implement their specific contribution logic.
- Parameters:
guest – the guest to run the commands on.
source_path – path where the artifacts are located (source for contribution).
shared_repo_dir – path to the shared repository directory where artifacts should be contributed.
exclude_patterns – if set, artifacts whose names match any of the given regular expressions would not be contributed.
- enumerate_artifacts(guest: Guest) None
Enumerate artifacts from repositories returned by
get_repositories()and populate_artifacts. Call this after repositories are installed.For repository providers only. Does not include artifacts contributed to the shared repository — those are handled by
contribute_to_shared_repo().
- 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.
- get_repositories() list[Repository]
Return a list of
Repositorythat this provider manages.
- 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.
- parent: PrepareArtifact
The PrepareArtifact phase that owns this provider.
- raw_id: str
Original full provider id given
- repository_priority: int
Repository priority for providers that create repositories. Lower values have higher priority in package managers.
- property sanitized_id: str
Sanitized provider ID to use as a directory name
- tmt.steps.prepare.artifact.providers.ArtifactProviderId
A type of an artifact provider identifier.
- tmt.steps.prepare.artifact.providers.SHARED_REPO_NAME: str = 'tmt-artifact-shared'
Name of the shared repository that download providers contribute RPMs into.
- exception tmt.steps.prepare.artifact.providers.UnsupportedOperationError
Bases:
RuntimeErrorRaised when an operation is intentionally unsupported by a provider.