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 ,
@@ -349,6 +350,57 @@ def schedule_job(self, entity_name, values):
349350 view .fill (values )
350351 view .submit .click ()
351352
353+ def schedule_remote_job (self , entities_list , values , timeout = 60 , wait_for_results = True ):
354+ """Apply Schedule Remote Job action to the hosts names in entities_list using PF5 UI.
355+
356+ For multiple hosts, uses AllHostsEntity helper to select checkboxes, then clicks
357+ "Schedule a job" button which opens the wizard with hosts pre-selected.
358+
359+ :param entities_list: The host names to apply the remote job.
360+ :param values: the values to fill The Job invocation view.
361+ :param timeout: The time to wait for the job to finish.
362+ :param wait_for_results: Whether to wait for the job to finish execution.
363+
364+ :returns: The job invocation status view values
365+ """
366+ if len (entities_list ) == 1 :
367+ entity_name = entities_list [0 ]
368+ details_view = self .navigate_to (self , 'NewDetails' , entity_name = entity_name )
369+ self .browser .plugin .ensure_page_safe ()
370+ details_view .wait_displayed ()
371+ self .browser .wait_for_element (details_view .schedule_job , exception = False )
372+ details_view .schedule_job .fill ('Schedule a job' )
373+ view = JobInvocationCreateView (self .browser )
374+ self .browser .plugin .ensure_page_safe ()
375+ else :
376+ hosts_view = AllHostsEntity .all_hosts_navigate_and_select_hosts_helper (
377+ self , host_names = entities_list
378+ )
379+ schedule_button_locator = ".//button[contains(., 'Schedule a job') or @data-ouia-component-id='schedule-a-job-dropdown']"
380+ wait_for (
381+ lambda : hosts_view .browser .element (schedule_button_locator , check_visibility = True ),
382+ timeout = 10 ,
383+ delay = 0.5 ,
384+ handle_exception = True ,
385+ )
386+ schedule_button = hosts_view .browser .element (schedule_button_locator )
387+ hosts_view .browser .click (schedule_button )
388+ view = JobInvocationCreateView (self .browser )
389+ self .browser .plugin .ensure_page_safe ()
390+ view .wait_displayed ()
391+
392+ view .fill (values )
393+ self .browser .plugin .ensure_page_safe ()
394+ view .submit .click ()
395+ view .flash .assert_no_error ()
396+ view .flash .dismiss ()
397+ status_view = HostsJobInvocationStatusView (self .browser )
398+ self .browser .plugin .ensure_page_safe ()
399+ status_view .wait_displayed ()
400+ if wait_for_results :
401+ status_view .wait_for_result (timeout = timeout )
402+ return status_view .read ()
403+
352404 def run_job (self , entity_name ):
353405 """Run a job on selected host"""
354406 view = self .navigate_to (self , 'NewDetails' , entity_name = entity_name )
@@ -1231,7 +1283,7 @@ def get_content_view_envs(self, entity_name):
12311283class ShowAllHosts (NavigateStep ):
12321284 """Navigate to new UI All Hosts page"""
12331285
1234- VIEW = HostsView
1286+ VIEW = AllHostsTableView
12351287
12361288 def step (self , * args , ** kwargs ):
12371289 self .view .menu .select ('Hosts' , 'All Hosts' )
@@ -1252,6 +1304,7 @@ def prerequisite(self, *args, **kwargs):
12521304
12531305 def step (self , * args , ** kwargs ):
12541306 entity_name = kwargs .get ('entity_name' )
1307+
12551308 self .parent .search (entity_name )
12561309 self .parent .table .row (name = entity_name )['Name' ].widget .click ()
12571310
0 commit comments