Skip to content

Commit

Permalink
[RTT-5270] Add support for kernel selection on aarch64
Browse files Browse the repository at this point in the history
  • Loading branch information
You-never-know committed Nov 21, 2023
1 parent 1acbca8 commit cd51fac
Showing 1 changed file with 47 additions and 1 deletion.
48 changes: 47 additions & 1 deletion anabot/runtime/installation/hub/software_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
from fnmatch import fnmatchcase

from anabot.conditions import is_distro_version
from anabot.runtime.decorators import make_prefixed_handle_action, make_prefixed_handle_check
from anabot.runtime.decorators import make_prefixed_handle_action, make_prefixed_handle_check, check_action_result
from anabot.runtime.default import default_handler, action_result
from anabot.runtime.functions import get_attr, getnode, getnode_scroll, getnodes, getparent, getsibling, disappeared, scrollto
from anabot.runtime.comps import reload_comps, get_comps
from anabot.runtime.hooks import register_post_hook
from anabot.runtime.errors import TimeoutError
from anabot.runtime.translate import tr, comps_tr_env, comps_tr_group, comps_tr_env_desc, comps_tr_group_rev, comps_tr_group_desc, comps_tr_env_rev
from anabot.runtime.installation.common import done_handler
from anabot.runtime.actionresult import NotFoundResult, ActionResultPass, ActionResultFail

_local_path = '/installation/hub/software_selection'
handle_act = make_prefixed_handle_action(_local_path)
Expand All @@ -30,6 +31,12 @@
__selected_addons = None

PACKAGE_SELECTION_STORE = '/mnt/sysimage/root/anabot-packageset.txt'
DEFAULT_KERNEL_OPTION = "4k"
kernel_options = {
"4k": "4k\nMore efficient memory usage in smaller environments",
"64k": "64k\nSystem performance gains for memory-intensive workloads",
}

@register_post_hook(None)
def record_package_selection():
if __selected_environment is None and __selected_addons is None:
Expand Down Expand Up @@ -216,3 +223,42 @@ def addon_check(element, app_node, local_node):
if action_result(element)[0] == False:
return action_result(element)
return addon_handler_manipulate(element, app_node, local_node, True)
@handle_act('/kernel_options')
def kernel_options_handler(element, app_node, local_node):
chosen_kernel_option = get_attr(element, "value")
if chosen_kernel_option is None:
return ActionResultFail("No kernel options specified in the anabot recipe.")
try:
kernel_combo_box = getnode(local_node, "combo box",
tr(DEFAULT_KERNEL_OPTION, context="GUI|Software Selection|Kernel Options"))
except TimeoutError:
return NotFoundResult(f"Kernel Options combo box named {DEFAULT_KERNEL_OPTION}",
where="Software Selection Spoke.")
# Open the combo box window by clicking on the combo box
kernel_combo_box.click()
try:
kernel_option_window = getnode(app_node, "window")
except TimeoutError:
return NotFoundResult("the opened 'Kernel Options' window", where="Software Selection Spoke.")
# The wanted kernel option node is specified by its full name, so we need to get it in order for anabot to find it
kernel_option_full_name = kernel_options.get(chosen_kernel_option, None)
try:
kernel_option_menu_item = getnode(kernel_option_window, "menu item",
tr(kernel_option_full_name, context="GUI|Software Selection|Kernel Options"))
except TimeoutError:
return NotFoundResult(chosen_kernel_option, where="Kernel Options combo box")
kernel_option_menu_item.click()
return ActionResultPass()

@handle_chck('/kernel_options')
@check_action_result
def kernel_options_check(element, app_node, local_node):
chosen_kernel_option = get_attr(element, "value")
try:
# The combo box has the name of the chosen option, so we can use it to check which is selected
# We do not need to use the found combo box
_ = getnode(local_node, "combo box",
tr(chosen_kernel_option, context="GUI|Software Selection|Kernel Options"))
except TimeoutError:
return ActionResultFail(f"{chosen_kernel_option} kernel option is not selected")
return ActionResultPass()

0 comments on commit cd51fac

Please sign in to comment.