From 4895ad72c6e66984f8175c55237b2c04d9dddfb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Hul=C3=A1n?= Date: Thu, 11 May 2017 10:42:26 +0200 Subject: [PATCH] Fixes #19334 - consider out of date as ok --- .../foreman_virt_who_configure/configs_helper.rb | 12 +++--------- app/models/foreman_virt_who_configure/config.rb | 9 +++++---- .../_foreman_virt_who_configs_status_widget.html.erb | 2 +- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/app/helpers/foreman_virt_who_configure/configs_helper.rb b/app/helpers/foreman_virt_who_configure/configs_helper.rb index 809a1cb3..7fc02b8a 100644 --- a/app/helpers/foreman_virt_who_configure/configs_helper.rb +++ b/app/helpers/foreman_virt_who_configure/configs_helper.rb @@ -26,9 +26,7 @@ def config_report_status(config) message = case config.status when :unknown _('No Report Yet') - when :ok - l(config.last_report_at, :format => :long) - when :error + when :ok, :out_of_date l(config.last_report_at, :format => :long) else _('Unknown configuration status') @@ -43,10 +41,8 @@ def config_report_status_icon(config) def report_status_class(status) icon_class = case status - when :ok + when :ok, :out_of_date 'pficon-ok' - when :error - 'pficon-error-circle-o' when :unknown 'pficon-info' else @@ -58,12 +54,10 @@ def report_status_class(status) def status_class(status) case status - when :ok + when :ok, :out_of_date 'status-ok'.html_safe when :unknown 'status-info'.html_safe - when :error - 'status-error'.html_safe else 'status-warn'.html_safe end diff --git a/app/models/foreman_virt_who_configure/config.rb b/app/models/foreman_virt_who_configure/config.rb index 2bb655e6..8c17949b 100644 --- a/app/models/foreman_virt_who_configure/config.rb +++ b/app/models/foreman_virt_who_configure/config.rb @@ -49,7 +49,7 @@ class Config < ActiveRecord::Base STATUSES = { 'ok' => N_('OK'), - 'error' => N_('Error'), + 'out_of_date' => N_('No change'), 'unknown' => N_('Unknown') } @@ -57,7 +57,7 @@ class Config < ActiveRecord::Base { :unknown => N_('The configuration was not deployed yet or the virt-who was unable to report the status'), :ok => N_('The virt-who report arrived within the interval'), - :error => N_('The virt-who report has not arrived within the interval, please check the virt-who reporter status and logs') + :out_of_date => N_('The virt-who report has not arrived within the interval, which indicates there was no change on hypervisor') } ) @@ -107,7 +107,7 @@ def self.search_by_status(key, operator, value) sanitize_sql_for_conditions([' out_of_date_at >= ? ', DateTime.now.utc.to_s(:db)]) when 'unknown' sanitize_sql_for_conditions({:last_report_at => nil}) - when 'error' + when 'out_of_date' sanitize_sql_for_conditions([' out_of_date_at < ? ', DateTime.now.utc.to_s(:db)]) end { :conditions => condition } @@ -188,7 +188,8 @@ def status when !self.out_of_date? :ok else - :error + # out of date is currently considered ok too, virt-who does not send any report if there's no change on hypervisor + :out_of_date end end diff --git a/app/views/dashboard/_foreman_virt_who_configs_status_widget.html.erb b/app/views/dashboard/_foreman_virt_who_configs_status_widget.html.erb index 2eeb763e..5043cecd 100644 --- a/app/views/dashboard/_foreman_virt_who_configs_status_widget.html.erb +++ b/app/views/dashboard/_foreman_virt_who_configs_status_widget.html.erb @@ -16,7 +16,7 @@ <%= scope.where(:last_report_at => nil).count %> - <%= link_to _("Out Of Date"), foreman_virt_who_configure_configs_path(:search => "status = error") %> + <%= link_to _("Out Of Date"), foreman_virt_who_configure_configs_path(:search => "status = out_of_date") %> <%= out_of_date.count %>