Sha256: bbe2fb4b057aaa657cbf5244e4d83776760438e19cbe8683d858d10c2f3690b4

Contents?: true

Size: 1.08 KB

Versions: 51

Compression:

Stored size: 1.08 KB

Contents

module Katello
  module Pulp
    class YumMetadataFile < PulpContentUnit
      CONTENT_TYPE = "yum_repo_metadata_file".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) }
        repo = ::Katello::Repository.find_by(:pulp_id => backend_data['repo_id']).try(:id)
        model.update!(shared_json.merge(repository_id: repo,
                                                  name: find_name_from_json(backend_data)))
      end

      def find_name_from_json(json)
        # get the name of the metadata file.
        # Notice that pulp does not have a way to get name of the metadata file
        # so we infer it from the _storage_path
        # for example from the following storage path
        #  "/var/lib/pulp/content/units/yum_repo_metadata_file/..../050-productid.gz"
        # we find the right most '/' and return everything after that
        # i.e ->  "050-productid.gz"
        File.basename(json["_storage_path"])
      end
    end
  end
end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
katello-4.0.3 app/services/katello/pulp/yum_metadata_file.rb
katello-3.18.5 app/services/katello/pulp/yum_metadata_file.rb
katello-4.0.2.1 app/services/katello/pulp/yum_metadata_file.rb
katello-4.0.2 app/services/katello/pulp/yum_metadata_file.rb
katello-3.18.4 app/services/katello/pulp/yum_metadata_file.rb
katello-4.0.1.2 app/services/katello/pulp/yum_metadata_file.rb
katello-3.18.3.1 app/services/katello/pulp/yum_metadata_file.rb
katello-4.1.0.rc2.2 app/services/katello/pulp/yum_metadata_file.rb
katello-4.1.0.rc2.1 app/services/katello/pulp/yum_metadata_file.rb
katello-4.0.1.1 app/services/katello/pulp/yum_metadata_file.rb
katello-3.18.3 app/services/katello/pulp/yum_metadata_file.rb
katello-4.1.0.rc2 app/services/katello/pulp/yum_metadata_file.rb
katello-4.0.1 app/services/katello/pulp/yum_metadata_file.rb
katello-4.1.0.rc1.1 app/services/katello/pulp/yum_metadata_file.rb
katello-4.1.0.rc1 app/services/katello/pulp/yum_metadata_file.rb
katello-4.0.0 app/services/katello/pulp/yum_metadata_file.rb
katello-4.0.0.rc3.1 app/services/katello/pulp/yum_metadata_file.rb
katello-4.0.0.rc3 app/services/katello/pulp/yum_metadata_file.rb
katello-3.18.2.1 app/services/katello/pulp/yum_metadata_file.rb
katello-3.18.2 app/services/katello/pulp/yum_metadata_file.rb