Class: Actions::Katello::Organization::ManifestRefresh
- Inherits:
-
AbstractAsyncTask
- Object
- EntryAction
- AbstractAsyncTask
- Actions::Katello::Organization::ManifestRefresh
- Includes:
- Helpers::Notifications
- Defined in:
- app/lib/actions/katello/organization/manifest_refresh.rb
Instance Method Summary collapse
- #failure_notification(plan) ⇒ Object
- #finalize ⇒ Object
-
#humanized_input ⇒ Object
results in correct grammar on Tasks page, e.g.
- #humanized_name ⇒ Object
- #humanized_output ⇒ Object
- #plan(organization) ⇒ Object
- #plan_refresh_repos(import_products_action, org) ⇒ Object
- #rescue_strategy ⇒ Object
- #success_notification(_plan) ⇒ Object
Methods included from Helpers::Notifications
#get_foreman_task, included, #plan_failed?, #send_notification, #subject_organization
Instance Method Details
#failure_notification(plan) ⇒ Object
63 64 65 66 67 68 |
# File 'app/lib/actions/katello/organization/manifest_refresh.rb', line 63 def failure_notification(plan) ::Katello::UINotifications::Subscriptions::ManifestRefreshError.deliver!( :subject => subject_organization, :task => get_foreman_task(plan) ) end |
#finalize ⇒ Object
94 95 96 97 98 |
# File 'app/lib/actions/katello/organization/manifest_refresh.rb', line 94 def finalize org = ::Organization.find(input[:organization_id]) org.clear_manifest_expired_notifications subject_organization.audit_manifest_action(_('Manifest refreshed')) end |
#humanized_input ⇒ Object
results in correct grammar on Tasks page, e.g. “Refresh manifest for organization Default Organization”
86 87 88 |
# File 'app/lib/actions/katello/organization/manifest_refresh.rb', line 86 def humanized_input "for organization '#{input[:organization_name]}'" end |
#humanized_name ⇒ Object
80 81 82 |
# File 'app/lib/actions/katello/organization/manifest_refresh.rb', line 80 def humanized_name _("Refresh Manifest") end |
#humanized_output ⇒ Object
90 91 92 |
# File 'app/lib/actions/katello/organization/manifest_refresh.rb', line 90 def humanized_output all_planned_actions(Candlepin::Owner::Import).first.humanized_output end |
#plan(organization) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/lib/actions/katello/organization/manifest_refresh.rb', line 9 def plan(organization) action_subject organization manifest_update = organization.products.redhat.any? path = File.join(::Rails.root, "tmp", "#{rand}.zip") details = organization.owner_details upstream = details['upstreamConsumer'].blank? ? {} : details['upstreamConsumer'] sequence do plan_self( :organization_id => organization.id, :organization_name => organization.name ) upstream_update = plan_action(Candlepin::Owner::UpstreamUpdate, :organization_id => organization.id, :upstream => upstream) export_action = plan_action(Candlepin::Owner::StartUpstreamExport, :organization_id => organization.id, :upstream => upstream, :path => path, :dependency => upstream_update.output) retrieved_export = plan_action(Candlepin::Owner::RetrieveUpstreamExport, :export_id => export_action.output[:task]['resultData']['exportId'], :organization_id => organization.id, :upstream => upstream, :path => path, :dependency => export_action.output) owner_import = plan_action(Candlepin::Owner::Import, :label => organization.label, :path => path, :dependency => retrieved_export.output) import_products = plan_action(Candlepin::Owner::ImportProducts, :organization_id => organization.id, :dependency => owner_import.output) plan_action(Katello::Organization::EnvironmentContentsRefresh, organization) if manifest_update plan_refresh_repos(import_products, organization) end end end |
#plan_refresh_repos(import_products_action, org) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/lib/actions/katello/organization/manifest_refresh.rb', line 50 def plan_refresh_repos(import_products_action, org) repositories = ::Katello::Repository.in_default_view.in_product(::Katello::Product.redhat.in_org(org)) repositories.in_groups_of(Setting[:foreman_proxy_content_batch_size], false) do |repo_batch| concurrence do repo_batch.each do |repo| plan_action(Katello::Repository::RefreshRepository, repo, :dependency => import_products_action.output) end end end end |
#rescue_strategy ⇒ Object
76 77 78 |
# File 'app/lib/actions/katello/organization/manifest_refresh.rb', line 76 def rescue_strategy Dynflow::Action::Rescue::Skip end |
#success_notification(_plan) ⇒ Object
70 71 72 73 74 |
# File 'app/lib/actions/katello/organization/manifest_refresh.rb', line 70 def success_notification(_plan) ::Katello::UINotifications::Subscriptions::ManifestRefreshSuccess.deliver!( subject_organization ) end |