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
66 67 68 |
# File 'app/controllers/foreman_chef/environments_controller.rb', line 66 def auto_complete_controller_name 'foreman_chef_environments' end |
#create ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'app/controllers/foreman_chef/environments_controller.rb', line 38 def create @environment = ForemanChef::Environment.new(environment_params) if @environment.save process_success else process_error end end |
#destroy ⇒ Object
58 59 60 61 62 63 64 |
# File 'app/controllers/foreman_chef/environments_controller.rb', line 58 def destroy if @environment.destroy process_success else process_error end end |
#edit ⇒ Object
47 48 |
# File 'app/controllers/foreman_chef/environments_controller.rb', line 47 def edit end |
#environments_for_chef_proxy ⇒ Object
70 71 72 73 74 75 |
# File 'app/controllers/foreman_chef/environments_controller.rb', line 70 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 18 |
# 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?) notice _("Nothing to synchronize") redirect_to foreman_chef_environments_path end end |
#index ⇒ Object
30 31 32 |
# File 'app/controllers/foreman_chef/environments_controller.rb', line 30 def index @environments = resource_base.includes(:chef_proxy).search_for(params[:search], :order => params[:order]).paginate(:page => params[:page]) end |
#new ⇒ Object
34 35 36 |
# File 'app/controllers/foreman_chef/environments_controller.rb', line 34 def new @environment = ForemanChef::Environment.new end |
#synchronize ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/foreman_chef/environments_controller.rb', line 20 def synchronize proxy = SmartProxy.(:view_smart_proxies).find(params[:proxy]) if (errors = ChefServerImporter.new(:chef_proxy => proxy).obsolete_and_new(params[:changed])).empty? notice _("Successfully updated environments") else error _("Failed to update environments: %s") % errors.to_sentence end redirect_to foreman_chef_environments_path end |
#update ⇒ Object
50 51 52 53 54 55 56 |
# File 'app/controllers/foreman_chef/environments_controller.rb', line 50 def update if @environment.update_attributes(environment_params) process_success else process_error end end |