Skip to content

Instantly share code, notes, and snippets.

@mccun934
Created March 5, 2019 20:47
Show Gist options
  • Save mccun934/90cb355fab0e0a1bea54027715eae942 to your computer and use it in GitHub Desktop.
Save mccun934/90cb355fab0e0a1bea54027715eae942 to your computer and use it in GitHub Desktop.
./app/lib/actions/katello/organization/manifest_refresh.rb
module Actions
module Katello
module Organization
class ManifestRefresh < Actions::AbstractAsyncTask
middleware.use Actions::Middleware::PropagateCandlepinErrors
def plan(organization)
action_subject organization
manifest_update = organization.products.redhat.any?
path = "/tmp/#{rand}.zip"
details = organization.owner_details
upstream = details['upstreamConsumer'].blank? ? {} : details['upstreamConsumer']
sequence do
upstream_update = plan_action(Candlepin::Owner::UpstreamUpdate,
:organization_id => organization.id,
:upstream => upstream)
export_action = plan_action(Candlepin::Owner::UpstreamExport,
:organization_id => organization.id,
:upstream => upstream,
:path => path,
:dependency => upstream_update.output)
owner_import = plan_action(Candlepin::Owner::Import,
:label => organization.label,
:path => path,
:dependency => export_action.output)
import_products = plan_action(Candlepin::Owner::ImportProducts, :organization_id => organization.id, :dependency => owner_import.output)
if manifest_update && SETTINGS[:katello][:use_pulp]
repositories = ::Katello::Repository.in_default_view.where(:product_id => ::Katello::Product.redhat.in_org(organization))
repositories.each do |repo|
plan_action(Katello::Repository::RefreshRepository, repo, :dependency => import_products.output)
end
end
end
end
def rescue_strategy
Dynflow::Action::Rescue::Skip
end
def humanized_name
_("Refresh Manifest")
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment