Sha256: 031ba4ca71d5ef9d8adcb390d1dd3024bf299a4fb7b3ac39e156c1fa7b2a67eb

Contents?: true

Size: 1.11 KB

Versions: 188

Compression:

Stored size: 1.11 KB

Contents

module Katello
  class InstalledProduct < Katello::Model
    has_many :subscription_facet_installed_products, :class_name => "Katello::SubscriptionFacetInstalledProduct", :dependent => :destroy, :inverse_of => :installed_product
    has_many :subscription_facets, :through => :subscription_facet_installed_products, :class_name => "Katello::Host::SubscriptionFacet"

    alias_attribute :product_id, :cp_product_id
    alias_attribute :product_name, :name

    def self.find_or_create_from_consumer(consumer_attributes)
      attributes = {
        :arch => consumer_attributes['arch'],
        :version => consumer_attributes['version'],
        :name => consumer_attributes['productName'],
        :cp_product_id => consumer_attributes['productId']
      }
      Katello::Util::Support.active_record_retry do
        unless self.where(attributes).exists?
          self.create!(attributes)
        end
      end
      self.where(attributes).first
    end

    def consumer_attributes
      {
        :arch => arch,
        :version => version,
        :productName => name,
        :productId => cp_product_id
      }
    end
  end
end

Version data entries

188 entries across 188 versions & 1 rubygems

Version Path
katello-4.14.2 app/models/katello/installed_product.rb
katello-4.14.1 app/models/katello/installed_product.rb
katello-4.14.0 app/models/katello/installed_product.rb
katello-4.14.0.rc3 app/models/katello/installed_product.rb
katello-4.14.0.rc2 app/models/katello/installed_product.rb
katello-4.14.0.rc1.1 app/models/katello/installed_product.rb
katello-4.14.0.rc1 app/models/katello/installed_product.rb
katello-4.13.1 app/models/katello/installed_product.rb
katello-4.13.0 app/models/katello/installed_product.rb
katello-4.12.1 app/models/katello/installed_product.rb
katello-4.13.0.rc1 app/models/katello/installed_product.rb
katello-4.12.0 app/models/katello/installed_product.rb
katello-4.12.0.rc3 app/models/katello/installed_product.rb
katello-4.12.0.rc2 app/models/katello/installed_product.rb
katello-4.12.0.rc1 app/models/katello/installed_product.rb
katello-4.11.1 app/models/katello/installed_product.rb
katello-4.11.0 app/models/katello/installed_product.rb
katello-4.11.0.rc2 app/models/katello/installed_product.rb
katello-4.11.0.rc1 app/models/katello/installed_product.rb
katello-4.10.0 app/models/katello/installed_product.rb