Sha256: c4816ec74755a25912d4228ec295a0f07e5bfff64a417642bd042956b1e8bad9
Contents?: true
Size: 1.7 KB
Versions: 2
Compression:
Stored size: 1.7 KB
Contents
class SccProduct < ApplicationRecord 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, inverse_of: :scc_product, dependent: :destroy has_many :scc_extensions, through: :scc_extendings has_many :inverse_scc_extendings, inverse_of: :scc_extension, 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 = repo.uniq_name(self) 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.6.3 | app/models/scc_product.rb |
foreman_scc_manager-1.6.2 | app/models/scc_product.rb |