Skip to content

Commit

Permalink
squash: rebase, remove warning
Browse files Browse the repository at this point in the history
  • Loading branch information
skycastlelily authored and happz committed Jul 1, 2024
1 parent bf40427 commit 0294a54
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 18 deletions.
10 changes: 4 additions & 6 deletions spec/hardware/location.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ description: |
.. versionchanged:: 1.33
Added ``location.lab-controller`` into specification.

.. warning::

Because of Beaker limitation, ``~`` and ``!~`` operators commonly used with text-like
HW requirements cannot be used with ``lab-controller``. Only ``==`` and ``!=``
operators are supported.

example:
- |
# Select a system that is not managed lab-01.foo.bar.com lab controller
location:
lab-controller: "!= lab-01.foo.bar.com"

link:
- implemented-by: /tmt/steps/provision/mrack.py
note: "``==`` and ``!=`` operators only"
11 changes: 5 additions & 6 deletions tests/unit/provision/mrack/test_hw.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,9 @@ def test_maximal_constraint(root_logger: Logger) -> None:
{
'labcontroller': {
'_op': '!=',
'_value': 'lab-01.rhts.eng.pek2.redhat.com'
'_value': 'lab-1.bar.redhat.com'
}
},
{'or': []},
{
'and': [
{'or': []},
Expand Down Expand Up @@ -688,21 +687,21 @@ def test_zcrypt_mode(root_logger: Logger) -> None:
def test_location_lab_controller(root_logger: Logger) -> None:

result = _CONSTRAINT_TRANSFORMERS['location.lab_controller'](
_parse_location({"lab-controller": "lab-01.rhts.eng.pek2.redhat.com"}), root_logger)
_parse_location({"lab-controller": "lab-01.bar.redhat.com"}), root_logger)

assert result.to_mrack() == {
'labcontroller': {
'_op': '==',
'_value': 'lab-01.rhts.eng.pek2.redhat.com'
'_value': 'lab-01.bar.redhat.com'
}
}

result = _CONSTRAINT_TRANSFORMERS['location.lab_controller'](
_parse_location({"lab-controller": "!= lab-01.rhts.eng.pek2.redhat.com"}), root_logger)
_parse_location({"lab-controller": "!= lab-01.bar.redhat.com"}), root_logger)

assert result.to_mrack() == {
'labcontroller': {
'_op': '!=',
'_value': 'lab-01.rhts.eng.pek2.redhat.com'
'_value': 'lab-01.bar.redhat.com'
}
}
7 changes: 1 addition & 6 deletions tmt/hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -1335,12 +1335,7 @@ def _parse_location(spec: Spec) -> BaseConstraint:

group = And()

group.constraints += _parse_text_constraints(spec,
'location',
('lab-controller',
),
[Operator.EQ,
Operator.NEQ])
group.constraints += _parse_text_constraints(spec, 'location', ('lab-controller',))

return group

Expand Down
3 changes: 3 additions & 0 deletions tmt/steps/provision/mrack.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,9 @@ def _transform_zcrypt_mode(
def _transform_location_lab_controller(
constraint: tmt.hardware.TextConstraint,
logger: tmt.log.Logger) -> MrackBaseHWElement:
if constraint.operator not in [tmt.hardware.Operator.EQ, tmt.hardware.Operator.NEQ]:
raise ProvisionError(
f"Cannot apply hardware requirement '{constraint}', operator not supported.")
beaker_operator, actual_value, negate = operator_to_beaker_op(
constraint.operator,
constraint.value)
Expand Down

0 comments on commit 0294a54

Please sign in to comment.