app/lib/actions/katello/host/upload_profiles.rb in katello-3.15.3.1 vs app/lib/actions/katello/host/upload_profiles.rb in katello-3.16.0.rc1
- old
+ new
@@ -31,55 +31,20 @@
def rescue_strategy
Dynflow::Action::Rescue::Skip
end
- def self.upload_modules_to_pulp(available_streams, host)
- query_name_streams = available_streams.map do |profile|
- ::Katello::ModuleStream.where(profile.slice(:name, :stream))
- end
-
- updated_profiles = []
- unless query_name_streams.empty?
- query_name_streams = query_name_streams.inject(&:or)
-
- bound_library_instances = host.content_facet.bound_repositories.map(&:library_instance_or_self)
- query = ::Katello::ModuleStream.in_repositories(bound_library_instances).
- select(:name, :stream, :version, :context, :arch).
- merge(query_name_streams)
-
- updated_profiles = query.map do |module_stream|
- module_stream.slice(:name, :stream, :version, :context, :arch)
- end
- end
-
- # We also need to pass module streams that are not found in the ModuleStream table
- # but are present on the content host
- unassociated_profiles = available_streams.select do |profile|
- updated_profiles.none? { |p| p[:name] == profile[:name] && p[:stream] == profile[:stream] }
- end
-
- module_stream_profile = updated_profiles + unassociated_profiles
-
- unless module_stream_profile.empty?
- begin
- ::Katello::Pulp::Consumer.new(host.content_facet.uuid).
- upload_module_stream_profile(module_stream_profile)
- rescue RestClient::ResourceNotFound
- Rails.logger.warn("Host with ID %s was not known to Pulp, continuing" % host.id)
- end
- end
- end
-
def import_module_streams(payload, host)
enabled_payload = payload.map do |profile|
- profile.slice("name", "stream", "version", "context", "arch").with_indifferent_access if profile["status"] == "enabled"
+ profile.slice("name", "stream", "version", "context", "arch") if profile["status"] == "enabled"
end
enabled_payload.compact!
- UploadProfiles.upload_modules_to_pulp(enabled_payload, host)
+ ::Katello::Pulp::Consumer.new(host.content_facet.uuid).upload_module_stream_profile(enabled_payload)
host.import_module_streams(payload)
+ rescue RestClient::ResourceNotFound
+ Rails.logger.warn("Host with ID %s was not known to Pulp, continuing" % input[:host_id])
end
def import_deb_package_profile(host, profile)
installed_deb_ids = profile.map do |item|
::Katello::InstalledDeb.find_or_create_by(name: item['name'], architecture: item['architecture'], version: item['version']).id
@@ -102,26 +67,21 @@
elsif profiles.try(:has_key?, "deb_package_profile")
# remove this when deb_package_profile API is removed
payload = profiles.dig("deb_package_profile", "deb_packages") || []
import_deb_package_profile(host, payload)
else
- module_streams = []
profiles.each do |profile|
payload = profile["profile"]
case profile["content_type"]
when "rpm"
UploadPackageProfile.upload(input[:host_id], payload)
when "deb"
import_deb_package_profile(host, payload)
when "enabled_repos"
host.import_enabled_repositories(payload)
else
- module_streams << payload
+ import_module_streams(payload, host)
end
- end
-
- module_streams.each do |module_stream_payload|
- import_module_streams(module_stream_payload, host)
end
end
end
end
end