Class: Katello::Content
- Includes:
- Glue::Candlepin::Content
- Defined in:
- app/models/katello/content.rb
Class Method Summary collapse
Instance Method Summary collapse
- #can_update_to_url?(new_url) ⇒ Boolean
- #propagate_name_change? ⇒ Boolean
- #redhat? ⇒ Boolean
- #repositories ⇒ Object
- #root_repositories ⇒ Object
- #update_repository_names ⇒ Object
Methods included from Glue::Candlepin::Content
Methods inherited from Model
Class Method Details
.import_all ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/models/katello/content.rb', line 39 def self.import_all Organization.all.each do |org| cp_products = ::Katello::Resources::Candlepin::Product.all(org.label, [:id, :productContent]) product_hash = cp_products.group_by { |prod| prod['id'] } prod_content_importer = Katello::ProductContentImporter.new(product_hash) org.products.each do |product| product_json = product_hash[product.cp_id]&.first if product_json.nil? Rails.logger.warn _("Product with ID %s not found in Candlepin. Skipping content import for it.") % product.cp_id next end prod_content_importer.add_product_content(product, product_json['productContent']) end prod_content_importer.import end end |
.substitute_content_path(arch: nil, releasever: nil, content_path:) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'app/models/katello/content.rb', line 67 def self.substitute_content_path(arch: nil, releasever: nil, content_path:) arch = nil if arch == "noarch" substitutions = { :releasever => releasever, :basearch => arch }.compact path = substitutions.inject(content_path) do |path_url, (key, value)| path_url.gsub("$#{key}", value) end { path: path, substitutions: substitutions } end |
Instance Method Details
#can_update_to_url?(new_url) ⇒ Boolean
59 60 61 62 63 64 65 |
# File 'app/models/katello/content.rb', line 59 def can_update_to_url?(new_url) # We need to match the substitutable variables from # current content_url and new_url current_subs = content_url&.scan(/\$\w+/)&.sort new_url_subs = new_url&.scan(/\$\w+/)&.sort current_subs == new_url_subs end |
#propagate_name_change? ⇒ Boolean
35 36 37 |
# File 'app/models/katello/content.rb', line 35 def propagate_name_change? self.saved_change_to_attribute?(:name) && self.redhat? end |
#redhat? ⇒ Boolean
31 32 33 |
# File 'app/models/katello/content.rb', line 31 def redhat? products.redhat.any? end |
#repositories ⇒ Object
27 28 29 |
# File 'app/models/katello/content.rb', line 27 def repositories Katello::Repository.where(:root_id => root_repositories) end |
#root_repositories ⇒ Object
23 24 25 |
# File 'app/models/katello/content.rb', line 23 def root_repositories Katello::RootRepository.where(:content_id => self.cp_content_id) end |
#update_repository_names ⇒ Object
17 18 19 20 21 |
# File 'app/models/katello/content.rb', line 17 def update_repository_names root_repositories.each do |root| root.update!(:name => root.calculate_updated_name) end end |