From de40362272ccb85932b2882ad5bfc59afc25c784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hellebrandt?= Date: Mon, 20 May 2024 14:37:28 +0200 Subject: [PATCH] Basic host statuses page (#1384) (cherry picked from commit 53e2b8ecca9c0ab4f1fea119f44eb479d46fbbf3) --- airgun/entities/host.py | 24 ++++++++++++++++++++++++ airgun/views/host.py | 14 ++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/airgun/entities/host.py b/airgun/entities/host.py index 4e550120c..4ae4b8d4b 100644 --- a/airgun/entities/host.py +++ b/airgun/entities/host.py @@ -25,6 +25,7 @@ HostsDeleteTaskDetailsView, HostsJobInvocationCreateView, HostsJobInvocationStatusView, + HostStatusesView, HostsUnassignCompliancePolicy, HostsView, RecommendationListView, @@ -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 @@ -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') diff --git a/airgun/views/host.py b/airgun/views/host.py index 2e6ccce15..960c4e20c 100644 --- a/airgun/views/host.py +++ b/airgun/views/host.py @@ -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')