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

feat: Add translantion for kernel_options and kernel_options_post #299

Merged
merged 1 commit into from
Oct 30, 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
40 changes: 40 additions & 0 deletions src/mrack/transformers/beaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,44 @@ def _get_ks_meta(self, host):
)
return res

def _get_kernel_options(self, host):
"""
Get `kernel_options` value from host or config or default if not defined.

The priority is following:
- host
- provisioning-config.yaml
- default from provisioning config
- empty if not defined in provisioning config

"""
res = self._find_value(
host.get(CONFIG_KEY, {}),
"kernel_options",
"kernel_options",
host["os"],
)
return res

def _get_kernel_options_post(self, host):
"""
Get `kernel_options_post` value from host or config or default if not defined.

The priority is following:
- host
- provisioning-config.yaml
- default from provisioning config
- empty if not defined in provisioning config

"""
res = self._find_value(
host.get(CONFIG_KEY, {}),
"kernel_options_post",
"kernel_options_post",
host["os"],
)
return res

def _construct_ks_append_script(self, ks_append, pubkeys=None):
"""Create ks_appdend from requirements."""
res_ks_list = []
Expand Down Expand Up @@ -167,6 +205,8 @@ def create_host_requirement(self, host):
"arch": host.get("arch", "x86_64"),
"variant": variant,
"ks_meta": self._get_ks_meta(host),
"kernel_options": self._get_kernel_options(host),
"kernel_options_post": self._get_kernel_options_post(host),
"retention_tag": self._find_value(
host.get(CONFIG_KEY, {}),
"retention_tag",
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/test_beaker_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class TestBeakerTransformer:
"restraint_id": 1,
"beaker": {
"ks_meta": "FEDORA_HOST_KS_META",
"kernel_options": "FEDORA_KERNEL_OPTIONS",
"kernel_options_post": "FEDORA_KERNEL_OPTIONS_POST",
"ks_append": {
"pre-install": "%pre\npre_dummy\n%end",
"script": "script_dummy",
Expand Down Expand Up @@ -193,6 +195,8 @@ async def create_transformer(self, legacy=False):
"variant": "Server",
"ks_meta": "FEDORA_HOST_KS_META",
"ks_append": maximal_ksappend,
"kernel_options": "FEDORA_KERNEL_OPTIONS",
"kernel_options_post": "FEDORA_KERNEL_OPTIONS_POST",
"whiteboard": default_whiteboard,
"priority": default_prio,
"tasks": [
Expand Down Expand Up @@ -289,6 +293,8 @@ async def test_beaker_requirement(
"variant",
"ks_meta",
"ks_append",
"kernel_options",
"kernel_options_post",
"whiteboard",
"priority",
"tasks",
Expand Down
Loading