Class: Actions::Katello::Organization::Destroy
- Inherits:
-
EntryAction
- Object
- EntryAction
- Actions::Katello::Organization::Destroy
- Defined in:
- app/lib/actions/katello/organization/destroy.rb
Instance Method Summary collapse
- #destroy_contents(organization) ⇒ Object
- #finalize ⇒ Object
- #humanized_name ⇒ Object
- #plan(organization, current_org = nil) ⇒ Object
- #remove_consumers(organization) ⇒ Object
- #remove_content_view_environment(cv_env) ⇒ Object
- #remove_content_views(organization) ⇒ Object
- #remove_default_content_view(organization) ⇒ Object
- #remove_environments(organization) ⇒ Object
- #remove_products(organization) ⇒ Object
- #remove_providers(organization) ⇒ Object
- #validate(organization, current_org) ⇒ Object
Instance Method Details
#destroy_contents(organization) ⇒ Object
96 97 98 99 100 101 102 103 |
# File 'app/lib/actions/katello/organization/destroy.rb', line 96 def destroy_contents(organization) repositories = organization.products.map(&:repositories).flatten content_ids = repositories.map(&:content_id).uniq content_ids.each do |content_id| plan_action(Candlepin::Product::ContentDestroy, content_id: content_id) end end |
#finalize ⇒ Object
26 27 28 29 |
# File 'app/lib/actions/katello/organization/destroy.rb', line 26 def finalize organization = ::Organization.find(input[:organization][:id]) organization.destroy! end |
#humanized_name ⇒ Object
31 32 33 |
# File 'app/lib/actions/katello/organization/destroy.rb', line 31 def humanized_name _("Destroy") end |
#plan(organization, current_org = nil) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/lib/actions/katello/organization/destroy.rb', line 7 def plan(organization, current_org = nil) action_subject(organization) validate(organization, current_org) sequence do remove_consumers(organization) remove_content_views(organization) remove_default_content_view(organization) remove_products(organization) remove_providers(organization) remove_environments(organization) destroy_contents(organization) plan_self plan_action(Candlepin::Owner::Destroy, label: organization.label) if ::SETTINGS[:katello][:use_cp] plan_action(Candlepin::Product::DeleteUnused, organization) end end |
#remove_consumers(organization) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/lib/actions/katello/organization/destroy.rb', line 48 def remove_consumers(organization) concurrence do organization.systems.each do |system| plan_action(Katello::System::Destroy, system, skip_candlepin: true) end organization.activation_keys.each do |key| plan_action(Katello::ActivationKey::Destroy, key, skip_candlepin: true) end end end |
#remove_content_view_environment(cv_env) ⇒ Object
69 70 71 |
# File 'app/lib/actions/katello/organization/destroy.rb', line 69 def remove_content_view_environment(cv_env) plan_action(ContentViewEnvironment::Destroy, cv_env, :skip_repo_destroy => true, :skip_candlepin_update => true, :organization_destroy => true) end |
#remove_content_views(organization) ⇒ Object
73 74 75 76 77 78 79 |
# File 'app/lib/actions/katello/organization/destroy.rb', line 73 def remove_content_views(organization) concurrence do organization.content_views.non_default.each do |content_view| plan_action(ContentView::Destroy, content_view, :check_ready_to_destroy => false, :organization_destroy => true) end end end |
#remove_default_content_view(organization) ⇒ Object
89 90 91 92 93 94 |
# File 'app/lib/actions/katello/organization/destroy.rb', line 89 def remove_default_content_view(organization) organization.default_content_view.tap do |view| view.content_view_environments.each { |cve| remove_content_view_environment(cve) } plan_action(ContentView::Destroy, organization.default_content_view, :check_ready_to_destroy => false, :organization_destroy => true) end end |
#remove_environments(organization) ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'app/lib/actions/katello/organization/destroy.rb', line 60 def remove_environments(organization) organization.promotion_paths.each do |path| path.reverse_each do |env| plan_action(Katello::Environment::Destroy, env, :skip_repo_destroy => true, :organization_destroy => true) end end plan_action(Katello::Environment::Destroy, organization.library, :skip_repo_destroy => true, :organization_destroy => true) end |
#remove_products(organization) ⇒ Object
81 82 83 84 85 86 87 |
# File 'app/lib/actions/katello/organization/destroy.rb', line 81 def remove_products(organization) concurrence do organization.products.each do |product| plan_action(Product::Destroy, product, :organization_destroy => true) end end end |
#remove_providers(organization) ⇒ Object
40 41 42 43 44 45 46 |
# File 'app/lib/actions/katello/organization/destroy.rb', line 40 def remove_providers(organization) concurrence do organization.providers.each do |provider| plan_action(Katello::Provider::Destroy, provider, false) end end end |
#validate(organization, current_org) ⇒ Object
35 36 37 38 |
# File 'app/lib/actions/katello/organization/destroy.rb', line 35 def validate(organization, current_org) errors = organization.validate_destroy(current_org) fail ::Katello::Errors::OrganizationDestroyException, errors.join(" ") if errors.present? end |