app/lib/actions/katello/capsule_content/sync.rb in katello-3.4.2 vs app/lib/actions/katello/capsule_content/sync.rb in katello-3.4.4
- old
+ new
@@ -4,22 +4,34 @@
class Sync < ::Actions::EntryAction
def resource_locks
:link
end
+ input_format do
+ param :name
+ end
+
def humanized_name
- _("Synchronize capsule content")
+ _("Synchronize smart proxy")
end
- def plan(capsule_content, options = {})
+ def humanized_input
+ ["'#{input['smart_proxy']['name']}'"] + super
+ end
+
+ def plan(smart_proxy, options = {})
+ action_subject(smart_proxy)
+ capsule_content = ::Katello::CapsuleContent.new(smart_proxy)
capsule_content.ping_pulp
capsule_content.verify_ueber_certs
- action_subject(capsule_content.capsule)
- environment = options.fetch(:environment, nil)
- repository = options.fetch(:repository, nil)
- content_view = options.fetch(:content_view, nil)
+ environment_id = options.fetch(:environment_id, nil)
+ environment = ::Katello::KTEnvironment.find(environment_id) if environment_id
+ repository_id = options.fetch(:repository_id, nil)
+ repository = ::Katello::Repository.find(repository_id) if repository_id
+ content_view_id = options.fetch(:content_view_id, nil)
+ content_view = ::Katello::ContentView.find(content_view_id) if content_view_id
fail _("Action not allowed for the default capsule.") if capsule_content.default_capsule?
affected_repos = affected_repositories(capsule_content, environment, content_view, repository)
need_updates = repos_needing_updates(capsule_content, affected_repos)
@@ -29,31 +41,29 @@
need_updates.each do |repo|
plan_action(Pulp::Repository::Refresh, repo, capsule_id: capsule_content.capsule.id)
end
plan_action(ConfigureCapsule, capsule_content, environment, content_view, repository)
sync_repos_to_capsule(capsule_content, repository_ids)
- plan_action(RemoveOrphans, :capsule_id => capsule_content.capsule.id)
end
end
end
def sync_repos_to_capsule(capsule_content, repository_ids)
concurrence do
repository_ids.each do |repo_id|
sequence do
- repo = ::Katello::Repository.where(:pulp_id => repo_id).first ||
- ::Katello::ContentViewPuppetEnvironment.where(:pulp_id => repo_id).first
- if repo && repo.content_type != "yum"
- # we unassociate units in non-yum repos in order to avoid version conflicts
- # during publish. (i.e. two versions of a puppet module in the same repo)
+ repo = ::Katello::Repository.find_by(pulp_id: repo_id)
+ if repo && ['yum', 'puppet'].exclude?(repo.content_type)
+ # we unassociate units in non-yum/puppet repos in order to avoid version conflicts
+ # during publish. (i.e. two versions of a unit in the same repo)
plan_action(Pulp::Consumer::UnassociateUnits,
capsule_id: capsule_content.capsule.id,
repo_pulp_id: repo_id)
end
-
plan_action(Pulp::Consumer::SyncCapsule,
capsule_id: capsule_content.capsule.id,
- repo_pulp_id: repo_id)
+ repo_pulp_id: repo_id,
+ sync_options: { remove_missing: repo && ["puppet", "yum"].include?(repo.content_type) })
end
end
end
end