commit b88ce6413cc2a533fc4eb4849c1597d3451720b2 Author: root Date: Wed Apr 13 11:59:28 2016 +0000 hook to katello host actions diff --git a/app/lib/actions/foreman_chef/host/destroy.rb b/app/lib/actions/foreman_chef/host/destroy.rb index a1a97a9..a9849b7 100644 --- a/app/lib/actions/foreman_chef/host/destroy.rb +++ b/app/lib/actions/foreman_chef/host/destroy.rb @@ -5,7 +5,7 @@ module Actions module Host class Destroy < Actions::EntryAction - def plan(host) + def plan(host, *_) action_subject(host) if (::Setting::ForemanChef.auto_deletion && proxy = ::SmartProxy.find_by_id(host.chef_proxy_id)) node_exists_in_chef = proxy.show_node(host.name) @@ -40,7 +40,14 @@ module Actions hammer host delete --id '#{task_input[:host][:id]}' EXAMPLE end - + + def self.subscribe + if defined? Actions::Katello::System::HostDestroy + Actions::Katello::System::HostDestroy + elsif defined? Actions::Katello::Host::Destroy + Actions::Katello::Host::Destroy + end + end end end end diff --git a/app/models/foreman_chef/concerns/host_action_subject.rb b/app/models/foreman_chef/concerns/host_action_subject.rb index 572c707..80c6531 100644 --- a/app/models/foreman_chef/concerns/host_action_subject.rb +++ b/app/models/foreman_chef/concerns/host_action_subject.rb @@ -1,23 +1,19 @@ -module ForemanChef - module Concerns - module HostActionSubject - extend ActiveSupport::Concern - include ForemanTasks::Concerns::ActionSubject - include ForemanTasks::Concerns::ActionTriggering - - def destroy_action - sync_action! - ::Actions::ForemanChef::Host::Destroy - end - - def action_input_key - "host" - end - - end - end -end - -class ::Host::Managed::Jail < Safemode::Jail - allow :chef_proxy -end +# module ForemanChef +# module Concerns +# module HostActionSubject +# extend ActiveSupport::Concern +# include ForemanTasks::Concerns::ActionSubject +# include ForemanTasks::Concerns::ActionTriggering +# +# def destroy_action +# sync_action! +# ::Actions::ForemanChef::Host::Destroy +# end +# +# def action_input_key +# "host" +# end +# +# end +# end +# end diff --git a/lib/foreman_chef/engine.rb b/lib/foreman_chef/engine.rb index 83363f1..614b1a6 100644 --- a/lib/foreman_chef/engine.rb +++ b/lib/foreman_chef/engine.rb @@ -51,12 +51,15 @@ module ForemanChef ::SmartProxy.send :include, SmartProxyExtensions ::FactImporter.register_fact_importer(:foreman_chef, ForemanChef::FactImporter) ::FactParser.register_fact_parser(:foreman_chef, ForemanChef::FactParser) - ::Host::Base.send :include, ForemanChef::Concerns::HostActionSubject + class ::Host::Managed::Jail < Safemode::Jail + allow :chef_proxy + end ::HostsController.send :include, ForemanChef::Concerns::HostsControllerRescuer # Renderer Concern needs to be injected to controllers, ForemanRenderer was already included (TemplatesController.descendants + [TemplatesController]).each do |klass| klass.send(:include, ForemanChef::Concerns::Renderer) end + end config.after_initialize do