Skip to content

Commit

Permalink
Define Beaker pool HW requirement
Browse files Browse the repository at this point in the history
Related to #2346
  • Loading branch information
happz committed Jun 28, 2024
1 parent 1bc2cb9 commit fc48e5c
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
21 changes: 21 additions & 0 deletions spec/hardware/beaker.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
summary: |
Select or provision a guest with Beaker-specific parameters.

.. note::

The requirements are consumed by Beaker-aware ``provision``
plugins only, and cannot be enforced in any other
infrastructure.

description: |
.. code-block::

beaker:
# String, name of the Beaker pool to use for provisioning.
pool: "some-pool"

example:
- |
# Select any system, as long as it is not from the given Beaker pool
beaker:
pool: "!= very-rare-machines"
1 change: 1 addition & 0 deletions tests/unit/provision/mrack/test_hw.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def test_maximal_constraint(root_logger: Logger) -> None:

assert result.to_mrack() == {
'and': [
{'or': []},
{'or': []},
{
'and': [
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/test_hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ def test_normalize_invalid_hardware(


FULL_HARDWARE_REQUIREMENTS = """
beaker:
pool: "!= foo.*"
boot:
method: bios
compatible:
Expand Down Expand Up @@ -219,6 +221,7 @@ def test_normalize_invalid_hardware(
def test_parse_maximal_constraint() -> None:
hw_spec_out = """
and:
- beaker.pool: '!= foo.*'
- boot.method: contains bios
- and:
- compatible.distro: contains rhel-7
Expand Down
19 changes: 19 additions & 0 deletions tmt/hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -1340,6 +1340,22 @@ def _parse_location(spec: Spec) -> BaseConstraint:
return group


@ungroupify
def _parse_beaker(spec: Spec) -> BaseConstraint:
"""
Parse constraints related to the ``beaker`` HW requirement.
:param spec: raw constraint block specification.
:returns: block representation as :py:class:`BaseConstraint` or one of its subclasses.
"""

group = And()

group.constraints += _parse_text_constraints(spec, 'beaker', ('pool',))

return group


@ungroupify
def _parse_generic_spec(spec: Spec) -> BaseConstraint:
"""
Expand All @@ -1358,6 +1374,9 @@ def _parse_generic_spec(spec: Spec) -> BaseConstraint:
spec['arch'])
]

if 'beaker' in spec:
group.constraints += [_parse_beaker(spec['beaker'])]

if 'boot' in spec:
group.constraints += [_parse_boot(spec['boot'])]

Expand Down

0 comments on commit fc48e5c

Please sign in to comment.