katello 3.14.1 → 3.15.0.rc1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of katello might be problematic. Click here for more details.

Files changed (167) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/katello/api/rhsm/candlepin_proxies_controller.rb +1 -1
  3. data/app/controllers/katello/api/v2/products_bulk_actions_controller.rb +3 -3
  4. data/app/controllers/katello/api/v2/repositories_controller.rb +1 -1
  5. data/app/helpers/katello/hosts_and_hostgroups_helper.rb +1 -1
  6. data/app/lib/actions/katello/content_view/publish.rb +2 -0
  7. data/app/lib/actions/katello/content_view_version/incremental_update.rb +1 -0
  8. data/app/lib/actions/katello/host/reassign.rb +1 -2
  9. data/app/lib/actions/katello/host/update_content_view.rb +1 -1
  10. data/app/lib/actions/katello/host/update_release_version.rb +1 -1
  11. data/app/lib/actions/katello/organization/manifest_refresh.rb +1 -1
  12. data/app/lib/actions/katello/product/update_http_proxy.rb +1 -1
  13. data/app/lib/actions/katello/repository/clone_contents.rb +1 -1
  14. data/app/lib/actions/katello/repository/clone_to_environment.rb +2 -1
  15. data/app/lib/actions/katello/repository/create.rb +1 -1
  16. data/app/lib/actions/katello/repository/metadata_generate.rb +2 -8
  17. data/app/lib/actions/katello/repository/refresh_repository.rb +5 -1
  18. data/app/lib/actions/katello/repository/sync.rb +6 -1
  19. data/app/lib/actions/middleware/execute_if_contents_changed.rb +1 -1
  20. data/app/lib/actions/pulp/orchestration/repository/refresh_if_needed.rb +1 -1
  21. data/app/lib/actions/pulp/repository/clear.rb +1 -1
  22. data/app/lib/actions/pulp/repository/remove_units.rb +1 -1
  23. data/app/lib/actions/pulp3/abstract_async_task.rb +1 -2
  24. data/app/lib/actions/pulp3/capsule_content/generate_metadata.rb +1 -1
  25. data/app/lib/actions/pulp3/capsule_content/refresh_distribution.rb +2 -2
  26. data/app/lib/actions/pulp3/capsule_content/sync.rb +1 -1
  27. data/app/lib/actions/pulp3/content_migration.rb +17 -0
  28. data/app/lib/actions/pulp3/import_migration.rb +14 -0
  29. data/app/lib/actions/pulp3/orchestration/orphan_cleanup/remove_orphans.rb +4 -1
  30. data/app/lib/actions/pulp3/orchestration/repository/copy_all_units.rb +3 -3
  31. data/app/lib/actions/pulp3/orchestration/repository/create.rb +3 -1
  32. data/app/lib/actions/pulp3/orchestration/repository/generate_metadata.rb +0 -2
  33. data/app/lib/actions/pulp3/orchestration/repository/import_upload.rb +1 -1
  34. data/app/lib/actions/pulp3/orchestration/repository/refresh_if_needed.rb +18 -0
  35. data/app/lib/actions/pulp3/orchestration/repository/refresh_repos.rb +1 -1
  36. data/app/lib/actions/pulp3/orchestration/repository/remove_units.rb +1 -1
  37. data/app/lib/actions/pulp3/orchestration/repository/sync.rb +1 -1
  38. data/app/lib/actions/pulp3/orchestration/repository/upload_content.rb +1 -1
  39. data/app/lib/actions/pulp3/orphan_cleanup/delete_orphan_distributions.rb +16 -0
  40. data/app/lib/actions/pulp3/orphan_cleanup/delete_orphan_remotes.rb +16 -0
  41. data/app/lib/actions/pulp3/orphan_cleanup/delete_orphan_repository_versions.rb +1 -6
  42. data/app/lib/actions/pulp3/orphan_cleanup/remove_orphans.rb +15 -0
  43. data/app/lib/actions/pulp3/orphan_cleanup/remove_unneeded_repos.rb +2 -2
  44. data/app/lib/actions/pulp3/repository/create.rb +1 -1
  45. data/app/lib/actions/pulp3/repository/create_publication.rb +1 -1
  46. data/app/lib/actions/pulp3/repository/presenters/content_unit_presenter.rb +1 -0
  47. data/app/lib/actions/pulp3/repository/refresh_distribution.rb +4 -2
  48. data/app/lib/actions/pulp3/repository/save_version.rb +12 -8
  49. data/app/lib/actions/pulp3/repository/upload_file.rb +2 -2
  50. data/app/lib/katello/api/v2/rendering.rb +1 -0
  51. data/app/lib/katello/concerns/base_template_scope_extensions.rb +5 -1
  52. data/app/lib/katello/http_resource.rb +4 -1
  53. data/app/lib/katello/resources/registry.rb +9 -2
  54. data/app/models/katello/concerns/content_facet_host_extensions.rb +1 -0
  55. data/app/models/katello/concerns/organization_extensions.rb +4 -4
  56. data/app/models/katello/concerns/smart_proxy_extensions.rb +33 -7
  57. data/app/models/katello/concerns/subscription_facet_host_extensions.rb +34 -12
  58. data/app/models/katello/content_view_docker_filter.rb +1 -1
  59. data/app/models/katello/content_view_version.rb +20 -47
  60. data/app/models/katello/glue/candlepin/owner.rb +4 -0
  61. data/app/models/katello/glue/candlepin/product.rb +12 -6
  62. data/app/models/katello/glue/pulp/repos.rb +6 -3
  63. data/app/models/katello/host/subscription_facet.rb +4 -5
  64. data/app/models/katello/ping.rb +3 -4
  65. data/app/models/katello/pool.rb +1 -1
  66. data/app/models/katello/pulp3/distribution_reference.rb +1 -1
  67. data/app/models/katello/repository.rb +14 -0
  68. data/app/models/katello/root_repository.rb +0 -2
  69. data/app/models/katello/subscription_status.rb +7 -0
  70. data/app/models/setting/content.rb +10 -3
  71. data/app/services/katello/candlepin/consumer.rb +1 -0
  72. data/app/services/katello/pulp/repository.rb +1 -1
  73. data/app/services/katello/pulp/repository/deb.rb +2 -0
  74. data/app/services/katello/pulp/repository/docker.rb +2 -0
  75. data/app/services/katello/pulp/repository/file.rb +2 -0
  76. data/app/services/katello/pulp/repository/yum.rb +9 -5
  77. data/app/services/katello/pulp3/ansible_collection.rb +1 -1
  78. data/app/services/katello/pulp3/api/ansible_collection.rb +46 -0
  79. data/app/services/katello/pulp3/api/core.rb +159 -0
  80. data/app/services/katello/pulp3/api/docker.rb +62 -0
  81. data/app/services/katello/pulp3/api/file.rb +54 -0
  82. data/app/services/katello/pulp3/api/yum.rb +54 -0
  83. data/app/services/katello/pulp3/distribution.rb +17 -0
  84. data/app/services/katello/pulp3/docker_blob.rb +1 -1
  85. data/app/services/katello/pulp3/docker_manifest.rb +1 -1
  86. data/app/services/katello/pulp3/docker_manifest_list.rb +1 -1
  87. data/app/services/katello/pulp3/docker_tag.rb +1 -1
  88. data/app/services/katello/pulp3/erratum.rb +109 -0
  89. data/app/services/katello/pulp3/file_unit.rb +1 -1
  90. data/app/services/katello/pulp3/migration.rb +71 -0
  91. data/app/services/katello/pulp3/migration_plan.rb +27 -0
  92. data/app/services/katello/pulp3/module_stream.rb +47 -0
  93. data/app/services/katello/pulp3/package_group.rb +66 -0
  94. data/app/services/katello/pulp3/pulp_content_unit.rb +9 -1
  95. data/app/services/katello/pulp3/repository.rb +118 -348
  96. data/app/services/katello/pulp3/repository/ansible_collection.rb +1 -29
  97. data/app/services/katello/pulp3/repository/docker.rb +23 -43
  98. data/app/services/katello/pulp3/repository/file.rb +1 -37
  99. data/app/services/katello/pulp3/repository/yum.rb +36 -37
  100. data/app/services/katello/pulp3/repository_mirror.rb +171 -0
  101. data/app/services/katello/pulp3/rpm.rb +143 -0
  102. data/app/services/katello/pulp3/smart_proxy_mirror_repository.rb +92 -0
  103. data/app/services/katello/pulp3/smart_proxy_repository.rb +38 -9
  104. data/app/services/katello/pulp3/srpm.rb +74 -0
  105. data/app/services/katello/pulp3/yum_metadata_file.rb +20 -0
  106. data/app/services/katello/registration_manager.rb +12 -11
  107. data/app/services/katello/repository_type.rb +11 -3
  108. data/app/services/katello/repository_type_manager.rb +11 -0
  109. data/app/views/dashboard/_subscription_widget.html.erb +6 -1
  110. data/app/views/katello/api/v2/content_view_versions/base.json.rabl +4 -11
  111. data/app/views/katello/api/v2/docker_manifest_lists/show.json.rabl +2 -1
  112. data/app/views/katello/api/v2/docker_manifests/show.json.rabl +2 -1
  113. data/app/views/katello/api/v2/package_groups/show.json.rabl +1 -1
  114. data/app/views/katello/api/v2/packages/show.json.rabl +2 -1
  115. data/app/views/katello/api/v2/repositories/base.json.rabl +2 -0
  116. data/app/views/katello/api/v2/repositories/show.json.rabl +2 -1
  117. data/app/views/katello/api/v2/smart_proxies/pulp_info.json.rabl +2 -0
  118. data/app/views/katello/api/v2/subscription_facet/show.json.rabl +1 -1
  119. data/app/views/smart_proxies/plugins/_pulp3.html.erb +19 -0
  120. data/app/views/smart_proxies/pulp_status.html.erb +10 -0
  121. data/db/migrate/20190930192813_add_pulp3_hrefs_to_content_types.rb +10 -0
  122. data/db/migrate/20191204020703_migrate_distribution_reference_to_use_repo_id.rb +22 -0
  123. data/db/migrate/20191204214919_add_content_view_version_counts.rb +7 -0
  124. data/db/migrate/20191213161248_add_dmi_uuid_to_katello_subscription_facets.rb +6 -0
  125. data/db/migrate/20200109162354_drop_host_update_lock_setting.rb +5 -0
  126. data/db/seeds.d/104-proxy.rb +1 -1
  127. data/db/seeds.d/111-upgrade_tasks.rb +3 -1
  128. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/bulk/content-hosts-bulk-subscriptions-modal.controller.js +3 -2
  129. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/bulk/views/content-hosts-bulk-subscriptions-modal.html +8 -3
  130. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/views/content-host-info.html +2 -2
  131. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/components/views/content-view-composite-available-content-views.html +1 -1
  132. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/components/views/content-view-composite-content-views-list.html +1 -1
  133. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/bulk/views/products-bulk-http-proxy-modal.html +3 -3
  134. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-info.html +2 -2
  135. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/new/views/new-repository.html +2 -2
  136. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/views/product-repositories.html +4 -1
  137. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/views/products.html +1 -1
  138. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/views/content-access-mode-banner.html +1 -1
  139. data/lib/katello/engine.rb +25 -25
  140. data/lib/katello/plugin.rb +1 -1
  141. data/lib/katello/repository_types/ansible_collection.rb +1 -0
  142. data/lib/katello/repository_types/docker.rb +2 -1
  143. data/lib/katello/repository_types/file.rb +1 -1
  144. data/lib/katello/repository_types/yum.rb +29 -7
  145. data/lib/katello/tasks/pulp3_content_switchover.rake +21 -0
  146. data/lib/katello/tasks/pulp3_migration.rake +21 -0
  147. data/lib/katello/tasks/reset.rake +43 -16
  148. data/lib/katello/tasks/update_content_default_http_proxy.rake +3 -3
  149. data/lib/katello/tasks/upgrades/3.15/reindex_rpm_modular.rake +23 -0
  150. data/lib/katello/tasks/upgrades/3.15/set_sub_facet_dmi_uuid.rake +16 -0
  151. data/lib/katello/version.rb +1 -1
  152. data/package.json +9 -10
  153. data/webpack/components/WithOrganization/__snapshots__/withOrganization.test.js.snap +0 -63
  154. data/webpack/redux/actions/RedHatRepositories/helpers.js +5 -5
  155. data/webpack/redux/reducers/RedHatRepositories/repositorySetRepositories.js +17 -2
  156. data/webpack/scenes/RedHatRepositories/components/RepositorySet.js +1 -0
  157. data/webpack/scenes/RedHatRepositories/components/RepositorySetRepositories.js +1 -1
  158. data/webpack/scenes/RedHatRepositories/components/RepositorySetRepository/RepositorySetRepository.js +2 -3
  159. data/webpack/scenes/RedHatRepositories/components/__tests__/RepositorySetRepositories.test.js +44 -28
  160. data/webpack/scenes/RedHatRepositories/components/__tests__/__snapshots__/RepositorySetRepositories.test.js.snap +77 -45
  161. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/__snapshots__/UpstreamSubscriptionsPage.test.js.snap +2 -6
  162. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/__tests__/__snapshots__/SubscriptionTypeFormatter.test.js.snap +0 -1
  163. data/webpack/test_setup.js +3 -1
  164. metadata +62 -24
  165. data/app/lib/actions/katello/host/update.rb +0 -84
  166. data/app/lib/actions/pulp3/repository/create_version.rb +0 -19
  167. data/app/views/katello/api/v2/smart_proxies/download_policy.json.rabl +0 -1
@@ -0,0 +1,46 @@
1
+ require "pulpcore_client"
2
+ # rubocop:disable ClassLength
3
+
4
+ module Katello
5
+ module Pulp3
6
+ module Api
7
+ class AnsibleCollection < Core
8
+ def self.api_exception_class
9
+ PulpAnsibleClient::ApiError
10
+ end
11
+
12
+ def self.client_module
13
+ PulpAnsibleClient
14
+ end
15
+
16
+ def self.remote_class
17
+ PulpAnsibleClient::AnsibleCollectionRemote
18
+ end
19
+
20
+ def self.distribution_class
21
+ PulpAnsibleClient::AnsibleAnsibleDistribution
22
+ end
23
+
24
+ def api_client
25
+ PulpAnsibleClient::ApiClient.new(smart_proxy.pulp3_configuration(PulpAnsibleClient::Configuration))
26
+ end
27
+
28
+ def repositories_api
29
+ PulpAnsibleClient::RepositoriesAnsibleApi.new(api_client)
30
+ end
31
+
32
+ def repository_versions_api
33
+ PulpAnsibleClient::RepositoriesAnsibleVersionsApi.new(api_client)
34
+ end
35
+
36
+ def remotes_api
37
+ PulpAnsibleClient::RemotesCollectionApi.new(api_client)
38
+ end
39
+
40
+ def distributions_api
41
+ PulpAnsibleClient::DistributionsAnsibleApi.new(api_client)
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,159 @@
1
+ require "pulpcore_client"
2
+ # rubocop:disable ClassLength
3
+
4
+ module Katello
5
+ module Pulp3
6
+ module Api
7
+ class Core
8
+ attr_accessor :smart_proxy
9
+
10
+ def initialize(smart_proxy)
11
+ @smart_proxy = smart_proxy
12
+ end
13
+
14
+ def self.api_exception_class
15
+ fail NotImplementedError
16
+ end
17
+
18
+ def self.client_module
19
+ fail NotImplementedError
20
+ end
21
+
22
+ def self.remote_class
23
+ fail NotImplementedError
24
+ end
25
+
26
+ def self.distribution_class
27
+ fail NotImplementedError
28
+ end
29
+
30
+ def self.publication_class
31
+ fail NotImplementedError
32
+ end
33
+
34
+ def api_client
35
+ fail NotImplementedError
36
+ end
37
+
38
+ def remotes_api
39
+ fail NotImplementedError
40
+ end
41
+
42
+ def publications_api
43
+ fail NotImplementedError #Optional
44
+ end
45
+
46
+ def distributions_api
47
+ fail NotImplementedError
48
+ end
49
+
50
+ def repositories_api
51
+ fail NotImplementedError
52
+ end
53
+
54
+ def repository_versions_api
55
+ fail NotImplementedError
56
+ end
57
+
58
+ def orphans_api
59
+ PulpcoreClient::OrphansApi.new(core_api_client)
60
+ end
61
+
62
+ def core_api_client
63
+ PulpcoreClient::ApiClient.new(smart_proxy.pulp3_configuration(PulpcoreClient::Configuration))
64
+ end
65
+
66
+ def uploads_api
67
+ PulpcoreClient::UploadsApi.new(core_api_client)
68
+ end
69
+
70
+ def tasks_api
71
+ PulpcoreClient::TasksApi.new(core_api_client)
72
+ end
73
+
74
+ def upload_class
75
+ PulpcoreClient::Upload
76
+ end
77
+
78
+ def delete_orphans
79
+ [orphans_api.delete]
80
+ end
81
+
82
+ def delete_remote(remote_href)
83
+ remotes_api.delete(remote_href)
84
+ end
85
+
86
+ def repository_versions(options = {})
87
+ current_pulp_repositories = self.list_all(options)
88
+ repo_hrefs = current_pulp_repositories.collect { |repo| repo.pulp_href }.uniq
89
+
90
+ version_hrefs = repo_hrefs.collect do |href|
91
+ versions_list_for_repository(href, options).map(&:pulp_href)
92
+ end
93
+
94
+ version_hrefs.flatten.uniq
95
+ end
96
+
97
+ def versions_list_for_repository(repository_href, options)
98
+ self.class.fetch_from_list { |page_opts| repository_versions_api.list(repository_href, page_opts.merge(options)) }
99
+ end
100
+
101
+ def distributions_list_all(args = {})
102
+ self.class.fetch_from_list do |page_opts|
103
+ distributions_api.list(page_opts.merge(args))
104
+ end
105
+ end
106
+
107
+ def get_distribution(href)
108
+ distributions_api.read(href)
109
+ rescue self.class.api_exception_class => e
110
+ raise e if e.code != 404
111
+ nil
112
+ end
113
+
114
+ def delete_distribution(href)
115
+ distributions_api.delete(href)
116
+ rescue self.class.api_exception_class => e
117
+ raise e if e.code != 404
118
+ nil
119
+ end
120
+
121
+ def list_all(options = {})
122
+ self.class.fetch_from_list do |page_opts|
123
+ repositories_api.list(page_opts.merge(options))
124
+ end
125
+ end
126
+
127
+ def remotes_list(args = {})
128
+ remotes_api.list(args).results
129
+ end
130
+
131
+ def remotes_list_all(_smart_proxy, options)
132
+ self.class.fetch_from_list do |page_opts|
133
+ remotes_api.list(page_opts.merge(options))
134
+ end
135
+ end
136
+
137
+ def self.fetch_from_list
138
+ page_size = SETTINGS[:katello][:pulp][:bulk_load_size]
139
+ page_opts = { "offset" => 0, limit: page_size }
140
+ response = {}
141
+
142
+ results = []
143
+
144
+ loop do
145
+ page_opts = page_opts.with_indifferent_access
146
+ break unless (
147
+ (response.count && (page_opts['offset'] < response.count)) ||
148
+ page_opts["offset"] == 0)
149
+ response = yield page_opts
150
+ results = results.concat(response.results)
151
+ page_opts[:offset] += page_size
152
+ end
153
+
154
+ results
155
+ end
156
+ end
157
+ end
158
+ end
159
+ end
@@ -0,0 +1,62 @@
1
+ require "pulpcore_client"
2
+ # rubocop:disable ClassLength
3
+
4
+ module Katello
5
+ module Pulp3
6
+ module Api
7
+ class Docker < Core
8
+ def self.api_exception_class
9
+ PulpContainerClient::ApiError
10
+ end
11
+
12
+ def self.client_module
13
+ PulpContainerClient
14
+ end
15
+
16
+ def self.remote_class
17
+ PulpContainerClient::ContainerContainerRemote
18
+ end
19
+
20
+ def self.distribution_class
21
+ PulpContainerClient::ContainerContainerDistribution
22
+ end
23
+
24
+ def self.publication_class
25
+ PulpContainerClient::ContainerPublication
26
+ end
27
+
28
+ def self.recursive_manage_class
29
+ PulpContainerClient::RecursiveManage
30
+ end
31
+
32
+ def api_client
33
+ PulpContainerClient::ApiClient.new(smart_proxy.pulp3_configuration(PulpContainerClient::Configuration))
34
+ end
35
+
36
+ def repositories_api
37
+ PulpContainerClient::RepositoriesContainerApi.new(api_client)
38
+ end
39
+
40
+ def repository_versions_api
41
+ PulpContainerClient::RepositoriesContainerVersionsApi.new(api_client)
42
+ end
43
+
44
+ def remotes_api
45
+ PulpContainerClient::RemotesContainerApi.new(api_client)
46
+ end
47
+
48
+ def publications_api
49
+ PulpContainerClient::PublicationsContainerApi.new(api_client)
50
+ end
51
+
52
+ def distributions_api
53
+ PulpContainerClient::DistributionsContainerApi.new(api_client)
54
+ end
55
+
56
+ def recursive_add_api
57
+ PulpContainerClient::ContainerRecursiveAddApi.new(api_client)
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,54 @@
1
+ require "pulpcore_client"
2
+ # rubocop:disable ClassLength
3
+
4
+ module Katello
5
+ module Pulp3
6
+ module Api
7
+ class File < Core
8
+ def self.api_exception_class
9
+ PulpFileClient::ApiError
10
+ end
11
+
12
+ def self.client_module
13
+ PulpFileClient
14
+ end
15
+
16
+ def self.remote_class
17
+ PulpFileClient::FileFileRemote
18
+ end
19
+
20
+ def self.distribution_class
21
+ PulpFileClient::FileFileDistribution
22
+ end
23
+
24
+ def self.publication_class
25
+ PulpFileClient::FileFilePublication
26
+ end
27
+
28
+ def api_client
29
+ PulpFileClient::ApiClient.new(smart_proxy.pulp3_configuration(PulpFileClient::Configuration))
30
+ end
31
+
32
+ def repositories_api
33
+ PulpFileClient::RepositoriesFileApi.new(api_client)
34
+ end
35
+
36
+ def repository_versions_api
37
+ PulpFileClient::RepositoriesFileVersionsApi.new(api_client)
38
+ end
39
+
40
+ def remotes_api
41
+ PulpFileClient::RemotesFileApi.new(api_client)
42
+ end
43
+
44
+ def publications_api
45
+ PulpFileClient::PublicationsFileApi.new(api_client)
46
+ end
47
+
48
+ def distributions_api
49
+ PulpFileClient::DistributionsFileApi.new(api_client)
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,54 @@
1
+ require "pulpcore_client"
2
+ # rubocop:disable ClassLength
3
+
4
+ module Katello
5
+ module Pulp3
6
+ module Api
7
+ class Yum < Core
8
+ def self.api_exception_class
9
+ PulpRpmClient::ApiError
10
+ end
11
+
12
+ def self.client_module
13
+ PulpRpmClient
14
+ end
15
+
16
+ def self.remote_class
17
+ PulpRpmClient::RpmRpmRemote
18
+ end
19
+
20
+ def self.distribution_class
21
+ PulpRpmClient::RpmRpmDistribution
22
+ end
23
+
24
+ def self.publication_class
25
+ PulpRpmClient::RpmRpmPublication
26
+ end
27
+
28
+ def api_client
29
+ PulpRpmClient::ApiClient.new(smart_proxy.pulp3_configuration(PulpRpmClient::Configuration))
30
+ end
31
+
32
+ def repositories_api
33
+ PulpRpmClient::RepositoriesRpmApi.new(api_client)
34
+ end
35
+
36
+ def repository_versions_api
37
+ PulpRpmClient::RepositoriesRpmVersionsApi.new(api_client)
38
+ end
39
+
40
+ def remotes_api
41
+ PulpRpmClient::RemotesRpmApi.new(api_client)
42
+ end
43
+
44
+ def publications_api
45
+ PulpRpmClient::PublicationsRpmApi.new(api_client)
46
+ end
47
+
48
+ def distributions_api
49
+ PulpRpmClient::DistributionsRpmApi.new(api_client)
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,17 @@
1
+ module Katello
2
+ module Pulp3
3
+ class Distribution < PulpContentUnit
4
+ include LazyAccessor
5
+
6
+ def self.content_api
7
+ PulpRpmClient::ContentDistributionTreesApi.new(Katello::Pulp3::Api::Yum.new(SmartProxy.pulp_master!).api_client)
8
+ end
9
+
10
+ def self.ids_for_repository(repo_id)
11
+ repo = Katello::Pulp3::Repository::Yum.new(Katello::Repository.find(repo_id), SmartProxy.pulp_master)
12
+ repo_content_list = repo.content_list
13
+ repo_content_list.map { |content| content.try(:pulp_href) }
14
+ end
15
+ end
16
+ end
17
+ end
@@ -4,7 +4,7 @@ module Katello
4
4
  include LazyAccessor
5
5
 
6
6
  def self.content_api
7
- PulpDockerClient::ContentBlobsApi.new(Katello::Pulp3::Repository::Docker.api_client(SmartProxy.pulp_master!))
7
+ PulpContainerClient::ContentBlobsApi.new(Katello::Pulp3::Api::Docker.new(SmartProxy.pulp_master!).api_client)
8
8
  end
9
9
 
10
10
  def self.ids_for_repository(repo_id)
@@ -4,7 +4,7 @@ module Katello
4
4
  include LazyAccessor
5
5
 
6
6
  def self.content_api
7
- PulpDockerClient::ContentManifestsApi.new(Katello::Pulp3::Repository::Docker.api_client(SmartProxy.pulp_master!))
7
+ PulpContainerClient::ContentManifestsApi.new(Katello::Pulp3::Api::Docker.new(SmartProxy.pulp_master!).api_client)
8
8
  end
9
9
 
10
10
  def self.ids_for_repository(repo_id)
@@ -4,7 +4,7 @@ module Katello
4
4
  include LazyAccessor
5
5
 
6
6
  def self.content_api
7
- PulpDockerClient::ContentManifestsApi.new(Katello::Pulp3::Repository::Docker.api_client(SmartProxy.pulp_master!))
7
+ PulpContainerClient::ContentManifestsApi.new(Katello::Pulp3::Api::Docker.new(SmartProxy.pulp_master!).api_client)
8
8
  end
9
9
 
10
10
  def self.ids_for_repository(repo_id)
@@ -4,7 +4,7 @@ module Katello
4
4
  include LazyAccessor
5
5
 
6
6
  def self.content_api
7
- PulpDockerClient::ContentTagsApi.new(Katello::Pulp3::Repository::Docker.api_client(SmartProxy.pulp_master!))
7
+ PulpContainerClient::ContentTagsApi.new(Katello::Pulp3::Api::Docker.new(SmartProxy.pulp_master!).api_client)
8
8
  end
9
9
 
10
10
  def self.ids_for_repository(repo_id)
@@ -0,0 +1,109 @@
1
+ module Katello
2
+ module Pulp3
3
+ class Erratum < PulpContentUnit
4
+ include LazyAccessor
5
+
6
+ def self.content_api
7
+ PulpRpmClient::ContentAdvisoriesApi.new(Katello::Pulp3::Api::Yum.new(SmartProxy.pulp_master!).api_client)
8
+ end
9
+
10
+ def self.ids_for_repository(repo_id)
11
+ repo = Katello::Pulp3::Repository::Yum.new(Katello::Repository.find(repo_id), SmartProxy.pulp_master)
12
+ repo_content_list = repo.content_list
13
+ repo_content_list.map { |content| content.try(:pulp_href) }
14
+ end
15
+
16
+ def update_model(model)
17
+ keys = %w(title id severity issued type description reboot_suggested solution updated summary)
18
+ custom_json = backend_data.slice(*keys)
19
+
20
+ # handle SUSE epoch dates
21
+ custom_json["issued"] = convert_date_if_epoch(custom_json["issued"])
22
+ custom_json["updated"] = convert_date_if_epoch(custom_json["updated"]) unless custom_json["updated"].blank?
23
+
24
+ if model.updated.blank? || (custom_json['updated'].to_datetime != model.updated.to_datetime)
25
+ custom_json['errata_id'] = custom_json.delete('id')
26
+ custom_json['errata_type'] = custom_json.delete('type')
27
+ custom_json['updated'] = custom_json['updated'].blank? ? custom_json['issued'] : custom_json['updated']
28
+ model.update_attributes!(custom_json)
29
+
30
+ unless backend_data['references'].blank?
31
+ update_bugzillas(model, backend_data['references'])
32
+ update_cves(model, backend_data['references'])
33
+ end
34
+ end
35
+ update_packages(model, backend_data['pkglist']) unless backend_data['pkglist'].blank?
36
+ update_modules(model, backend_data['pkglist']) unless backend_data['pkglist'].blank?
37
+ end
38
+
39
+ def update_bugzillas(model, ref_list)
40
+ ref_list.select { |r| r[:type] == "bugzilla" }.each do |bugzilla|
41
+ Katello::Util::Support.active_record_retry do
42
+ model.bugzillas.where(bug_id: bugzilla[:id]).first_or_create!(bug_id: bugzilla[:id], href: bugzilla[:href], erratum_id: model.id)
43
+ end
44
+ end
45
+ end
46
+
47
+ def update_cves(model, ref_list)
48
+ ref_list.select { |r| r[:type] == "cve" }.each do |cve|
49
+ Katello::Util::Support.active_record_retry do
50
+ model.cves.where(cve_id: cve[:id]).first_or_create!(cve_id: cve[:id], href: cve[:href], erratum_id: model.id)
51
+ end
52
+ end
53
+ end
54
+
55
+ def update_packages(model, package_list)
56
+ package_list.each do |json|
57
+ package_hashes = json[:packages]
58
+ package_attributes = package_hashes.map do |hash|
59
+ nvrea = Util::Package.build_nvra(hash)
60
+ {'name' => hash[:name], 'nvrea' => nvrea, 'filename' => hash[:filename]}
61
+ end
62
+ existing_nvreas = model.packages.pluck(:nvrea)
63
+ package_attributes.delete_if { |pkg| existing_nvreas.include?(pkg['nvrea']) }
64
+ package_attributes.uniq.each do |package|
65
+ Katello::Util::Support.active_record_retry do
66
+ model.packages.where(filename: package["filename"]).first_or_create!(package)
67
+ end
68
+ end
69
+ end
70
+ end
71
+
72
+ def update_modules(model, module_stream_list)
73
+ module_stream_attributes = []
74
+ module_stream_list.each do |package_item|
75
+ if package_item[:module]
76
+ module_stream = ::Katello::ModuleStream.where(package_item[:module]).first
77
+ next if module_stream.blank?
78
+ nvreas = package_item[:packages].map { |hash| Util::Package.build_nvra(hash) }
79
+ module_stream_id_column = "#{ModuleStreamErratumPackage.table_name}.module_stream_id"
80
+ existing = ErratumPackage.joins(:module_streams).
81
+ where(module_stream_id_column => module_stream.id,
82
+ :nvrea => nvreas).pluck(:nvrea)
83
+
84
+ (nvreas - existing).each do |nvrea|
85
+ package = model.packages.find_by(:nvrea => nvrea)
86
+ module_stream_attributes << { :module_stream_id => module_stream.id,
87
+ :erratum_package_id => package.id }
88
+ end
89
+ end
90
+ end
91
+ module_stream_attributes.uniq.each do |module_stream|
92
+ Katello::Util::Support.active_record_retry do
93
+ if model.module_streams.empty? || !model.module_streams.pluck(:module_stream_id).include?(module_stream[:module_stream_id])
94
+ ModuleStreamErratumPackage.create!(module_stream)
95
+ end
96
+ end
97
+ end
98
+ end
99
+
100
+ def convert_date_if_epoch(date)
101
+ date.to_i.to_s == date ? epoch_to_date(date) : date
102
+ end
103
+
104
+ def epoch_to_date(epoch)
105
+ Time.at(epoch.to_i).to_s
106
+ end
107
+ end
108
+ end
109
+ end