From: Jan Provaznik<jprovazn(a)redhat.com>
task #1634 (
https://www.aeolusproject.org/redmine/issues/1634)
displays last_error messages for failed instances for now
---
src/app/controllers/pools_controller.rb | 3 ++-
src/app/views/pools/_alerts_index.haml | 7 +++++++
src/app/views/pools/_pretty_list.haml | 1 +
src/app/views/pools/index.haml | 1 +
src/features/pool.feature | 7 +++++++
5 files changed, 18 insertions(+), 1 deletions(-)
create mode 100644 src/app/views/pools/_alerts_index.haml
diff --git a/src/app/controllers/pools_controller.rb
b/src/app/controllers/pools_controller.rb
index 1222aa0..dfb4c36 100644
--- a/src/app/controllers/pools_controller.rb
+++ b/src/app/controllers/pools_controller.rb
@@ -227,12 +227,13 @@ class PoolsController< ApplicationController
def statistics
instances = Instance.list_for_user(current_user, Privilege::VIEW)
+ @failed_instances = instances.select {|instance| instance.state ==
Instance::STATE_CREATE_FAILED || instance.state == Instance::STATE_ERROR}
@statistics = {
:pools_in_use => @user_pools.collect { |pool|
pool.instances.pending.count> 0 || pool.instances.deployed.count> 0 }.count,
:deployments => Deployment.list_for_user(current_user,
Privilege::VIEW).count,
:instances => instances.count,
:instances_pending => instances.select {|instance| instance.state ==
Instance::STATE_NEW || instance.state == Instance::STATE_PENDING}.count,
- :instances_failed => instances.select {|instance| instance.state ==
Instance::STATE_CREATE_FAILED || instance.state == Instance::STATE_ERROR}.count
+ :instances_failed => @failed_instances.count
}
end
end
diff --git a/src/app/views/pools/_alerts_index.haml
b/src/app/views/pools/_alerts_index.haml
new file mode 100644
index 0000000..631f381
--- /dev/null
+++ b/src/app/views/pools/_alerts_index.haml
@@ -0,0 +1,7 @@
+- if @failed_instances.count> 0
+ %div.alerts
+ Alerts
+ %ul
+ - @failed_instances.each do |i|
+ %li
+ = "#{i.name}: #{i.last_error.blank? ? i.state : i.last_error}"
diff --git a/src/app/views/pools/_pretty_list.haml
b/src/app/views/pools/_pretty_list.haml
index 72eba48..ffe6db1 100644
--- a/src/app/views/pools/_pretty_list.haml
+++ b/src/app/views/pools/_pretty_list.haml
@@ -1,4 +1,5 @@
= link_to "expand all", "#", :class => "reveal_all"
+= link_to "New Pool", new_pool_path
%table#pools_pretty_view
- @pools.each do |pool|
%tr
diff --git a/src/app/views/pools/index.haml b/src/app/views/pools/index.haml
index 35fcd43..4d2db04 100644
--- a/src/app/views/pools/index.haml
+++ b/src/app/views/pools/index.haml
@@ -1,5 +1,6 @@
= render :partial => 'header_index'
= render :partial => 'scoreboard_index'
+= render :partial => 'alerts_index'
= link_to "Pretty View", pools_path(:view => 'pretty'), :id
=>'pretty_view'
= link_to "Filtred View", pools_path(:view => 'filter'), :id
=> 'filtred_view'
%div#view
diff --git a/src/features/pool.feature b/src/features/pool.feature
index 6c88c69..24d6443 100644
--- a/src/features/pool.feature
+++ b/src/features/pool.feature
@@ -172,3 +172,10 @@ Feature: Manage Pools
When I follow "Pretty View"
Then I should not see "Pools" within "#view"
And I should see "expand all"
+
+ Scenario: Display alerts
+ Given There is a mock pulp repository
+ And there is a "fail1" failed instance
+ When I go to the pools page
+ Then I should see "Alerts"
+ And I should see "fail1: error"
ACK
--
No trees were killed to send this message, but a large number of
electrons were terribly inconvenienced.