Sha256: 15e468856860800a985d380919e234d6460ea0bf4ddcf54d33b5f10259b3199f

Contents?: true

Size: 1.25 KB

Versions: 30

Compression:

Stored size: 1.25 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_attributes!(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

30 entries across 30 versions & 1 rubygems

Version Path
katello-3.15.3.1 app/services/katello/pulp/module_stream.rb
katello-3.15.3 app/services/katello/pulp/module_stream.rb
katello-3.15.2 app/services/katello/pulp/module_stream.rb
katello-3.15.1.1 app/services/katello/pulp/module_stream.rb
katello-3.15.1 app/services/katello/pulp/module_stream.rb
katello-3.15.0.1 app/services/katello/pulp/module_stream.rb
katello-3.15.0 app/services/katello/pulp/module_stream.rb
katello-3.15.0.rc2 app/services/katello/pulp/module_stream.rb
katello-3.15.0.rc1.3 app/services/katello/pulp/module_stream.rb
katello-3.15.0.rc1.2 app/services/katello/pulp/module_stream.rb
katello-3.15.0.rc1.1 app/services/katello/pulp/module_stream.rb
katello-3.15.0.rc1 app/services/katello/pulp/module_stream.rb
katello-3.14.1 app/services/katello/pulp/module_stream.rb
katello-3.13.4 app/services/katello/pulp/module_stream.rb
katello-3.14.0 app/services/katello/pulp/module_stream.rb
katello-3.13.3 app/services/katello/pulp/module_stream.rb
katello-3.14.0.rc2 app/services/katello/pulp/module_stream.rb
katello-3.13.2 app/services/katello/pulp/module_stream.rb
katello-3.14.0.rc1 app/services/katello/pulp/module_stream.rb
katello-3.13.1 app/services/katello/pulp/module_stream.rb