Class: Actions::Katello::Environment::Destroy
- Inherits:
-
EntryAction
- Object
- EntryAction
- Actions::Katello::Environment::Destroy
- Defined in:
- app/lib/actions/katello/environment/destroy.rb
Instance Method Summary collapse
- #delete_host_and_hostgroup_associations(environment:) ⇒ Object
- #finalize ⇒ Object
- #humanized_input ⇒ Object
- #humanized_name ⇒ Object
- #plan(env, options = {}) ⇒ Object
Instance Method Details
#delete_host_and_hostgroup_associations(environment:) ⇒ Object
34 35 36 37 38 39 |
# File 'app/lib/actions/katello/environment/destroy.rb', line 34 def delete_host_and_hostgroup_associations(environment:) environment.hostgroups.delete_all host_ids = environment.hosts.ids ::Katello::Host::ContentFacet.where(:host_id => host_ids).delete_all ::Katello::Host::SubscriptionFacet.where(:host_id => host_ids).delete_all end |
#finalize ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'app/lib/actions/katello/environment/destroy.rb', line 49 def finalize environment = ::Katello::KTEnvironment.find(input['kt_environment']['id']) # CapsuleLifecycleEnvironment can cause issues when auditing, it will try to associate the audit to the deleted taxonomy ::Katello::CapsuleLifecycleEnvironment.without_auditing do environment.destroy! end end |
#humanized_input ⇒ Object
45 46 47 |
# File 'app/lib/actions/katello/environment/destroy.rb', line 45 def humanized_input ["'#{input['kt_environment']['name']}'"] + super end |
#humanized_name ⇒ Object
41 42 43 |
# File 'app/lib/actions/katello/environment/destroy.rb', line 41 def humanized_name _("Delete Lifecycle Environment") end |
#plan(env, options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/lib/actions/katello/environment/destroy.rb', line 12 def plan(env, = {}) fail env.errors..join(" ") unless env.deletable? skip_repo_destroy = .fetch(:skip_repo_destroy, false) organization_destroy = .fetch(:organization_destroy, false) sequence do action_subject(env) concurrence do env.content_view_environments.each do |cve| plan_action(ContentView::Remove, cve.content_view, :content_view_environments => [cve], :skip_repo_destroy => skip_repo_destroy, :organization_destroy => organization_destroy) end end if organization_destroy delete_host_and_hostgroup_associations(environment: env) end plan_self end end |