Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add product files for physical server dashboard widgets #17172

Merged
merged 10 commits into from
Apr 9, 2018
11 changes: 11 additions & 0 deletions app/models/physical_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class PhysicalServer < ApplicationRecord

scope :with_hosts, -> { where("physical_servers.id in (select hosts.physical_server_id from hosts)") }

virtual_column :v_availability, :type => :string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should add :uses => :host to both of these lines to force eager loading. This'll prevent n+1 queries when the widgets are generated.

virtual_column :v_host_os, :type => :string

def name_with_details
details % {
:name => name,
Expand Down Expand Up @@ -91,4 +94,12 @@ def refresh_ems
end
EmsRefresh.queue_refresh(self)
end

def v_availability
host.try(:physical_server_id).nil? ? N_("Available") : N_("In use")
end

def v_host_os
host.try(:vmm_product).nil? ? N_("") : host.vmm_product
end
end
18 changes: 18 additions & 0 deletions product/dashboard/widgets/chart_server_availability.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
description: chart_server_availability
title: "Physical Server Availability"
content_type: chart
options:
:timezone_matters: false
visibility:
:roles:
- _ALL_
user_id:
resource_name: Physical Server Availability
resource_type: MiqReport
miq_schedule_options:
:run_at:
:interval:
:value: "1"
:unit: hourly
enabled: true
read_only: true
18 changes: 18 additions & 0 deletions product/dashboard/widgets/chart_server_health.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
description: chart_server_health
title: "Physical Server Health"
content_type: chart
options:
:timezone_matters: false
visibility:
:roles:
- _ALL_
user_id:
resource_name: Physical Server Health
resource_type: MiqReport
miq_schedule_options:
:run_at:
:interval:
:value: "1"
:unit: hourly
enabled: true
read_only: true
18 changes: 18 additions & 0 deletions product/dashboard/widgets/rss_newest_servers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
description: rss_newest_servers
title: "Recently Discovered Physical Servers"
content_type: report
options:
:row_count: 5
visibility:
:roles:
- _ALL_
user_id:
resource_name: Recently Discovered Physical Servers
resource_type: MiqReport
miq_schedule_options:
:run_at:
:interval:
:value: "1"
:unit: hourly
enabled: true
read_only: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
title: Recently Discovered Physical Servers
rpt_group: Custom
rpt_type: Custom
priority:
db: PhysicalServer
cols:
- hostname
- health_state
- power_state
- product_name
include: {}
col_order:
- hostname
- health_state
- power_state
- product_name
headers:
- Hostname
- Health State
- Power State
- Product Name
conditions:
order: Ascending
sortby:
- hostname
group:
graph:
dims:
filename:
file_mtime:
categories: []
timeline:
template_type: report
where_clause:
db_options: {}
generate_cols:
generate_rows:
col_formats:
-
-
-
-
-
-
tz:
time_profile_id:
display_filter:
col_options: {}
rpt_options:
:pdf:
:page_size: US-Letter
:queue_timeout:
menu_name: Recently Discovered Physical Servers
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
title: Physical Server Health
conditions:
order: Ascending
graph:
:type: Pie
:count: 10
:other: true
menu_name: Physical Server Health
rpt_group: Custom
rpt_type: Custom
priority:
col_order:
- hostname
- health_state
- power_state
- product_name
timeline:
file_mtime:
categories:
filename:
db: PhysicalServer
cols:
- hostname
- health_state
- power_state
- product_name
template_type: report
sortby:
- health_state
- hostname
headers:
- Hostname
- Health State
- Power State
- Product Name
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
title: Physical Server Availability
order: Ascending
graph:
:type: Pie
:count: 10
:other: true
menu_name: Physical Server Availability
rpt_group: Custom
rpt_type: Custom
priority:
col_order:
- hostname
- v_availability
- health_state
- power_state
- v_host_os
- product_name
timeline:
file_mtime:
categories:
filename:
db: PhysicalServer
cols:
- hostname
- v_availability
- health_state
- power_state
- v_host_os
- product_name
template_type: report
sortby:
- v_availability
- hostname
headers:
- Hostname
- Availability
- Health State
- Power State
- Host OS
- Product Name
2 changes: 1 addition & 1 deletion spec/models/miq_report/seeding_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe MiqReport do
context "Seeding" do
include_examples(".seed called multiple times", 140)
include_examples(".seed called multiple times", 143)
end
end
2 changes: 1 addition & 1 deletion spec/models/miq_widget_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
describe MiqWidget do
describe '.seed' do
before { [MiqReport, RssFeed].each(&:seed) }
include_examples(".seed called multiple times", 21)
include_examples(".seed called multiple times", 24)
end

before do
Expand Down