Revision a08ecd79
Added by Justin Sherrill about 10 years ago
app/lib/actions/katello/repository/clone_content.rb | ||
---|---|---|
module Repository
|
||
class CloneContent < Actions::Base
|
||
|
||
def plan(source_repo, target_repo, filters)
|
||
# rubocop:disable MethodLength
|
||
def plan(source_repo, target_repo, filters, purge_empty_units)
|
||
copy_clauses = nil
|
||
remove_clauses = nil
|
||
process_errata_and_groups = false
|
||
... | ... | |
process_errata_and_groups = true
|
||
end
|
||
if process_errata_and_groups
|
||
plan_copy(Pulp::Repository::CopyErrata, source_repo, target_repo, copy_clauses)
|
||
plan_copy(Pulp::Repository::CopyPackageGroup, source_repo, target_repo, copy_clauses)
|
||
plan_copy(Pulp::Repository::CopyErrata, source_repo, target_repo, nil)
|
||
plan_copy(Pulp::Repository::CopyPackageGroup, source_repo, target_repo, nil)
|
||
end
|
||
plan_copy(Pulp::Repository::CopyYumMetadataFile, source_repo, target_repo)
|
||
plan_copy(Pulp::Repository::CopyDistribution, source_repo, target_repo)
|
||
|
||
if purge_empty_units
|
||
plan_action(Pulp::Repository::PurgeEmptyErrata, :pulp_id => target_repo.pulp_id)
|
||
plan_action(Pulp::Repository::PurgeEmptyPackageGroups, :pulp_id => target_repo.pulp_id)
|
||
end
|
||
|
||
plan_action(Katello::Repository::MetadataGenerate, target_repo, filters.empty? ? source_repo : nil)
|
||
plan_action(ElasticSearch::Repository::IndexContent, id: target_repo.id)
|
||
end
|
app/lib/actions/katello/repository/clone_to_environment.rb | ||
---|---|---|
else
|
||
plan_action(Repository::Clear, clone)
|
||
end
|
||
plan_action(Repository::CloneContent, repository, clone, [])
|
||
plan_action(Repository::CloneContent, repository, clone, [], false)
|
||
concurrence do
|
||
plan_action(Katello::Repository::NodeMetadataGenerate, clone)
|
||
plan_action(Pulp::Repository::RegenerateApplicability, pulp_id: clone.pulp_id)
|
||
... | ... | |
# visible for the systems in the environment
|
||
def find_or_build_environment_clone(repository, environment)
|
||
version = repository.content_view_version
|
||
library = repository.organization.library
|
||
clone = version.content_view.get_repo_clone(library, repository).first
|
||
|
||
clone = version.content_view.get_repo_clone(environment, repository).first
|
||
if clone
|
||
clone = ::Katello::Repository.find(clone.id) # reload readonly object
|
||
clone.update_attributes!(content_view_version_id: version.id)
|
app/lib/actions/katello/repository/clone_to_version.rb | ||
---|---|---|
version: content_view_version)
|
||
sequence do
|
||
plan_action(Repository::Create, new_repository, true)
|
||
plan_action(Repository::CloneContent, repository, new_repository, filters)
|
||
plan_action(Repository::CloneContent, repository, new_repository, filters, true)
|
||
end
|
||
end
|
||
|
app/lib/actions/katello/repository/create.rb | ||
---|---|---|
path = repository.relative_path
|
||
end
|
||
sequence do
|
||
plan_action(Pulp::Repository::Create,
|
||
plan_action(Actions::Pulp::Repository::Create,
|
||
content_type: repository.content_type,
|
||
pulp_id: repository.pulp_id,
|
||
name: repository.name,
|
app/lib/actions/pulp/repository/abstract_copy_content.rb | ||
---|---|---|
end
|
||
|
||
def criteria
|
||
{ filters: {:unit => input[:clauses] } }
|
||
if input[:clauses]
|
||
{ filters: {:unit => input[:clauses] } }
|
||
else
|
||
{}
|
||
end
|
||
end
|
||
|
||
end
|
app/lib/actions/pulp/repository/purge_empty_errata.rb | ||
---|---|---|
#
|
||
# Copyright 2014 Red Hat, Inc.
|
||
#
|
||
# This software is licensed to you under the GNU General Public
|
||
# License as published by the Free Software Foundation; either version
|
||
# 2 of the License (GPLv2) or (at your option) any later version.
|
||
# There is NO WARRANTY for this software, express or implied,
|
||
# including the implied warranties of MERCHANTABILITY,
|
||
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
|
||
# have received a copy of GPLv2 along with this software; if not, see
|
||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
||
|
||
module Actions
|
||
module Pulp
|
||
module Repository
|
||
class PurgeEmptyErrata < Pulp::AbstractAsyncTask
|
||
|
||
input_format do
|
||
param :pulp_id, Integer
|
||
end
|
||
|
||
def invoke_external_task
|
||
repo = ::Katello::Repository.where(:pulp_id => input[:pulp_id]).first
|
||
|
||
package_lists = repo.package_lists_for_publish
|
||
filenames = package_lists[:filenames]
|
||
|
||
errata_to_delete = repo.errata.collect do |erratum|
|
||
erratum.errata_id if filenames.intersection(erratum.package_filenames).empty?
|
||
end
|
||
errata_to_delete.compact!
|
||
repo.unassociate_by_filter(::Katello::ContentViewErratumFilter::CONTENT_TYPE,
|
||
{ "id" => { "$in" => errata_to_delete } })
|
||
|
||
end
|
||
end
|
||
end
|
||
end
|
||
end
|
app/lib/actions/pulp/repository/purge_empty_package_groups.rb | ||
---|---|---|
#
|
||
# Copyright 2014 Red Hat, Inc.
|
||
#
|
||
# This software is licensed to you under the GNU General Public
|
||
# License as published by the Free Software Foundation; either version
|
||
# 2 of the License (GPLv2) or (at your option) any later version.
|
||
# There is NO WARRANTY for this software, express or implied,
|
||
# including the implied warranties of MERCHANTABILITY,
|
||
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
|
||
# have received a copy of GPLv2 along with this software; if not, see
|
||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
||
|
||
module Actions
|
||
module Pulp
|
||
module Repository
|
||
class PurgeEmptyPackageGroups < Pulp::AbstractAsyncTask
|
||
|
||
input_format do
|
||
param :pulp_id, Integer
|
||
end
|
||
|
||
def invoke_external_task
|
||
repo = ::Katello::Repository.where(:pulp_id => input[:pulp_id]).first
|
||
|
||
package_lists = repo.package_lists_for_publish
|
||
rpm_names = package_lists[:names]
|
||
|
||
# Remove all package groups with no packages
|
||
package_groups_to_delete = repo.package_groups.collect do |group|
|
||
group.package_group_id if rpm_names.intersection(group.package_names).empty?
|
||
end
|
||
package_groups_to_delete.compact!
|
||
|
||
repo.unassociate_by_filter(::Katello::ContentViewPackageGroupFilter::CONTENT_TYPE,
|
||
{ "id" => { "$in" => package_groups_to_delete } })
|
||
|
||
end
|
||
end
|
||
end
|
||
end
|
||
end
|
app/models/katello/content_view_filter.rb | ||
---|---|---|
scope :whitelist, where(:inclusion => true)
|
||
scope :blacklist, where(:inclusion => false)
|
||
|
||
scope :yum, where(:type => [ContentViewPackageGroupFilter.name,
|
||
ContentViewErratumFilter.name,
|
||
ContentViewPackageFilter.name])
|
||
def self.yum
|
||
where(:type => [::Katello::ContentViewPackageGroupFilter.name,
|
||
::Katello::ContentViewErratumFilter.name,
|
||
::Katello::ContentViewPackageFilter.name])
|
||
end
|
||
|
||
def params_format
|
||
{}
|
app/models/katello/glue/elastic_search/repository.rb | ||
---|---|---|
end
|
||
|
||
def indexed_errata_ids
|
||
options = {:repoids => [self.pulp_id], :fields => [:id], :start => 0, :page_size => 1}
|
||
options = {:filters => {:repoids => [self.pulp_id]}, :fields => [:id], :start => 0, :page_size => 1}
|
||
options[:page_size] = ::Katello::Errata.legacy_search("", options).total
|
||
::Katello::Errata.legacy_search("", options).collect{|e| e.id}
|
||
end
|
||
... | ... | |
else
|
||
errata_ids = self.errata_ids
|
||
search_errata_ids = self.indexed_errata_ids
|
||
|
||
Katello::Errata.add_indexed_repoid(errata_ids - search_errata_ids, self.pulp_id)
|
||
Katello::Errata.remove_indexed_repoid(search_errata_ids - errata_ids, self.pulp_id)
|
||
end
|
app/models/katello/glue/pulp/repo.rb | ||
---|---|---|
Katello.pulp_server.extensions.repository.unit_search(self.pulp_id, options)
|
||
end
|
||
|
||
# A helper method used by purge_empty_groups_errata
|
||
# to obtain a list of package filenames and names
|
||
# so that it could mix/match empty package groups
|
||
# and errata and purge them.
|
||
def package_lists_for_publish
|
||
names = []
|
||
filenames = []
|
||
|
||
rpms = Katello.pulp_server.extensions.repository.unit_search(self.pulp_id,
|
||
:type_ids => ['rpm'],
|
||
:fields => {:unit => %w(filename name)})
|
||
|
||
rpms.each do |rpm|
|
||
filenames << rpm["metadata"]["filename"]
|
||
names << rpm["metadata"]["name"]
|
||
end
|
||
{:names => names.to_set,
|
||
:filenames => filenames.to_set}
|
||
end
|
||
|
||
protected
|
||
|
||
def _get_most_recent_sync_status
|
||
... | ... | |
end
|
||
end
|
||
|
||
# A helper method used by purge_empty_groups_errata
|
||
# to obtain a list of package filenames and names
|
||
# so that it could mix/match empty package groups
|
||
# and errata and purge them.
|
||
def package_lists_for_publish
|
||
names = []
|
||
filenames = []
|
||
|
||
rpms = Katello.pulp_server.extensions.repository.unit_search(self.pulp_id,
|
||
:type_ids => ['rpm'],
|
||
:fields => {:unit => %w(filename name)})
|
||
|
||
rpms.each do |rpm|
|
||
filenames << rpm["metadata"]["filename"]
|
||
names << rpm["metadata"]["name"]
|
||
end
|
||
{:names => names.to_set,
|
||
:filenames => filenames.to_set}
|
||
end
|
||
|
||
end
|
||
|
||
def full_path
|
Also available in: Unified diff
fixes for CV promote and publish
instead of creating a new one