Module: Glue::Candlepin::Content::InstanceMethods

Defined in:
app/models/katello/glue/candlepin/content.rb

Instance Method Summary collapse

Instance Method Details

#contentObject



13
14
15
16
17
18
19
# File 'app/models/katello/glue/candlepin/content.rb', line 13

def content
  return @content unless @content.nil?
  unless self.content_id.nil?
    @content = Katello::Candlepin::Content.find(self.content_id)
  end
  @content
end

#create_contentObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/models/katello/glue/candlepin/content.rb', line 21

def create_content
  #only used for custom content
  fail 'Can only create content for custom providers' if self.product.provider.redhat_provider?
  new_content = Candlepin::ProductContent.new(
    :content => {
      :name => self.name,
      :contentUrl => Glue::Pulp::Repos.custom_content_path(self.product, self.label),
      :type => self.content_type,
      :label => self.,
      :vendor => Provider::CUSTOM
    },
    :enabled => true
  )
  new_content.create
  self.product.add_content new_content
  self.content_id = new_content.content.id
  self.cp_label = new_content.content.label
  new_content.content
end

#custom_content_labelObject



54
55
56
# File 'app/models/katello/glue/candlepin/content.rb', line 54

def 
  "#{organization.label} #{product.label} #{label}".gsub(/\s/, "_")
end

#should_update_content?Boolean

Returns:

  • (Boolean)


41
42
43
44
# File 'app/models/katello/glue/candlepin/content.rb', line 41

def should_update_content?
  (self.gpg_key_id_was.nil? && !self.gpg_key_id.nil? && self.content.gpgUrl == '') ||
      (!self.gpg_key_id_was.nil? && self.gpg_key_id.nil? && self.content.gpgUrl != '')
end

#yum_gpg_key_urlObject



46
47
48
49
50
51
52
# File 'app/models/katello/glue/candlepin/content.rb', line 46

def yum_gpg_key_url
  # if the repo has a gpg key return a url to access it
  if (gpg_key && gpg_key.content.present?)
    host = Facter.value(:fqdn) || SETTINGS[:fqdn]
    gpg_key_content_api_repository_url(self, :host => host + "/katello", :protocol => 'https')
  end
end