Skip to content

Commit

Permalink
feat: Add translantion for kernel_options and kernel_options_post
Browse files Browse the repository at this point in the history
  • Loading branch information
skycastlelily committed Oct 25, 2024
1 parent f65f5ec commit 2281399
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
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

0 comments on commit 2281399

Please sign in to comment.