Skip to content

Commit

Permalink
Support system.model-name hardware requirement for mrack
Browse files Browse the repository at this point in the history
  • Loading branch information
skycastlelily committed Oct 11, 2024
1 parent 3f51582 commit 23a227c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
25 changes: 24 additions & 1 deletion tests/unit/provision/mrack/test_hw.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,14 @@ def test_maximal_constraint(root_logger: Logger) -> None:
},
},
},
{'or': []},
{
'system': {
'model': {
'_op': 'like',
'_value': 'PowerEdge R750',
},
},
},
]
},
{
Expand Down Expand Up @@ -864,3 +871,19 @@ def test_system_numa_nodes(root_logger: Logger) -> None:
}
}
}


def test_system_model_name(root_logger: Logger) -> None:
result = _CONSTRAINT_TRANSFORMERS['system.model_name'](
_parse_system({'model-name': '!~ PowerEdge R750.*'}), root_logger)

assert result.to_mrack() == {
'not': {
'system': {
'model': {
'_op': 'like',
'_value': 'PowerEdge R750%'
}
}
}
}
18 changes: 18 additions & 0 deletions tmt/steps/provision/mrack.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,23 @@ def _transform_system_numa_nodes(
children=[MrackHWBinOp('numanodes', beaker_operator, actual_value)])


def _transform_system_model_name(
constraint: tmt.hardware.NumberConstraint,
logger: tmt.log.Logger) -> MrackBaseHWElement:
beaker_operator, actual_value, negate = operator_to_beaker_op(
constraint.operator,
str(constraint.value))

if negate:
return MrackHWNotGroup(children=[
MrackHWGroup('system',
children=[MrackHWBinOp('model', beaker_operator, actual_value)])
])

return MrackHWGroup('system',
children=[MrackHWBinOp('model', beaker_operator, actual_value)])


ConstraintTransformer = Callable[[
tmt.hardware.Constraint[Any], tmt.log.Logger], MrackBaseHWElement]

Expand Down Expand Up @@ -595,6 +612,7 @@ def _transform_system_numa_nodes(
'zcrypt.adapter': _transform_zcrypt_adapter, # type: ignore[dict-item]
'zcrypt.mode': _transform_zcrypt_mode, # type: ignore[dict-item]
'system.numa_nodes': _transform_system_numa_nodes, # type: ignore[dict-item]
'system.model_name': _transform_system_model_name, # type: ignore[dict-item]
'iommu.is_supported': _transform_iommu_is_supported, # type: ignore[dict-item]
}

Expand Down

0 comments on commit 23a227c

Please sign in to comment.