From 56f40bca0488238a074f8d4de1db9d7c954562e5 Mon Sep 17 00:00:00 2001 From: Lili Nie Date: Sun, 20 Oct 2024 23:42:08 -0400 Subject: [PATCH] Support `system.vendor-name` hardware requirement for `mrack` --- spec/hardware/system.fmf | 2 +- tests/unit/provision/mrack/test_hw.py | 9 ++++++++- tmt/steps/provision/mrack.py | 18 ++++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/spec/hardware/system.fmf b/spec/hardware/system.fmf index 06f9b2e045..04e38436ac 100644 --- a/spec/hardware/system.fmf +++ b/spec/hardware/system.fmf @@ -42,4 +42,4 @@ example: link: - implemented-by: /tmt/steps/provision/mrack.py - note: "``system.numa-nodes`` and ``system.model-name`` only" + note: "``system.vendor`` and ``system.model`` not implemented yet" diff --git a/tests/unit/provision/mrack/test_hw.py b/tests/unit/provision/mrack/test_hw.py index 277ef65e20..1db5369aeb 100644 --- a/tests/unit/provision/mrack/test_hw.py +++ b/tests/unit/provision/mrack/test_hw.py @@ -281,7 +281,14 @@ def test_maximal_constraint(root_logger: Logger) -> None: { 'and': [ {'or': []}, - {'or': []}, + { + 'system': { + 'vendor': { + '_op': 'like', + '_value': 'Dell%', + }, + }, + }, {'or': []}, { 'system': { diff --git a/tmt/steps/provision/mrack.py b/tmt/steps/provision/mrack.py index 3ec8b19f0f..606a146e5c 100644 --- a/tmt/steps/provision/mrack.py +++ b/tmt/steps/provision/mrack.py @@ -596,6 +596,23 @@ def _transform_system_model_name( children=[MrackHWBinOp('model', beaker_operator, actual_value)]) +def _transform_system_vendor_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('vendor', beaker_operator, actual_value)]) + ]) + + return MrackHWGroup('system', + children=[MrackHWBinOp('vendor', beaker_operator, actual_value)]) + + ConstraintTransformer = Callable[[ tmt.hardware.Constraint[Any], tmt.log.Logger], MrackBaseHWElement] @@ -626,6 +643,7 @@ def _transform_system_model_name( '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] + 'system.vendor_name': _transform_system_vendor_name, # type: ignore[dict-item] 'iommu.is_supported': _transform_iommu_is_supported, # type: ignore[dict-item] }