Skip to content

Commit

Permalink
Support disk.driver hw requirement for mrack
Browse files Browse the repository at this point in the history
  • Loading branch information
skycastlelily authored and psss committed Mar 8, 2024
1 parent d91f41a commit 4b3da6d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
4 changes: 2 additions & 2 deletions docs/releases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ tmt-1.32

The hardware specification for :ref:`/spec/hardware/disk` has been
extended with the new keys ``driver`` and ``model-name``. Users
can provision Beaker guests with a given disk model using the
:ref:`/spec/plans/provision/beaker` plugin.
can provision Beaker guests with a given disk model or driver using
the :ref:`/spec/plans/provision/beaker` plugin.

The :ref:`/spec/plans/provision/virtual` provision plugin gains support
for :ref:`TPM hardware requirement</spec/hardware/tpm>`. It is limited
Expand Down
1 change: 0 additions & 1 deletion spec/hardware/disk.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,5 @@ link:
- implemented-by: /tmt/steps/provision/artemis.py
note: "``size`` only"
- implemented-by: /tmt/steps/provision/mrack.py
note: "``size`` and ``model-name`` only"
- implemented-by: /tmt/steps/provision/testcloud.py
note: "``size`` only with ``=``, ``>=`` and ``<=`` operators only"
30 changes: 30 additions & 0 deletions tmt/steps/provision/mrack.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class GuestInspectType(TypedDict):
'cpu.model',
'disk.size',
'disk.model_name',
'disk.driver',
'hostname',
'memory',
'virtualization.is_virtualized'
Expand Down Expand Up @@ -146,6 +147,20 @@ def __init__(self, name: str, operator: str, value: str) -> None:
}


@dataclasses.dataclass(init=False)
class MrackHWKeyValue(MrackHWElement):
""" A key-value element """

def __init__(self, name: str, operator: str, value: str) -> None:
super().__init__('key_value')

self.attributes = {
'_key': name,
'_op': operator,
'_value': value
}


@dataclasses.dataclass
class MrackHWGroup(MrackBaseHWElement):
"""
Expand Down Expand Up @@ -288,6 +303,21 @@ def constraint_to_beaker_filter(
'disk',
children=[MrackHWBinOp('model', beaker_operator, actual_value)])

if name == "disk" and child_name == 'driver':
beaker_operator, actual_value, negate = operator_to_beaker_op(
constraint.operator,
constraint.value)

if negate:
return MrackHWNotGroup(children=[
MrackHWKeyValue('BOOTDISK', beaker_operator, actual_value)
])

return MrackHWKeyValue(
'BOOTDISK',
beaker_operator,
actual_value)

if name == "cpu":
if child_name == 'flag':
beaker_operator = OPERATOR_SIGN_TO_OPERATOR[tmt.hardware.Operator.EQ] \
Expand Down

0 comments on commit 4b3da6d

Please sign in to comment.