Class: Katello::Host::ProfilesUploader
- Inherits:
-
Object
- Object
- Katello::Host::ProfilesUploader
- Defined in:
- app/services/katello/host/profiles_uploader.rb
Instance Method Summary collapse
-
#initialize(profile_string:, host: nil) ⇒ ProfilesUploader
constructor
A new instance of ProfilesUploader.
-
#trigger_applicability_generation ⇒ Object
rubocop:enable Metrics/MethodLength.
-
#upload ⇒ Object
rubocop:disable Metrics/MethodLength.
Constructor Details
#initialize(profile_string:, host: nil) ⇒ ProfilesUploader
Returns a new instance of ProfilesUploader.
4 5 6 7 |
# File 'app/services/katello/host/profiles_uploader.rb', line 4 def initialize(profile_string:, host: nil) @profile_string = profile_string @host = host end |
Instance Method Details
#trigger_applicability_generation ⇒ Object
rubocop:enable Metrics/MethodLength
55 56 57 58 59 60 61 |
# File 'app/services/katello/host/profiles_uploader.rb', line 55 def trigger_applicability_generation if @host.nil? Rails.logger.warn "Host was not specified; can't trigger applicability generation" return end ::Katello::Host::ContentFacet.trigger_applicability_generation(@host.id) end |
#upload ⇒ Object
rubocop:disable Metrics/MethodLength
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 49 50 51 52 |
# File 'app/services/katello/host/profiles_uploader.rb', line 10 def upload if @host.nil? Rails.logger.warn("Host was not specified; skipping") return false elsif @host.content_facet.nil? || @host.content_facet.uuid.nil? Rails.logger.warn("Host with ID %s has no content facet; skipping" % @host.id) return false end profiles = JSON.parse(@profile_string) #free the huge string from the memory @profile_string = 'TRIMMED'.freeze if 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(payload) else module_streams = [] profiles.each do |profile| payload = profile["profile"] case profile["content_type"] when "rpm" PackageProfileUploader.import_package_profile_for_host(@host.id, payload) when "deb" import_deb_package_profile(payload) when "enabled_repos" @host.import_enabled_repositories(payload) else module_streams << payload end end module_streams.each do |module_stream_payload| import_module_streams(module_stream_payload) end end # Just to update the internal cache @host.content_facet.tracer_installed?(force_update_cache: true) @host.content_facet.host_tools_installed?(force_update_cache: true) true end |