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

Fixed titles and labels for Hosts & Clusters Openstack Providers #1560

Merged
merged 2 commits into from
Jun 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,15 @@
$scope.clusterCpuUsage = infraChartsMixin.processHeatmapData($scope.clusterCpuUsage, data.heatmaps.clusterCpuUsage);
$scope.clusterCpuUsage.loadingDone = true;

$scope.clusterChartTitle = data.heatmaps.title;
$scope.clusterMemoryUsage =
infraChartsMixin.processHeatmapData($scope.clusterMemoryUsage, data.heatmaps.clusterMemoryUsage);
$scope.clusterMemoryUsage.loadingDone = true;

// Recent Hosts
$scope.recentHostsConfig = infraChartsMixin.chartConfig.recentHostsConfig;
$scope.recentHostsConfig.headTitle = data.recentHosts.title;
$scope.recentHostsConfig.label = data.recentHosts.label;

// recent Hosts chart
$scope.recentHostsData = infraChartsMixin.processRecentHostsData(data.recentHosts,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ angular.module('miq.util').factory('infraDashboardUtilsFactory', function() {
};
var createClustersStatus = function() {
return {
title: __("Clusters"),
iconClass: " pficon pficon-cluster",
count: 0,
notification: {}
};
};
var createHostsStatus = function() {
return {
title: __("Hosts"),
iconClass: "pficon pficon-screen",
count: 0,
notification: {}
Expand Down Expand Up @@ -51,6 +49,10 @@ angular.module('miq.util').factory('infraDashboardUtilsFactory', function() {
statusObject.notification = {};
if (data) {
statusObject.count = data.count;
if (data.title) {
statusObject.title = data.title;
}

if (data.errorCount > 0) {
statusObject.notification = {
iconClass: "pficon pficon-error-circle-o",
Expand Down
62 changes: 36 additions & 26 deletions app/services/ems_infra_dashboard_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,21 @@ def all_data
end

def status
{
status_hsh = {
:ems_clusters => {
:title => openstack? ? _('Deplyoment Roles') : _('Cluster'),
:count => @ems.present? ? @ems.ems_clusters.count : EmsCluster.count,
:errorCount => 0,
:warningCount => 0,
:href => get_url_to_entity(:ems_cluster)
},
:hosts => {
:title => openstack? ? _('Nodes') : _('Hosts'),
:count => @ems.present? ? @ems.hosts.count : Host.where.not(:ext_management_system => nil).count,
:errorCount => 0,
:warningCount => 0,
:href => get_url_to_entity(:host)
},
:datastores => {
:count => @ems.present? ? @ems.storages.count : Storage.count,
:errorCount => 0,
:warningCount => 0,
:href => get_url_to_entity(:storage)
},
:vms => {
:count => @ems.present? ? @ems.vms.count : VmInfra.where.not(:ext_management_system => nil).count,
:errorCount => 0,
Expand All @@ -54,6 +50,16 @@ def status
:href => get_url_to_entity(:miq_template)
}
}
unless openstack?
status_hsh[:datastores] = {
:count => @ems.present? ? @ems.storages.count : Storage.count,
:errorCount => 0,
:warningCount => 0,
:href => get_url_to_entity(:storage)
}
end

status_hsh
end

def providers
Expand Down Expand Up @@ -124,42 +130,42 @@ def heatmaps

{
:clusterCpuUsage => cluster_cpu_usage.presence,
:clusterMemoryUsage => cluster_memory_usage.presence
:clusterMemoryUsage => cluster_memory_usage.presence,
:title => openstack? ? _('Deplyoment Roles Utilization') : _('Cluster Utilization')
}
end

def recentHosts
# Get recent hosts
all_hosts = Hash.new(0)
hosts = Host.where('created_on > ? and ems_id = ?', 30.days.ago.utc, @ems.id)
hosts = hosts.includes(:resource => [:ext_management_system]) unless @ems.present?
hosts.sort_by { |h| h.created_on }.uniq.each do |h|
date = h.created_on.strftime("%Y-%m-%d")
all_hosts[date] += Host.where('created_on = ?', h.created_on).count
end

{
all_hosts = recentRecords(Host)
{
:xData => all_hosts.keys,
:yData => all_hosts.values.map
:yData => all_hosts.values.map,
:title => openstack? ? _('Recent Nodes') : _('Recent Hosts'),
:label => openstack? ? _('Nodes') : _('Hosts'),
}
end

def recentVms
# Get recent VMs
all_vms = Hash.new(0)
vms = VmOrTemplate.where('created_on > ? and ems_id = ?', 30.days.ago.utc, @ems.id)
vms = vms.includes(:resource => [:ext_management_system]) unless @ems.present?
vms.sort_by { |v| v.created_on }.uniq.each do |v|
date = v.created_on.strftime("%Y-%m-%d")
all_vms[date] += VmOrTemplate.where('created_on = ?', v.created_on).count
end

all_vms = recentRecords(VmOrTemplate)
{
:xData => all_vms.keys,
:yData => all_vms.values.map
}
end

def recentRecords(model)
all_records = Hash.new(0)
records = model.where('created_on > ? and ems_id = ?', 30.days.ago.utc, @ems.id)
records = records.includes(:resource => [:ext_management_system]) unless @ems.present?
records.sort_by { |r| r.created_on }.uniq.each do |r|
date = r.created_on.strftime("%Y-%m-%d")
all_records[date] += model.where('created_on = ?', r.created_on).count
end
all_records
end

def ems_utilization
used_cpu = Hash.new(0)
used_mem = Hash.new(0)
Expand Down Expand Up @@ -205,4 +211,8 @@ def daily_provider_metrics
.where(:resource => (@ems || ManageIQ::Providers::InfraManager.all))
.where('timestamp > ?', 30000.days.ago.utc).order('timestamp')
end

def openstack?
@ems.kind_of?(ManageIQ::Providers::Openstack::InfraManager)
end
end
15 changes: 8 additions & 7 deletions app/views/ems_infra/_show_dashboard.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@
"show-top-border" => "true",
:status => "objectStatus.hosts",
:url => "navigation"}
.col-xs-6.col-sm-6.col-md-3
%div{:layout => "mini",
"pf-aggregate-status-card" => "",
"show-top-border" => "true",
:status => "objectStatus.datastores",
:url => "navigation"}
- unless @ems.kind_of?(ManageIQ::Providers::Openstack::InfraManager)
.col-xs-6.col-sm-6.col-md-3
%div{:layout => "mini",
"pf-aggregate-status-card" => "",
"show-top-border" => "true",
:status => "objectStatus.datastores",
:url => "navigation"}
.col-xs-6.col-sm-6.col-md-3
%div{:layout => "mini",
"pf-aggregate-status-card" => "",
Expand Down Expand Up @@ -75,7 +76,7 @@
:heatmaps => "heatmaps",
"heatmaps-card" => "",
:hidetopborder => "true",
:title => _("Cluster Utilization")}
"title" => "{{clusterChartTitle}}"}
.row.row-tile-pf.row-tile-pf-last
.col-xs-12.col-sm-6.col-md-6
%div{"head-title" => "{{recentHostsConfig.headTitle}}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@
"clusterCpuUsage": null,
"clusterMemoryUsage": null
},
"recentHosts": {
"title": "Recent Hosts",
"label": "hosts",
"xData": [
"2015-11-26"
],
"yData": [
3
]
},
"providers": [
{
"count": 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@
}
]
},
"recentHosts": {
"title": "Recent Hosts",
"label": "hosts",
"xData": [
"2015-11-26"
],
"yData": [
3
]
},
"providers": [
{
"count": 1,
Expand Down