Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse the disk.sector-size hardware requirement #2972

Merged
merged 6 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions spec/hardware/disk.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ description: |
# String, disk driver requested.
- driver: "well-known disk driver"

# Number or string, logical sector size.
# Bytes are assumed when no unit is specified.
- logical-sector-size: 512|">= 512"

# Number or string, physical sector size.
# Bytes are assumed when no unit is specified.
- physical-sector-size: 4096|">= 4096"

The :ref:`/spec/plans/guest-topology` may include the following
fields in its description of the actual guest hardware:

Expand Down Expand Up @@ -60,11 +68,13 @@ example:
model-name: PERC H310
driver: megaraid_sas
block-device: /dev/sda
logical-sector-size: "512 byte"

- size: 21474836480
model-name: PERC H310
driver: megaraid_sas
block-device: /dev/sdb
physical-sector-size: "4096 byte"

link:
- implemented-by: /tmt/steps/provision/artemis.py
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/provision/mrack/test_hw.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ def test_maximal_constraint(root_logger: Logger) -> None:
}
}
},
{'or': []},
{
'disk': {
'model': {
Expand All @@ -195,6 +196,7 @@ def test_maximal_constraint(root_logger: Logger) -> None:
}
}
},
{'or': []},
{
'key_value': {
'_key': 'BOOTDISK',
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/test_hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,10 @@ def test_normalize_invalid_hardware(
disk:
- size: 40 GiB
model-name: "~ WD 100G.*"
physical-sector-size: "4096 byte"
- size: 120 GiB
driver: virtblk
logical-sector-size: "512 byte"
gpu:
device-name: G86 [Quadro NVS 290]
device: "97"
Expand Down Expand Up @@ -277,9 +279,11 @@ def test_parse_maximal_constraint() -> None:
- and:
- and:
- disk[0].size: == 40 GiB
- disk[0].physical-sector-size: == 4096 B
- disk[0].model-name: ~ WD 100G.*
- and:
- disk[1].size: == 120 GiB
- disk[1].logical-sector-size: == 512 B
- disk[1].driver: == virtblk
- and:
- and:
Expand Down
8 changes: 6 additions & 2 deletions tmt/hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,7 @@ def _parse_size_constraints(

return [
SizeConstraint.from_specification(
f'{prefix}.{constraint_name}',
f'{prefix}.{constraint_name.replace("-", "_")}',
str(spec[constraint_name]),
allowed_operators=[
Operator.EQ, Operator.NEQ, Operator.LT, Operator.LTE, Operator.GT, Operator.GTE])
Expand Down Expand Up @@ -1169,7 +1169,11 @@ def _parse_disk(spec: Spec, disk_index: int) -> BaseConstraint:

group = And()

group.constraints += _parse_size_constraints(spec, f'disk[{disk_index}]', ('size',))
group.constraints += _parse_size_constraints(spec,
f'disk[{disk_index}]',
('size',
'physical-sector-size',
'logical-sector-size'))
group.constraints += _parse_text_constraints(spec,
f'disk[{disk_index}]', ('model-name', 'driver'))

happz marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
9 changes: 9 additions & 0 deletions tmt/schemas/provision/hardware.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,15 @@ definitions:
driver:
type: string

logical-sector-size:
anyOf:
- type: string
- type: integer

physical-sector-size:
anyOf:
- type: string
- type: integer
additionalProperties: false

# enforce at least one property - we don't care which one, but we don't want
Expand Down
Loading