Module: Katello::Util::CandlepinRepositoryChecker

Defined in:
app/lib/katello/util/candlepin_repository_checker.rb

Class Method Summary collapse

Class Method Details

.check_repositories_for_content_view_publish!(repositories, component_version: nil) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'app/lib/katello/util/candlepin_repository_checker.rb', line 54

def self.check_repositories_for_content_view_publish!(repositories, component_version: nil)
  bad_repo = repositories.yum_type.find { |repo| !repository_exist_in_backend?(repo) }
  return if bad_repo.blank?
  if component_version
    item = _("Component Version: '%{cvv}', Product: '%{product}', Repository: '%{repo}' " %
            { repo: bad_repo.name, product: bad_repo.product.name, cvv: component_version.name })
  else
    item = _("Product: '%{product}', Repository: '%{repo}' " %
            { repo: bad_repo.name, product: bad_repo.product.name })
  end
  if bad_repo.redhat?
    fail _("'%{item}' in this content view does not exist in the backend system [ Candlepin ]. "\
           " Either remove the invalid repository or try refreshing "\
           "the manifest before publishing again. " % { item: item })
  else
    fail _("'%{item}' in this content view does not exist in the backend system [ Candlepin ]. "\
           " Remove the invalid repository before publishing again. " % { item: item })
  end
end

.check_repositories_for_promote!(content_view_version) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/lib/katello/util/candlepin_repository_checker.rb', line 4

def self.check_repositories_for_promote!(content_view_version)
  bad_repo = content_view_version.repositories.yum_type.find { |repo| !repository_exist_in_backend?(repo) }
  return if bad_repo.blank?
  item = _("Content View Version: '%{cvv}', Product: '%{product}', Repository: '%{repo}' " %
            { repo: bad_repo.name, product: bad_repo.product.name, cvv: content_view_version.name })

  if bad_repo.redhat?
    fail _("'%{item}' does not exist in the backend system [ Candlepin ]. "\
           " Either remove the invalid repository or try refreshing "\
           "the manifest before promoting. " % { item: item })
  else
    fail _("'%{item}' does not exist in the backend system [ Candlepin ]. "\
           " Remove the invalid repository before promoting. " % { item: item })
  end
end

.check_repositories_for_publish!(content_view) ⇒ Object



44
45
46
47
48
49
50
51
52
# File 'app/lib/katello/util/candlepin_repository_checker.rb', line 44

def self.check_repositories_for_publish!(content_view)
  if content_view.composite?
    content_view.components.each do |cvv|
      check_repositories_for_content_view_publish!(cvv.repositories, component_version: cvv)
    end
  else
    check_repositories_for_content_view_publish!(content_view.repositories)
  end
end

.check_repository_for_sync!(repo) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/lib/katello/util/candlepin_repository_checker.rb', line 20

def self.check_repository_for_sync!(repo)
  return if !repo.yum? || repository_exist_in_backend?(repo)
  item = _("Product: '%{product}', Repository: '%{repo}' " %
            { repo: repo.name, product: repo.product.name })

  if repo.redhat?
    fail _("'%{item}' does not exist in the backend system [ Candlepin ]. "\
           " Either remove and re-enable the repository or try refreshing "\
           "the manifest before synchronizing. " % { item: item })
  else
    fail _("'%{item}' does not exist in the backend system [ Candlepin ]. "\
           " Remove and recreate the repository before synchronizing. " % { item: item })
  end
end

.repository_exist_in_backend?(repository) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
38
39
40
41
42
# File 'app/lib/katello/util/candlepin_repository_checker.rb', line 35

def self.repository_exist_in_backend?(repository)
  return false if repository.root.content_id.blank?

  ::Katello::Resources::Candlepin::Content.get(repository.organization.label, repository.root.content_id)
  true
rescue RestClient::NotFound
  false
end