Sha256: e76cd7a7748fdefb33f7bf2d70b9efc870bfaa666161dae2a5352b0f6ef1c241

Contents?: true

Size: 1.24 KB

Versions: 71

Compression:

Stored size: 1.24 KB

Contents

module Katello
  module Pulp
    class ModuleStream < PulpContentUnit
      include LazyAccessor

      CONTENT_TYPE = "modulemd".freeze

      def update_model(model)
        shared_attributes = backend_data.keys & model.class.column_names
        shared_json = backend_data.select { |key, _v| shared_attributes.include?(key) }
        model.update!(shared_json)

        create_stream_artifacts(model, backend_data['artifacts']) if backend_data.key?('artifacts')
        create_profiles(model, backend_data['profiles']) if backend_data.key?('profiles')
      end

      def create_stream_artifacts(model, artifacts_json)
        artifacts_json.each do |name|
          Katello::Util::Support.active_record_retry do
            model.artifacts.where(name: name).first_or_create!
          end
        end
      end

      def create_profiles(model, profiles_json)
        profiles_json.each do |profile, rpms|
          Katello::Util::Support.active_record_retry do
            profile = model.profiles.where(name: profile).first_or_create!
          end
          rpms.each do |rpm|
            Katello::Util::Support.active_record_retry do
              profile.rpms.where(name: rpm).first_or_create!
            end
          end
        end
      end
    end
  end
end

Version data entries

71 entries across 71 versions & 1 rubygems

Version Path
katello-3.16.0 app/services/katello/pulp/module_stream.rb
katello-3.16.0.rc5.1 app/services/katello/pulp/module_stream.rb
katello-3.16.0.rc5 app/services/katello/pulp/module_stream.rb
katello-3.16.0.rc4.1 app/services/katello/pulp/module_stream.rb
katello-3.16.0.rc4 app/services/katello/pulp/module_stream.rb
katello-3.16.0.rc3.1 app/services/katello/pulp/module_stream.rb
katello-3.16.0.rc3 app/services/katello/pulp/module_stream.rb
katello-3.16.0.rc2.1 app/services/katello/pulp/module_stream.rb
katello-3.16.0.rc2 app/services/katello/pulp/module_stream.rb
katello-3.16.0.rc1.1 app/services/katello/pulp/module_stream.rb
katello-3.16.0.rc1 app/services/katello/pulp/module_stream.rb