On 12/13/2011 03:08 PM, Tomas Hrcka wrote:
---
src/app/controllers/instances_controller.rb | 22 ++++++++++++++++++++++
src/app/views/instances/_list.html.haml | 1 +
src/config/locales/en.yml | 2 ++
src/config/routes.rb | 1 +
4 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/src/app/controllers/instances_controller.rb
b/src/app/controllers/instances_controller.rb
index 5979a1c..e302c3d 100644
--- a/src/app/controllers/instances_controller.rb
+++ b/src/app/controllers/instances_controller.rb
@@ -178,6 +178,28 @@ class InstancesController< ApplicationController
do_operation(:reboot)
end
+ def multi_reboot
+ notices = ""
+ errors = ""
+ Instance.find(params[:instance_selected] || []).each do |instance|
+ begin
+ require_privilege(Privilege::USE,instance)
+ instance.reboot
+ notices<< "#{instance.name}:
#{t('instances.flash.notice.reboot')}"
This generates strings like
"My F15 deployment/My F15 Template: %{name}:
reboot action was successfully queued."
So it should be replaced with something like:
notices<< "#{instance.name}: #{t('instances.flash.notice.reboot',
:name => instance.name)}"
+ rescue Exception => err
+ errors<< "#{instance.name}: " + err
+ end
+ end
+ # If nothing is selected, display an error message:
+ errors = t('instances.none_selected_to_reboot') if errors.blank?&&
notices.blank?
+ flash[:notice] = notices unless notices.blank?
+ flash[:error] = errors unless errors.blank?
+ respond_to do |format|
+ format.html { redirect_to params[:backlink] || pools_path(:view =>
'filter', :details_tab => 'instances') }
+ format.json { render :json => {:success => notices, :errors => errors}
}
+ end
+ end
+
def filter
redirect_to_original({"instances_preset_filter" =>
params[:instances_preset_filter], "instances_search" =>
params[:instances_search]})
end
diff --git a/src/app/views/instances/_list.html.haml
b/src/app/views/instances/_list.html.haml
index 8e68a2b..6b5a21a 100644
--- a/src/app/views/instances/_list.html.haml
+++ b/src/app/views/instances/_list.html.haml
@@ -1,6 +1,7 @@
- content_for :form_header do
%li= link_to "#{t'instances.list.export_events'}",
export_events_instances_path, :class => 'button'
%li= restful_submit_tag
"#{t'instances.list.stop_selected_instances'}", 'stop',
multi_stop_instances_path, 'GET', :class => 'button', :id =>
'stop_selected_instances'
+ %li= restful_submit_tag
"#{t'instances.list.reboot_selected_instances'}", 'reboot',
multi_reboot_instances_path, 'GET', :class => 'button', :id =>
'reboot_selected_instances'
= hidden_field_tag 'backlink', request.url
- content_for :filter_controls do
diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml
index 99050d5..1f771cf 100644
--- a/src/config/locales/en.yml
+++ b/src/config/locales/en.yml
@@ -268,6 +268,7 @@ en:
reboot: Reboot
instance: Instance
none_selected: "You must select one or more instances to stop."
+ none_selected_to_reboot: "You must select one or more instances to
reboot."
tab_captions:
properties: Properties
history: History
@@ -275,6 +276,7 @@ en:
list:
export_events: Export events
stop_selected_instances: Stop selected instances
+ reboot_selected_instances: Reboot selected instances
stopped_instances_hidden: Stopped instances are hidden
showing_all_instances: Showing all instances
show_all: show all
diff --git a/src/config/routes.rb b/src/config/routes.rb
index 09e96be..94e87e8 100644
--- a/src/config/routes.rb
+++ b/src/config/routes.rb
@@ -118,6 +118,7 @@ Conductor::Application.routes.draw do
collection do
get 'start'
get 'multi_stop'
+ get 'multi_reboot'
get 'remove_failed'
get 'export_events'
post 'filter'
ACK, note inline.