Class: Actions::Katello::Repository::CheckMatchingContent

Inherits:
Base
  • Object
show all
Defined in:
app/lib/actions/katello/repository/check_matching_content.rb

Instance Method Summary collapse

Instance Method Details

#debs_match?(source_repo, target_repo) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
# File 'app/lib/actions/katello/repository/check_matching_content.rb', line 38

def debs_match?(source_repo, target_repo)
  source_repo.deb_ids.sort == target_repo.deb_ids.sort
end

#distributions_match?(source_repo, target_repo) ⇒ Boolean

Returns:

  • (Boolean)


66
67
68
# File 'app/lib/actions/katello/repository/check_matching_content.rb', line 66

def distributions_match?(source_repo, target_repo)
  source_repo.distribution_information == target_repo.distribution_information
end

#errata_match?(source_repo, target_repo) ⇒ Boolean

Returns:

  • (Boolean)


54
55
56
57
58
# File 'app/lib/actions/katello/repository/check_matching_content.rb', line 54

def errata_match?(source_repo, target_repo)
  source_repo_ids = source_repo.erratum_ids.sort.uniq
  target_repo_ids = target_repo.erratum_ids.sort.uniq
  source_repo_ids == target_repo_ids
end

#package_groups_match?(source_repo, target_repo) ⇒ Boolean

Returns:

  • (Boolean)


60
61
62
63
64
# File 'app/lib/actions/katello/repository/check_matching_content.rb', line 60

def package_groups_match?(source_repo, target_repo)
  source_repo_ids = source_repo.package_groups.order(:name).pluck(:name).uniq
  target_repo_ids = target_repo.package_groups.order(:name).pluck(:name).uniq
  source_repo_ids == target_repo_ids
end

#rpms_match?(source_repo, target_repo) ⇒ Boolean

Returns:

  • (Boolean)


48
49
50
51
52
# File 'app/lib/actions/katello/repository/check_matching_content.rb', line 48

def rpms_match?(source_repo, target_repo)
  source_repo_ids = source_repo.rpm_ids.sort.uniq
  target_repo_ids = target_repo.rpm_ids.sort.uniq
  source_repo_ids == target_repo_ids
end

#runObject

Check if content in the repositories has changed. We can use this info to skip regenerating metadata in pulp, keeping the revision number on the repo the same



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/lib/actions/katello/repository/check_matching_content.rb', line 13

def run
  source_repo = ::Katello::Repository.find(input[:source_repo_id])
  target_repo = ::Katello::Repository.find(input[:target_repo_id])
  target_repo_published = target_repo.backend_service(SmartProxy.pulp_primary).published?

  if source_repo.content_type == ::Katello::Repository::YUM_TYPE
    srpms_match = srpms_match?(source_repo, target_repo)
    rpms = rpms_match?(source_repo, target_repo)
    errata = errata_match?(source_repo, target_repo)
    package_groups = package_groups_match?(source_repo, target_repo)
    distributions = distributions_match?(source_repo, target_repo)
     = (source_repo, target_repo)
    checksum_match = (target_repo.saved_checksum_type == source_repo.saved_checksum_type)

    output[:checksum_match] = checksum_match
    output[:matching_content] =  && srpms_match && rpms && errata && package_groups && distributions && target_repo_published && checksum_match
  end

  if source_repo.content_type == ::Katello::Repository::DEB_TYPE
    debs = debs_match?(source_repo, target_repo)

    output[:matching_content] = debs && target_repo_published
  end
end

#srpms_match?(source_repo, target_repo) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
45
46
# File 'app/lib/actions/katello/repository/check_matching_content.rb', line 42

def srpms_match?(source_repo, target_repo)
  source_repo_ids = source_repo.srpm_ids.sort.uniq
  target_repo_ids = target_repo.srpm_ids.sort.uniq
  source_repo_ids == target_repo_ids
end

#yum_metadata_files_match?(source_repo, target_repo) ⇒ Boolean

Returns:

  • (Boolean)


70
71
72
73
74
# File 'app/lib/actions/katello/repository/check_matching_content.rb', line 70

def (source_repo, target_repo)
  source_repo_items = source_repo..pluck(:name, :checksum).sort.uniq
  target_repo_items = target_repo..pluck(:name, :checksum).sort.uniq
  source_repo_items == target_repo_items
end