Signed-off-by: Ohad Levy <ohadlevy@gmail.com>
···
--- app/controllers/hosts_controller.rb | 16 +++++++++++++++- app/helpers/hosts_helper.rb | 1 + app/views/hosts/multiple_puppetrun.html.erb | 5 +++++ config/routes.rb | 2 ++ vendor/plugins/proxy/lib/proxy.rb | 4 ++-- 5 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 app/views/hosts/multiple_puppetrun.html.erbdiff --git a/app/controllers/hosts_controller.rb b/app/controllers/hosts_controller.rb
index b8294e4…bd848c2 100644
— a/app/controllers/hosts_controller.rb
+++ b/app/controllers/hosts_controller.rb
@@ -15,7 +15,7 @@ class HostsController < ApplicationController
before_filter :find_multiple, :only => [:update_multiple_parameters, :multiple_build,
:select_multiple_hostgroup, :select_multiple_environment, :multiple_parameters, :multiple_destroy,
:multiple_enable, :multiple_disable, :submit_multiple_disable, :submit_multiple_enable, :update_multiple_hostgroup,
- :update_multiple_environment, :submit_multiple_build, :submit_multiple_destroy]
- :update_multiple_environment, :submit_multiple_build, :submit_multiple_destroy, :update_multiple_puppetrun, :multiple_puppetrun]
before_filter :find_by_name, :only => %w[show edit update destroy puppetrun setBuild cancelBuild report
reports facts storeconfig_klasses clone pxe_config toggle_manage]
@@ -338,6 +338,20 @@ class HostsController < ApplicationController
toggle_hostmode
end
-
def multiple_puppetrun
-
return deny_access unless Setting[:puppetrun]
-
end
-
def update_multiple_puppetrun
-
return deny_access unless Setting[:puppetrun]
-
if GW::Puppet.run @hosts.map(&:fqdn)
-
notice "Successfully executed, check reports and/or log files for more details"
-
else
-
error "Some or all hosts execution failed, Please check log files for more information"
-
end
-
redirect_back_or_to hosts_path
-
end
-
def errors
params[:search]="last_report > “#{Setting[:puppet_interval] + 5} minutes ago” and (status.failed > 0 or status.failed_restarts > 0)"
index "Hosts with errors"
diff --git a/app/helpers/hosts_helper.rb b/app/helpers/hosts_helper.rb
index 7231674…cdb1605 100644
— a/app/helpers/hosts_helper.rb
+++ b/app/helpers/hosts_helper.rb
@@ -82,6 +82,7 @@ module HostsHelper
[‘Enable Notifications’, multiple_enable_hosts_path],
]
actions.insert(1, [‘Build Hosts’, multiple_build_hosts_path]) if SETTINGS[:unattended] -
actions << [‘Run Puppet’, multiple_puppetrun_hosts_path] if Setting[:puppetrun]
select_tag “Multiple Actions”, options_for_select(actions), :id => “Submit_multiple”,
:class => “medium”, :title => "Perform Actions on multiple hosts"
diff --git a/app/views/hosts/multiple_puppetrun.html.erb b/app/views/hosts/multiple_puppetrun.html.erb
new file mode 100644
index 0000000…e43d33d
— /dev/null
+++ b/app/views/hosts/multiple_puppetrun.html.erb
@@ -0,0 +1,5 @@
+<%= render ‘selected_hosts’, :hosts => @hosts %>
+<%= form_tag update_multiple_puppetrun_hosts_path({:host_ids => params[:host_ids]}) do -%>
-
Run Puppet on the following hosts
+<% end %>
diff --git a/config/routes.rb b/config/routes.rb
index 7c8accb…cc5f808 100644
— a/config/routes.rb
+++ b/config/routes.rb
@@ -33,6 +33,8 @@ Foreman::Application.routes.draw do
post 'update_multiple_hostgroup’
get 'select_multiple_environment’
post ‘update_multiple_environment’ -
get 'multiple_puppetrun'
-
post 'update_multiple_puppetrun' get 'multiple_destroy' post 'submit_multiple_destroy' get 'multiple_build'
diff --git a/vendor/plugins/proxy/lib/proxy.rb b/vendor/plugins/proxy/lib/proxy.rb
index 0f6f546…afb9381 100644
— a/vendor/plugins/proxy/lib/proxy.rb
+++ b/vendor/plugins/proxy/lib/proxy.rb
@@ -20,9 +20,9 @@ module GW
module Logger
def logger
-
if defined? RAILS_DEFAULT_LOGGER
-
if defined? Rails and defined? Rails.logger # If we are running as a library in a rails app then use the provided logger
-
RAILS_DEFAULT_LOGGER
-
Rails.logger else # We must make our own ruby based logger if we are a standalone proxy server require 'logger'
–
1.7.7.3