Skip to content

Commit

Permalink
Basic host statuses page (#1384) (#1388)
Browse files Browse the repository at this point in the history
(cherry picked from commit 53e2b8e)

Co-authored-by: Lukáš Hellebrandt <[email protected]>
  • Loading branch information
Satellite-QE and lhellebr authored Jun 3, 2024
1 parent 6b6423e commit 467902f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
24 changes: 24 additions & 0 deletions airgun/entities/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
HostsDeleteTaskDetailsView,
HostsJobInvocationCreateView,
HostsJobInvocationStatusView,
HostStatusesView,
HostsUnassignCompliancePolicy,
HostsView,
RecommendationListView,
Expand Down Expand Up @@ -248,6 +249,19 @@ def export(self):
view.export.click()
return self.browser.save_downloaded_file()

def host_statuses(self):
view = self.navigate_to(self, 'Host Statuses')
view.wait_displayed()
statuses = []
view.status_green_total.wait_displayed()
statuses.append({'name': 'green_total', 'count': view.status_green_total.read()})
statuses.append({'name': 'green_owned', 'count': view.status_green_owned.read()})
statuses.append({'name': 'yellow_total', 'count': view.status_yellow_total.read()})
statuses.append({'name': 'yellow_owned', 'count': view.status_yellow_owned.read()})
statuses.append({'name': 'red_total', 'count': view.status_red_total.read()})
statuses.append({'name': 'red_owned', 'count': view.status_red_owned.read()})
return statuses

def schedule_remote_job(self, entities_list, values, timeout=60, wait_for_results=True):
"""Apply Schedule Remote Job action to the hosts names in entities_list
Expand Down Expand Up @@ -544,3 +558,13 @@ def prerequisite(self, *args, **kwargs):
def step(self, *args, **kwargs):
"""Open the Manage columns dialog"""
self.parent.manage_columns.click()


@navigator.register(HostEntity, 'Host Statuses')
class HostStatuses(NavigateStep):

VIEW = HostStatusesView

def step(self, *args, **kwargs):
"""Navigate to Monitor -> Host Statuses"""
self.view.menu.select('Monitor', 'Host Statuses')
14 changes: 14 additions & 0 deletions airgun/views/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,20 @@ def is_displayed(self):
return self.browser.wait_for_element(self.title, visible=True, exception=False) is not None


class HostStatusesView(BaseLoggedInView):
title = Text("//h5[normalize-space(.)='Host Status Overview']")
status_green_total = Text("//div[contains(@class, 'status-count')][1]/a[1]")
status_green_owned = Text("//div[contains(@class, 'status-count')][1]/a[2]")
status_yellow_total = Text("//div[contains(@class, 'status-count')][2]/span[1]")
status_yellow_owned = Text("//div[contains(@class, 'status-count')][2]/span[2]")
status_red_total = Text("//div[contains(@class, 'status-count')][3]/a[1]")
status_red_owned = Text("//div[contains(@class, 'status-count')][3]/a[2]")

@property
def is_displayed(self):
return self.browser.wait_for_element(self.title, exception=False) is not None


class HostsView(BaseLoggedInView, SearchableViewMixinPF4):
title = Text("//h1[normalize-space(.)='Hosts']")
manage_columns = PF4Button('manage-columns-button')
Expand Down

0 comments on commit 467902f

Please sign in to comment.