Class: SccRepository

Inherits:
ApplicationRecord
  • Object
show all
Defined in:
app/models/scc_repository.rb

Instance Method Summary collapse

Instance Method Details

#full_urlObject



12
13
14
# File 'app/models/scc_repository.rb', line 12

def full_url
  token.blank? ? url : "#{url}?#{token}"
end

#pretty_nameObject



20
21
22
# File 'app/models/scc_repository.rb', line 20

def pretty_name
  description
end

#token_changed_callbackObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/models/scc_repository.rb', line 24

def token_changed_callback
  User.current ||= User.anonymous_admin

  # get all Katello repos that were derived from this SCC repo
  # as uniq_name was changed, we need to look for repo labels that end with the repo name
  katello_repos = Katello::RootRepository.where('label like ?', "%#{::Katello::Util::Model.labelize(self.description)}%")
  katello_repos.each do |repo|
    if repo.has_attribute?('upstream_authentication_token')
      unless repo.url == url && repo.upstream_authentication_token == token
        ForemanTasks.async_task(::Actions::Katello::Repository::Update, repo, url: url, upstream_authentication_token: token)
        ::Foreman::Logging.logger('foreman_scc_manager').info "Update URL and authentication token for repository '#{repo.name}'."
      end
    else
      unless repo.url == full_url
        ForemanTasks.async_task(::Actions::Katello::Repository::Update, repo, url: full_url)
        ::Foreman::Logging.logger('foreman_scc_manager').info "Update URL-token for repository '#{repo.name}'."
      end
    end
  end
end

#uniq_name(scc_product) ⇒ Object



16
17
18
# File 'app/models/scc_repository.rb', line 16

def uniq_name(scc_product)
  "#{scc_product.scc_id} #{description}"
end