tmt.steps.prepare package

Submodules

tmt.steps.prepare.ansible module

class tmt.steps.prepare.ansible.PrepareAnsible(*, step: Step, data: StepDataT, workdir: Literal[True] | Path | None = None, logger: Logger)

Bases: PreparePlugin[PrepareAnsibleData]

Prepare guest using Ansible.

Run Ansible playbooks against the guest, by running ansible-playbook for all given playbooks.

Warning

When specifying playbooks with paths, all paths must be relative to the metadata tree root.

Run a single playbook on the guest:

prepare:
    how: ansible
    playbook: ansible/packages.yml
prepare --how ansible --playbook ansible/packages.yml

Run multiple playbooks in one phase, with extra arguments for ansible-playbook:

prepare:
    how: ansible
    playbook:
      - one.yml
      - two.yml
    extra-args: '-vvv'
prepare --how ansible --playbook one.yml --playbook two.yml --extra-args '-vvv'

Remote playbooks can be referenced as well as local ones, and both kinds can be intermixed:

prepare:
    how: ansible
    playbook:
      - https://foo.bar/one.yml
      - two.yml
prepare --how ansible --playbook https://foo.bar/two.yml --playbook two.yml

Store plugin name, data and parent step

cli_invocation: 'tmt.cli.CliInvocation' | None = None
go(*, guest: Guest, environment: Environment | None = None, logger: Logger) None

Prepare the guests

class tmt.steps.prepare.ansible.PrepareAnsibleData(name: str, how: str, order: int = 50, summary: Optional[str] = None, where: list[str] = <factory>, playbook: list[str] = <factory>, extra_args: Optional[str] = None)

Bases: PrepareStepData

extra_args: str | None = None
playbook: list[str]
classmethod pre_normalization(raw_data: _RawAnsibleStepData, logger: Logger) None

Called before normalization, useful for tweaking raw data

tmt.steps.prepare.distgit module

class tmt.steps.prepare.distgit.DistGitData(name: str, how: str, order: int = 60, summary: Optional[str] = None, where: list[str] = <factory>, source_dir: Optional[tmt.utils.Path] = None, phase_name: str = <factory>, install_builddeps: bool = False, require: list['tmt.base.DependencySimple'] = <factory>)

Bases: PrepareStepData

install_builddeps: bool = False
order: int = 60
phase_name: str
require: list[tmt.base.DependencySimple]
source_dir: Path | None = None
class tmt.steps.prepare.distgit.PrepareDistGit(*, discover: DiscoverPlugin[Any] | None = None, future_requires: PreparePlugin[Any] | None = None, future_recommends: PreparePlugin[Any] | None = None, **kwargs: Any)

Bases: PreparePlugin[DistGitData]

Companion to the discover-dist-git, place where rpmbuild -bp happens

Step is responsible: 1. Install required packages for the rpmbuild itself 2. Detect and install build requires 3. Patch sources 3. Call function of discover plugin to discover tests from patched sources

Store plugin name, data and parent step

cli_invocation: 'tmt.cli.CliInvocation' | None = None
go(*, guest: Guest, environment: Environment | None = None, logger: Logger) None

Prepare the guests for building rpm sources

tmt.steps.prepare.distgit.insert_to_prepare_step(discover_plugin: DiscoverPlugin[Any], sourcedir: Path) None

Single place to call when inserting PrepareDistGit from discover

tmt.steps.prepare.feature module

class tmt.steps.prepare.feature.EPEL(*, parent: PrepareFeature, guest: Guest, logger: Logger)

Bases: ToggleableFeature

Initialize feature data

NAME: str = 'epel'
cli_invocation: 'tmt.cli.CliInvocation' | None = None
disable() None
enable() None
class tmt.steps.prepare.feature.Feature(*, parent: PrepareFeature, guest: Guest, logger: Logger)

Bases: Common

Base class for feature prepare plugin implementations

Initialize feature data

NAME: str
cli_invocation: 'tmt.cli.CliInvocation' | None = None
class tmt.steps.prepare.feature.PrepareFeature(*, step: Step, data: StepDataT, workdir: Literal[True] | Path | None = None, logger: Logger)

Bases: PreparePlugin[PrepareFeatureData]

Enable or disable common features like repositories on the guest.

Example config:

prepare:
    how: feature
    epel: enabled

Or

prepare:
    how: feature
    epel: disabled

Store plugin name, data and parent step

cli_invocation: 'tmt.cli.CliInvocation' | None = None
go(*, guest: Guest, environment: Environment | None = None, logger: Logger) None

Prepare the guests

class tmt.steps.prepare.feature.PrepareFeatureData(name: str, how: str, order: int = 50, summary: Optional[str] = None, where: list[str] = <factory>, epel: Optional[str] = None)

Bases: PrepareStepData

epel: str | None = None
class tmt.steps.prepare.feature.ToggleableFeature(*, parent: PrepareFeature, guest: Guest, logger: Logger)

Bases: Feature

Initialize feature data

cli_invocation: 'tmt.cli.CliInvocation' | None = None
disable() None
enable() None
get_root_path() Path

Get the root path for getting the path of a playbook

tmt.steps.prepare.install module

class tmt.steps.prepare.install.Copr(*args: Any, guest: Guest, **kwargs: Any)

Bases: Common

Initialize name and relation with the parent object

Prepare the workdir for provided id / directory path or generate a new workdir name if workdir=True given. Store command line context and options for future use if context is provided.

cli_invocation: 'tmt.cli.CliInvocation' | None = None
copr_plugin: str
enable_copr(repositories: list[str]) None

Enable requested copr repositories

enable_copr_epel6(copr: str) None

Manually enable copr repositories for epel6

guest: Guest
class tmt.steps.prepare.install.InstallApt(*, parent: PrepareInstall, guest: Guest, dependencies: list[tmt.base.DependencySimple], directories: list[tmt.utils.Path], exclude: list[str], logger: Logger, **kwargs: Any)

Bases: InstallBase

Install packages using apt

Initialize installation data

cli_invocation: 'tmt.cli.CliInvocation' | None = None
install_debuginfo() None

Install debuginfo packages

install_from_repository() None

Install packages from a repository

install_from_url() None

Install packages stored on a remote URL

install_local() None

Install packages stored in a local directory

class tmt.steps.prepare.install.InstallBase(*, parent: PrepareInstall, guest: Guest, dependencies: list[tmt.base.DependencySimple], directories: list[tmt.utils.Path], exclude: list[str], logger: Logger, **kwargs: Any)

Bases: Common

Base class for installation implementations

Initialize installation data

cli_invocation: 'tmt.cli.CliInvocation' | None = None
debuginfo_packages: list[tmt.package_managers.Package]
exclude: list[tmt.package_managers.Package]
guest: Guest
install() None

Perform the actual installation

install_debuginfo() None

Default base install method for debuginfo packages

install_from_repository() None

Default base install method for packages from repositories

install_from_url() None

Default base install method for packages which are from URL

install_local() None

Default base install method for local packages

list_installables(title: str, *installables: Package | FileSystemPath | PackagePath | PackageUrl) Iterator[Package | FileSystemPath | PackagePath | PackageUrl]

Show package info and return package names

local_packages: list[tmt.package_managers.PackagePath]
package_directory: Path
packages: list[Union[tmt.package_managers.Package, tmt.package_managers.FileSystemPath]]
prepare_install_local() None

Copy packages to the test system

prepare_installables(dependencies: list[tmt.base.DependencySimple], directories: list[tmt.utils.Path]) None

Process package names and directories

prepare_repository() None

Configure additional repository

remote_packages: list[tmt.package_managers.PackageUrl]
rpm_check(package: str, mode: str = '-q') None

Run rpm command to check package existence Throws tmt.utils.RunError

skip_missing: bool = False
class tmt.steps.prepare.install.InstallDnf(*, parent: PrepareInstall, guest: Guest, dependencies: list[tmt.base.DependencySimple], directories: list[tmt.utils.Path], exclude: list[str], logger: Logger, **kwargs: Any)

Bases: InstallBase, Copr

Install packages using dnf

Initialize installation data

cli_invocation: 'tmt.cli.CliInvocation' | None = None
copr_plugin: str = 'dnf-plugins-core'
install_debuginfo() None

Install debuginfo packages

install_from_repository() None

Install packages from a repository

install_from_url() None

Install packages stored on a remote URL

install_local() None

Install packages stored in a local directory

class tmt.steps.prepare.install.InstallRpmOstree(*, parent: PrepareInstall, guest: Guest, dependencies: list[tmt.base.DependencySimple], directories: list[tmt.utils.Path], exclude: list[str], logger: Logger, **kwargs: Any)

Bases: InstallBase, Copr

Install packages using rpm-ostree

Initialize installation data

cli_invocation: 'tmt.cli.CliInvocation' | None = None
copr_plugin: str = 'dnf-plugins-core'
install_debuginfo() None

Install debuginfo packages

install_from_repository() None

Install packages from the repository

install_local() None

Install copied local packages

recommended_packages: list[Union[tmt.package_managers.Package, tmt.package_managers.FileSystemPath]]
required_packages: list[Union[tmt.package_managers.Package, tmt.package_managers.FileSystemPath]]
sort_packages() None

Identify required and recommended packages

class tmt.steps.prepare.install.InstallYum(*, parent: PrepareInstall, guest: Guest, dependencies: list[tmt.base.DependencySimple], directories: list[tmt.utils.Path], exclude: list[str], logger: Logger, **kwargs: Any)

Bases: InstallDnf

Install packages using yum

Initialize installation data

cli_invocation: 'tmt.cli.CliInvocation' | None = None
copr_plugin: str = 'yum-plugin-copr'
class tmt.steps.prepare.install.PrepareInstall(*, step: Step, data: StepDataT, workdir: Literal[True] | Path | None = None, logger: Logger)

Bases: PreparePlugin[PrepareInstallData]

Install packages on the guest.

Example config:

prepare:
    how: install
    copr: psss/tmt
    package: tmt-all
    missing: fail

Use copr for enabling desired Copr repository and missing to choose whether missing packages should be silently ignored (skip) or a preparation error should be reported (fail), which is the default.

In addition to package name you can also use one or more paths to local rpm files to be installed:

prepare:
    how: install
    package:
        - tmp/RPMS/noarch/tmt-0.15-1.fc31.noarch.rpm
        - tmp/RPMS/noarch/python3-tmt-0.15-1.fc31.noarch.rpm

Use directory to install all packages from given folder and exclude to skip selected packages:

prepare:
    how: install
    directory: tmp/RPMS/noarch
    exclude: tmt+provision-virtual

Note

When testing ostree booted deployments tmt will use rpm-ostree as the package manager to perform the installation of requested packages. The current limitations of the rpm-ostree implementation are:

  • Cannot install new version of already installed local rpm.

  • No support for installing debuginfo packages at this time.

Store plugin name, data and parent step

cli_invocation: 'tmt.cli.CliInvocation' | None = None
go(*, guest: Guest, environment: Environment | None = None, logger: Logger) None

Perform preparation for the guests

class tmt.steps.prepare.install.PrepareInstallData(name: str, how: str, order: int = 50, summary: Optional[str] = None, where: list[str] = <factory>, package: list[tmt.base.DependencySimple] = <factory>, directory: list[tmt.utils.Path] = <factory>, copr: list[str] = <factory>, exclude: list[str] = <factory>, missing: Literal['skip', 'fail'] = 'fail')

Bases: PrepareStepData

copr: list[str]
directory: list[tmt.utils.Path]
exclude: list[str]
missing: Literal['skip', 'fail'] = 'fail'
package: list[tmt.base.DependencySimple]

tmt.steps.prepare.shell module

class tmt.steps.prepare.shell.PrepareShell(*, step: Step, data: StepDataT, workdir: Literal[True] | Path | None = None, logger: Logger)

Bases: PreparePlugin[PrepareShellData]

Prepare guest using shell (Bash) scripts.

Run various commands and scripts on the guest:

prepare:
    how: shell
    script:
      - sudo dnf install -y 'dnf-command(copr)'
      - sudo dnf copr enable -y psss/tmt
      - sudo dnf install -y tmt

Store plugin name, data and parent step

cli_invocation: 'tmt.cli.CliInvocation' | None = None
go(*, guest: Guest, environment: Environment | None = None, logger: Logger) None

Prepare the guests

class tmt.steps.prepare.shell.PrepareShellData(name: str, how: str, order: int = 50, summary: Optional[str] = None, where: list[str] = <factory>, script: list[tmt.utils.ShellScript] = <factory>)

Bases: PrepareStepData

script: list[tmt.utils.ShellScript]
to_spec() dict[str, Any]

Convert to a form suitable for saving in a specification file

Module contents

class tmt.steps.prepare.Prepare(*, plan: Plan, data: _RawStepData | list[tmt.steps._RawStepData], logger: Logger)

Bases: Step

Prepare the environment for testing.

Use the ‘order’ attribute to select in which order preparation should happen if there are multiple configs. Default order is ‘50’. Default order of required packages installation is ‘70’, for the recommended packages it is ‘75’.

Initialize prepare step data

cli_invocation: 'tmt.cli.CliInvocation' | None = None
cli_invocations: list['tmt.cli.CliInvocation'] = []
go(force: bool = False) None

Prepare the guests

summary() None

Give a concise summary of the preparation

wake() None

Wake up the step (process workdir and command line)

class tmt.steps.prepare.PreparePlugin(*, step: Step, data: StepDataT, workdir: Literal[True] | Path | None = None, logger: Logger)

Bases: Plugin[PrepareStepDataT]

Common parent of prepare plugins

Store plugin name, data and parent step

classmethod base_command(usage: str, method_class: type[click.core.Command] | None = None) Command

Create base click command (common for all prepare plugins)

cli_invocation: 'tmt.cli.CliInvocation' | None = None
go(*, guest: Guest, environment: Environment | None = None, logger: Logger) None

Prepare the guest (common actions)

class tmt.steps.prepare.PrepareStepData(name: str, how: str, order: int = 50, summary: Optional[str] = None, where: list[str] = <factory>)

Bases: WhereableStepData, StepData