33from navmazing import NavigateToSibling
44from wait_for import wait_for
55
6+ from airgun .entities .all_hosts import AllHostsEntity
67from airgun .entities .host import HostEntity
78from airgun .navigation import NavigateStepWithWait as NavigateStep , navigator
9+ from airgun .views .all_hosts import AllHostsTableView
810from airgun .views .cloud_insights import RemediateSummary
911from airgun .views .fact import HostFactView
10- from airgun .views .host import HostsView as LegacyHostsView
12+ from airgun .views .host import HostsJobInvocationStatusView , HostsView as LegacyHostsView
1113from airgun .views .host_new import (
1214 AllAssignedRolesView ,
1315 ContainerfileInstallCommandView ,
1416 EditAnsibleRolesView ,
1517 EditSystemPurposeView ,
1618 EnableTracerView ,
17- HostsView ,
1819 InstallPackagesView ,
1920 ManageHostCollectionModal ,
2021 ManageHostStatusesView ,
@@ -351,6 +352,72 @@ def schedule_job(self, entity_name, values):
351352 view .fill (values )
352353 view .submit .click ()
353354
355+ def schedule_remote_job (self , entities_list , values , timeout = 60 , wait_for_results = True ):
356+ """Apply Schedule Remote Job action to the hosts names in entities_list using PF5 UI.
357+
358+ For multiple hosts, uses AllHostsEntity helper to select checkboxes, then clicks
359+ "Schedule a job" button which opens the wizard with hosts pre-selected.
360+
361+ :param entities_list: The host names to apply the remote job.
362+ :param values: the values to fill The Job invocation view.
363+ :param timeout: The time to wait for the job to finish.
364+ :param wait_for_results: Whether to wait for the job to finish execution.
365+
366+ :returns: The job invocation status view values
367+ """
368+ if len (entities_list ) == 1 :
369+ # Single host - use the host details page approach
370+ entity_name = entities_list [0 ]
371+ details_view = self .navigate_to (self , 'NewDetails' , entity_name = entity_name )
372+ self .browser .plugin .ensure_page_safe ()
373+ details_view .wait_displayed ()
374+ # Click the Schedule a job dropdown
375+ self .browser .wait_for_element (details_view .schedule_job , exception = False )
376+ details_view .schedule_job .fill ('Schedule a job' )
377+ # The job invocation form appears in the same browser context
378+ view = JobInvocationCreateView (self .browser )
379+ self .browser .plugin .ensure_page_safe ()
380+ else :
381+ # Multiple hosts - use AllHostsEntity helper to navigate and select hosts
382+ # This helper handles: clearing previous selections, searching, selecting checkboxes
383+ # and returns AllHostsTableView with selected hosts
384+ hosts_view = AllHostsEntity .all_hosts_navigate_and_select_hosts_helper (
385+ self , host_names = entities_list
386+ )
387+
388+ # After selecting hosts, click the "Schedule a job" button
389+ # This button appears dynamically after hosts are selected
390+ schedule_button_locator = ".//button[contains(., 'Schedule a job') or @data-ouia-component-id='schedule-a-job-dropdown']"
391+ wait_for (
392+ lambda : hosts_view .browser .element (schedule_button_locator , check_visibility = True ),
393+ timeout = 10 ,
394+ delay = 0.5 ,
395+ handle_exception = True ,
396+ )
397+ schedule_button = hosts_view .browser .element (schedule_button_locator )
398+ hosts_view .browser .click (schedule_button )
399+
400+ # The job invocation form should now open with hosts pre-selected
401+ view = JobInvocationCreateView (self .browser )
402+ self .browser .plugin .ensure_page_safe ()
403+ # Wait for the wizard to be displayed
404+ view .wait_displayed ()
405+
406+ # Fill the form with provided values
407+ view .fill (values )
408+ # Wait for form to be fully filled and ready for submission
409+ self .browser .plugin .ensure_page_safe ()
410+ view .submit .click ()
411+ view .flash .assert_no_error ()
412+ view .flash .dismiss ()
413+ # Wait for status view to appear after job submission
414+ status_view = HostsJobInvocationStatusView (self .browser )
415+ self .browser .plugin .ensure_page_safe ()
416+ status_view .wait_displayed ()
417+ if wait_for_results :
418+ status_view .wait_for_result (timeout = timeout )
419+ return status_view .read ()
420+
354421 def run_job (self , entity_name ):
355422 """Run a job on selected host"""
356423 view = self .navigate_to (self , 'NewDetails' , entity_name = entity_name )
@@ -1228,7 +1295,7 @@ def get_content_view_envs(self, entity_name):
12281295class ShowAllHosts (NavigateStep ):
12291296 """Navigate to new UI All Hosts page"""
12301297
1231- VIEW = HostsView
1298+ VIEW = AllHostsTableView
12321299
12331300 def step (self , * args , ** kwargs ):
12341301 self .view .menu .select ('Hosts' , 'All Hosts' )
@@ -1249,6 +1316,7 @@ def prerequisite(self, *args, **kwargs):
12491316
12501317 def step (self , * args , ** kwargs ):
12511318 entity_name = kwargs .get ('entity_name' )
1319+
12521320 self .parent .search (entity_name )
12531321 self .parent .table .row (name = entity_name )['Name' ].widget .click ()
12541322
0 commit comments