Sha256: 699479ff732400688656901b4edabc2e134de79e43249533ec1c1b098598362f
Contents?: true
Size: 1.65 KB
Versions: 2
Compression:
Stored size: 1.65 KB
Contents
class SccProduct < ActiveRecord::Base include Authorizable include ForemanTasks::Concerns::ActionSubject self.include_root_in_json = false belongs_to :scc_account belongs_to :product, class_name: 'Katello::Product' has_one :organization, through: :scc_account has_and_belongs_to_many :scc_repositories has_many :scc_extendings, dependent: :destroy has_many :scc_extensions, through: :scc_extendings has_many :inverse_scc_extendings, dependent: :destroy, class_name: :SccExtending, foreign_key: :scc_extension_id has_many :inverse_scc_extensions, through: :inverse_scc_extendings, source: :scc_product default_scope -> { order(:name) } scoped_search on: :name, complete_value: true def uniq_name "#{scc_id} " + friendly_name end def subscribe raise 'Product already subscribed!' if product new_product = Katello::Product.new new_product.name = uniq_name new_product.description = description ForemanTasks.sync_task(::Actions::Katello::Product::Create, new_product, scc_account.organization) new_product.reload scc_repositories.each do |repo| uniq_repo_name = uniq_name + ' ' + repo.description label = Katello::Util::Model.labelize(uniq_repo_name) unprotected = true gpg_key = new_product.gpg_key new_repo = new_product.add_repo(label, uniq_repo_name, repo.full_url, 'yum', unprotected, gpg_key) new_repo.arch = arch || 'noarch' new_repo.mirror_on_sync = true new_repo.verify_ssl_on_sync = true ForemanTasks.sync_task(::Actions::Katello::Repository::Create, new_repo, false, false) end update!(product: new_product) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
foreman_scc_manager-1.1.2 | app/models/scc_product.rb |
foreman_scc_manager-1.1.1 | app/models/scc_product.rb |