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 committed Mar 5, 2024
1 parent c1e75f7 commit b89608d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
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 @@ -48,6 +48,7 @@ class GuestInspectType(TypedDict):
'cpu.model',
'disk.size',
'disk.model_name',
'disk.driver',
'hostname',
'memory',
'virtualization.is_virtualized'
Expand Down Expand Up @@ -145,6 +146,20 @@ def __init__(self, name: str, operator: str, value: str) -> None:
}


@dataclasses.dataclass(init=False)
class MrackHWKeyValue(MrackHWElement):
""" An 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 @@ -247,6 +262,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 == 'hostname':
assert isinstance(constraint.value, str)

Expand Down

0 comments on commit b89608d

Please sign in to comment.