Class: ForemanChef::EnvironmentsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- ForemanChef::EnvironmentsController
- Includes:
- Foreman::Controller::AutoCompleteSearch, Concerns::EnvironmentParameters
- Defined in:
- app/controllers/foreman_chef/environments_controller.rb
Instance Method Summary collapse
- #auto_complete_controller_name ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #environments_for_chef_proxy ⇒ Object
- #import ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #synchronize ⇒ Object
- #update ⇒ Object
Methods included from Concerns::EnvironmentParameters
Methods inherited from ApplicationController
Instance Method Details
#auto_complete_controller_name ⇒ Object
65 66 67 |
# File 'app/controllers/foreman_chef/environments_controller.rb', line 65 def auto_complete_controller_name 'foreman_chef_environments' end |
#create ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'app/controllers/foreman_chef/environments_controller.rb', line 37 def create @environment = ForemanChef::Environment.new(environment_params) if @environment.save process_success else process_error end end |
#destroy ⇒ Object
57 58 59 60 61 62 63 |
# File 'app/controllers/foreman_chef/environments_controller.rb', line 57 def destroy if @environment.destroy process_success else process_error end end |
#edit ⇒ Object
46 47 |
# File 'app/controllers/foreman_chef/environments_controller.rb', line 46 def edit end |
#environments_for_chef_proxy ⇒ Object
69 70 71 72 73 74 |
# File 'app/controllers/foreman_chef/environments_controller.rb', line 69 def environments_for_chef_proxy @chef_proxy = SmartProxy.(:view_smart_proxies).with_features('Chef').find_by_id(params[:chef_proxy_id]) @environments = @chef_proxy.present? ? @chef_proxy.chef_environments : [] @type = params[:type] render :layout => false end |
#import ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'app/controllers/foreman_chef/environments_controller.rb', line 8 def import proxy = SmartProxy.(:view_smart_proxies).find(params[:proxy]) opts = params[:proxy].blank? ? {} : { :url => proxy.url, :chef_proxy => proxy } opts[:env] = params[:env] unless params[:env].blank? @importer = ChefServerImporter.new(opts) @changed = @importer.changes if @changed.values.all?(&:empty?) process_success :success_redirect => foreman_chef_environments_path, :success_msg => _("Nothing to synchronize") end end |
#index ⇒ Object
29 30 31 |
# File 'app/controllers/foreman_chef/environments_controller.rb', line 29 def index @environments = resource_base.includes(:chef_proxy).search_for(params[:search], :order => params[:order]).paginate(:page => params[:page]) end |
#new ⇒ Object
33 34 35 |
# File 'app/controllers/foreman_chef/environments_controller.rb', line 33 def new @environment = ForemanChef::Environment.new end |
#synchronize ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/foreman_chef/environments_controller.rb', line 19 def synchronize proxy = SmartProxy.(:view_smart_proxies).find(params[:proxy]) if (errors = ChefServerImporter.new(:chef_proxy => proxy).obsolete_and_new(params[:changed])).empty? process_success :success_redirect => foreman_chef_environments_path, :success_msg => _("Successfully updated environments") else process_error :redirect => foreman_chef_environments_path, :error_msg => _("Failed to update environments: %s") % errors.to_sentence end end |
#update ⇒ Object
49 50 51 52 53 54 55 |
# File 'app/controllers/foreman_chef/environments_controller.rb', line 49 def update if @environment.update_attributes(environment_params) process_success else process_error end end |