Class: Actions::ForemanChef::Host::Destroy
- Inherits:
-
EntryAction
- Object
- EntryAction
- Actions::ForemanChef::Host::Destroy
- Defined in:
- app/lib/actions/foreman_chef/host/destroy.rb
Instance Method Summary collapse
- #cli_example ⇒ Object
- #humanized_input ⇒ Object
- #humanized_name ⇒ Object
- #plan(host) ⇒ Object
- #resource_locks ⇒ Object
- #run ⇒ Object
Instance Method Details
#cli_example ⇒ Object
41 42 43 44 45 46 |
# File 'app/lib/actions/foreman_chef/host/destroy.rb', line 41 def cli_example return unless input[:host] <<-EXAMPLE hammer host delete --id '#{task_input[:host][:id]}' EXAMPLE end |
#humanized_input ⇒ Object
37 38 39 |
# File 'app/lib/actions/foreman_chef/host/destroy.rb', line 37 def humanized_input input[:host] && input[:host][:name] end |
#humanized_name ⇒ Object
33 34 35 |
# File 'app/lib/actions/foreman_chef/host/destroy.rb', line 33 def humanized_name _("Delete host") end |
#plan(host) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/lib/actions/foreman_chef/host/destroy.rb', line 12 def plan(host) action_subject(host) if (::Setting[:auto_deletion] && proxy = host.chef_proxy) node_exists_in_chef = proxy.show_node(host.name) if node_exists_in_chef plan_self :chef_proxy_id => host.chef_proxy_id end plan_action Actions::ForemanChef::Client::Destroy, host.name, proxy end rescue => e ::Foreman::Logging.exception('Unable to communicate with Chef proxy', e) raise ::ForemanChef::ProxyException.new(N_('Unable to communicate with Chef proxy, %s' % e.)) end |
#resource_locks ⇒ Object
8 9 10 |
# File 'app/lib/actions/foreman_chef/host/destroy.rb', line 8 def resource_locks :link end |
#run ⇒ Object
27 28 29 30 31 |
# File 'app/lib/actions/foreman_chef/host/destroy.rb', line 27 def run proxy = ::SmartProxy.unscoped.find_by_id(input[:chef_proxy_id]) action_logger.debug "Deleting #{input[:host][:name]} on proxy #{proxy.name} at #{proxy.url}" self.output = proxy.delete_node(input[:host][:name]) end |