Skip to content
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
85 changes: 85 additions & 0 deletions spec/hardware/preset.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
summary: |
Reference predefined hardware configurations from external preset files.

description: |
.. code-block:: yaml

provision:
hardware:
import-preset:
- https://github.com/my-team/project/presets.yaml
- file:///home/user/config/tmt/presets.yaml
- ~/.config/tmt/presets.yaml
preset: BIG_MEMORY
cpu:
model: 97

In the example above, both the ``BIG_MEMORY`` preset and the
``cpu.model: 97`` constraint must be satisfied — sibling keys under
``hardware`` are combined with implicit ``and`` glue.

Rules:
Comment thread
happz marked this conversation as resolved.

* ``import-preset`` is allowed only at the top level of the ``hardware``
key.

* ``import-preset`` accepts a single string or a list of strings. Each
string identifies a preset source and is interpreted automatically:

* An ``http://`` or ``https://`` URL — fetched remotely.
Comment thread
therazix marked this conversation as resolved.
* A ``file://`` URL — read from the given absolute local path.
* Any other string — treated as a local file path (absolute, relative,
or using ``~`` for the home directory).

* ``preset`` is a string referencing a single named preset. To apply
multiple presets, combine them with ``and`` (or ``or``).

Preset files use YAML format with a dictionary mapping preset names to
their hardware definitions:

.. code-block:: yaml

# presets.yaml
AMD__ROME:
cpu:
family: 23
model: 49
MEMORY_MIN_64G:
memory: ">= 64 GB"
Comment thread
psss marked this conversation as resolved.

example:
- |
# Use a remote preset
provision:
hardware:
import-preset: https://github.com/my-team/presets.yaml
preset: AMD__ROME
- |
# Use a local preset file
Comment thread
LecrisUT marked this conversation as resolved.
provision:
hardware:
import-preset: ~/.config/tmt/presets.yaml
preset: BIG_MEMORY
- |
# Use a local preset file via file:// URL
provision:
hardware:
import-preset: file:///home/user/config/tmt/presets.yaml
preset: BIG_MEMORY
- |
# Combine multiple presets and additional constraints
provision:
hardware:
import-preset:
- https://github.com/my-team/project/presets.yaml
- file:///home/user/config/tmt/presets.yaml
- ~/.config/tmt/presets.yaml
and:
- preset: AMD__ROME
- preset: BIG_MEMORY
- cpu:
model: 97

# NOTE: not yet supported
# link:
# - implemented-by: /tmt/steps/provision/artemis.py
12 changes: 12 additions & 0 deletions tmt/schemas/hardware-preset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---

#
# JSON Schema definition for tmt hardware preset files
#

$id: /schemas/hardware-preset
$schema: https://json-schema.org/draft-07/schema

type: object
additionalProperties:
$ref: "/schemas/provision/hardware#/definitions/hardware"
Loading