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
- #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
#finalize ⇒ Object
24 25 26 27 |
# File 'app/lib/actions/katello/organization/destroy.rb', line 24 def finalize organization = ::Organization.find(input[:organization][:id]) organization.destroy! end |
#humanized_name ⇒ Object
29 30 31 |
# File 'app/lib/actions/katello/organization/destroy.rb', line 29 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 |
# 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) plan_self plan_action(Candlepin::Owner::Destroy, label: organization.label) end end |
#remove_consumers(organization) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/lib/actions/katello/organization/destroy.rb', line 46 def remove_consumers(organization) concurrence do ::Host.unscoped.where(:organization => organization).each do |host| plan_action(Katello::Host::Destroy, host, organization_destroy: 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
67 68 69 |
# File 'app/lib/actions/katello/organization/destroy.rb', line 67 def remove_content_view_environment(cv_env) plan_action(ContentViewEnvironment::Destroy, cv_env, :skip_repo_destroy => true, :organization_destroy => true) end |
#remove_content_views(organization) ⇒ Object
71 72 73 74 75 76 77 |
# File 'app/lib/actions/katello/organization/destroy.rb', line 71 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
87 88 89 90 91 92 |
# File 'app/lib/actions/katello/organization/destroy.rb', line 87 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
58 59 60 61 62 63 64 65 |
# File 'app/lib/actions/katello/organization/destroy.rb', line 58 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
79 80 81 82 83 84 85 |
# File 'app/lib/actions/katello/organization/destroy.rb', line 79 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
38 39 40 41 42 43 44 |
# File 'app/lib/actions/katello/organization/destroy.rb', line 38 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
33 34 35 36 |
# File 'app/lib/actions/katello/organization/destroy.rb', line 33 def validate(organization, current_org) errors = organization.validate_destroy(current_org) fail ::Katello::Errors::OrganizationDestroyException, errors.join(" ") if errors.present? end |