tmt.steps.prepare.feature package

Submodules

tmt.steps.prepare.feature.crb module

class tmt.steps.prepare.feature.crb.Crb(*args: Any, **kwargs: Any)

Bases: ToggleableFeature

Enable or disable the CodeReady Builder (CRB) repository:

prepare:
    how: feature
    crb: enabled
prepare --how feature --crb enabled

Added in version 1.49.

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.

FEATURE_NAME: str = 'crb'
cli_invocation: 'tmt.cli.CliInvocation' | None = None
classmethod disable(guest: Guest, logger: Logger) None
classmethod enable(guest: Guest, logger: Logger) None
class tmt.steps.prepare.feature.crb.CrbStepData(name: str, how: str, order: int = 50, when: list[str] = <factory>, summary: str | None = None, where: list[str] = <factory>, crb: str | None = None)

Bases: PrepareFeatureData

crb: str | None = None

tmt.steps.prepare.feature.environment_profile module

tmt.steps.prepare.feature.environment_profile.PLAYBOOK_NAME = 'apply'

The name of a playbook provided by the collection. This name is part of the Testing Farm profile specification.

class tmt.steps.prepare.feature.environment_profile.Profile(*args: Any, **kwargs: Any)

Bases: Feature

Prepare guest setup with a guest profile.

Note

Guest profiles are being developed, once there is an agreed upon text we could steal^Wborrow^Wreuse, we shall add it to this docstring.

Guest profiles represent a particular setup of guest environment as defined by a CI system or service. They are implemented as Ansible roles, and packaged as Ansible collections. The CI systems use profiles to set up guests before testing, and users may use the same profiles to establish the same environment locally when developing tests or reprodcing issues.

Apply a profile to the guest:

prepare:
    how: feature
    profile: testing_farm.fedora_ci
prepare --how feature --profile testing_farm.fedora_ci

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.

FEATURE_NAME: str = 'profile'
NAME = 'profile'
cli_invocation: 'tmt.cli.CliInvocation' | None = None
classmethod enable(guest: Guest, value: str, logger: Logger) None
class tmt.steps.prepare.feature.environment_profile.ProfileStepData(name: str, how: str, order: int = 50, when: list[str] = <factory>, summary: str | None = None, where: list[str] = <factory>, profile: str | None = None)

Bases: PrepareFeatureData

profile: str | None = None

tmt.steps.prepare.feature.epel module

class tmt.steps.prepare.feature.epel.Epel(*args: Any, **kwargs: Any)

Bases: ToggleableFeature

Control Extra Packages for Enterprise Linux (EPEL) repository.

EPEL is an initiative within the Fedora Project to provide high quality additional packages for CentOS Stream and Red Hat Enterprise Linux (RHEL).

Enable or disable EPEL repository on the guest:

prepare:
    how: feature
    epel: enabled
prepare --how feature --epel enabled

Note

This plugin requires the following Ansible modules be installed on the runner:

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.

FEATURE_NAME: str = 'epel'
PLAYBOOKS: set[str] = {'epel-disable.yaml', 'epel-enable.yaml'}
cli_invocation: 'tmt.cli.CliInvocation' | None = None
classmethod disable(guest: Guest, logger: Logger) None
classmethod enable(guest: Guest, logger: Logger) None
class tmt.steps.prepare.feature.epel.EpelStepData(name: str, how: str, order: int = 50, when: list[str] = <factory>, summary: str | None = None, where: list[str] = <factory>, epel: str | None = None)

Bases: PrepareFeatureData

epel: str | None = None

tmt.steps.prepare.feature.fips module

class tmt.steps.prepare.feature.fips.Fips(*args: Any, **kwargs: Any)

Bases: ToggleableFeature

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.

FEATURE_NAME: str = 'fips'
PLAYBOOKS: set[str] = {'fips-enable.yaml'}
cli_invocation: 'tmt.cli.CliInvocation' | None = None
classmethod disable(guest: Guest, logger: Logger) None
classmethod enable(guest: Guest, logger: Logger) None
class tmt.steps.prepare.feature.fips.FipsStepData(name: str, how: str, order: int = 50, when: list[str] = <factory>, summary: str | None = None, where: list[str] = <factory>, fips: str | None = None)

Bases: PrepareFeatureData

fips: str | None = None

Module contents

tmt.steps.prepare.feature.ANSIBLE_MODULE_NAME_PATTERN = re.compile('.+\\..+\\..+')

A pattern for matching module-like keys in Ansible playbooks.

tmt.steps.prepare.feature.ANSIBLE_MODULE_NOTE_TEMPLATE = "\n.. note::\n\n    This plugin requires the following Ansible modules be installed\n    on the runner:\n\n    {% for module in MODULES %}\n    * `{{ module }}`__\n    {% endfor %}\n\n    {% for module in MODULES %}\n        {% set module_components = module.split('.', 2) %}\n    __ https://docs.ansible.com/ansible/latest/collections/{{ module_components[0] }}/{{ module_components[1] }}/{{ module_components[2] }}_module.html\n    {% endfor %}\n"

A template for “used modules” note for plugin docstrings.

class tmt.steps.prepare.feature.Feature(*args: Any, **kwargs: Any)

Bases: FeatureBase

Base class for feature plugins that enable a feature

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
abstractmethod classmethod enable(guest: Guest, value: str, logger: Logger) None
class tmt.steps.prepare.feature.FeatureBase(*args: Any, **kwargs: Any)

Bases: Common

Base class for feature plugins

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.

FEATURE_NAME: str
PLAYBOOKS: set[str] = {}
cli_invocation: 'tmt.cli.CliInvocation' | None = None
classmethod get_data_class() type[PrepareFeatureData]

Return step data class for this plugin.

By default, _data_class is returned, but plugin may override this method to provide different class.

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

Bases: PreparePlugin[PrepareFeatureData]

Easily enable and disable common features

The feature plugin provides a comfortable way to enable and disable some commonly used functionality such as enabling and disabling the epel repository or the fips mode.

Note

The plugin requires a working Ansible to be available on the test runner.

Warning

The plugin may be a subject of various limitations, imposed by the fact it uses Ansible to implement some of the features:

  • Ansible 2.17+ no longer supports Python 3.6 and older. Guests where Python 3.7+ is not available cannot be prepared with the feature plugin. This has been observed when Fedora Rawhide runner is used with CentOS 7 or CentOS Stream 8 guests. Possible workarounds: downgrade Ansible tmt uses, or install Python 3.7+ before using feature plugin from an alternative repository or local build.

prepare:
    how: feature
    epel: disabled
    crb: enabled
    fips: enabled
    ...
prepare --how feature --epel disabled --crb enabled --fips enabled ...

Note

Features available via this plugin are implemented and shipped as plugins too. The list of available features and configuration keys will depend on which plugins you have installed.

Store plugin name, data and parent step

cli_invocation: 'tmt.cli.CliInvocation' | None = None
essential_requires() list[DependencySimple | DependencyFmfId | DependencyFile]

Collect all essential requirements of the plugin.

Essential requirements of a plugin are necessary for the plugin to perform its basic functionality.

Returns:

a list of requirements.

classmethod get_data_class() type[PrepareFeatureData]

Return step data class for this plugin.

prepare/feature builds the class in a dynamic way: class’ fields are defined by discovered feature plugins. Plugins define their own data classes, these are collected, their fields extracted and merged together with the base data class fields (name, order, …) into the final data class of prepare/feature plugin.

go(*, guest: Guest, environment: Environment | None = None, logger: Logger) PluginOutcome

Prepare the guests

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

Bases: PrepareStepData

classmethod unserialize_class() Any

Provide the actual class to unserialize.

In some situations, the class recorded in the serialized state cannot be safely unserialized. Such classes may reimplement this method, and return the right class.

class tmt.steps.prepare.feature.ToggleableFeature(*args: Any, **kwargs: Any)

Bases: FeatureBase

Base class for feature plugins that enable/disable a feature

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
abstractmethod classmethod disable(guest: Guest, logger: Logger) None
abstractmethod classmethod enable(guest: Guest, logger: Logger) None
tmt.steps.prepare.feature.find_plugin(name: str) type[FeatureBase]

Find a plugin by its name.

Raises:

GeneralError – when the plugin does not exist.

tmt.steps.prepare.feature.provides_feature(feature: str) Callable[[type[FeatureBase]], type[FeatureBase]]

A decorator for registering feature plugins.

Decorate a feature plugin class to register a feature:

@provides_feature('foo')
class Foo(ToggleableFeature):
    ...

Decorator also inspects plugins FeatureBase.PLAYBOOKS, gathers all Ansible modules from listed playbooks, and adds a note to plugin’s docstring reminding user about their necessity on the runner.