katello 3.18.5 → 4.0.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 (239) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/katello/katello.scss +72 -0
  3. data/app/controllers/katello/api/registry/registry_proxies_controller.rb +6 -4
  4. data/app/controllers/katello/api/rhsm/candlepin_dynflow_proxy_controller.rb +0 -19
  5. data/app/controllers/katello/api/rhsm/candlepin_proxies_controller.rb +1 -3
  6. data/app/controllers/katello/api/v2/content_credentials_controller.rb +24 -24
  7. data/app/controllers/katello/api/v2/content_export_incrementals_controller.rb +1 -1
  8. data/app/controllers/katello/api/v2/content_exports_controller.rb +4 -0
  9. data/app/controllers/katello/api/v2/content_views_controller.rb +2 -2
  10. data/app/controllers/katello/api/v2/host_subscriptions_controller.rb +2 -3
  11. data/app/controllers/katello/api/v2/repositories_controller.rb +3 -19
  12. data/app/controllers/katello/api/v2/simple_content_access_controller.rb +34 -0
  13. data/app/controllers/katello/api/v2/subscriptions_controller.rb +1 -1
  14. data/app/controllers/katello/api/v2/upstream_subscriptions_controller.rb +8 -4
  15. data/app/controllers/katello/concerns/api/v2/authorization.rb +1 -14
  16. data/app/controllers/katello/concerns/authorization/api/v2/content_views_controller.rb +1 -1
  17. data/app/helpers/katello/sync_management_helper.rb +0 -2
  18. data/app/lib/actions/candlepin/environment/create.rb +1 -1
  19. data/app/lib/actions/candlepin/environment/set_content.rb +1 -1
  20. data/app/lib/actions/katello/activation_key/create.rb +9 -11
  21. data/app/lib/actions/katello/capsule_content/sync.rb +8 -8
  22. data/app/lib/actions/katello/capsule_content/sync_capsule.rb +9 -0
  23. data/app/lib/actions/katello/check_matching_content.rb +17 -0
  24. data/app/lib/actions/katello/content_view/environment_create.rb +6 -8
  25. data/app/lib/actions/katello/content_view/publish.rb +1 -1
  26. data/app/lib/actions/katello/content_view_version/incremental_update.rb +11 -7
  27. data/app/lib/actions/katello/host/hypervisors_update.rb +4 -4
  28. data/app/lib/actions/katello/organization/create.rb +3 -5
  29. data/app/lib/actions/katello/organization/destroy.rb +1 -1
  30. data/app/lib/actions/katello/organization/manifest_delete.rb +3 -5
  31. data/app/lib/actions/katello/organization/manifest_import.rb +1 -1
  32. data/app/lib/actions/katello/organization/manifest_refresh.rb +1 -1
  33. data/app/lib/actions/katello/orphan_cleanup/remove_orphans.rb +1 -1
  34. data/app/lib/actions/katello/repository/check_matching_content.rb +3 -1
  35. data/app/lib/actions/katello/repository/clone_contents.rb +8 -11
  36. data/app/lib/actions/katello/repository/create.rb +0 -8
  37. data/app/lib/actions/katello/repository/filtered_index_content.rb +3 -0
  38. data/app/lib/actions/katello/repository/index_content.rb +1 -0
  39. data/app/lib/actions/katello/repository/multi_clone_contents.rb +9 -12
  40. data/app/lib/actions/katello/repository/sync.rb +1 -5
  41. data/app/lib/actions/katello/repository/update.rb +0 -8
  42. data/app/lib/actions/middleware/execute_if_contents_changed.rb +4 -1
  43. data/app/lib/actions/pulp/orchestration/repository/refresh_repos.rb +0 -6
  44. data/app/lib/actions/pulp3/capsule_content/refresh_distribution.rb +3 -3
  45. data/app/lib/actions/pulp3/content_guard/refresh_all_distributions.rb +1 -2
  46. data/app/lib/actions/pulp3/content_migration_presenter.rb +2 -5
  47. data/app/lib/actions/pulp3/orchestration/repository/refresh_repos.rb +1 -6
  48. data/app/lib/katello/concerns/base_template_scope_extensions.rb +8 -0
  49. data/app/lib/katello/errors.rb +1 -1
  50. data/app/lib/katello/event_daemon/monitor.rb +53 -0
  51. data/app/lib/katello/event_daemon/runner.rb +99 -0
  52. data/app/lib/katello/logging.rb +32 -0
  53. data/app/lib/katello/messaging/connection.rb +1 -7
  54. data/app/lib/katello/util/pulpcore_content_filters.rb +1 -1
  55. data/app/lib/katello/validators/content_view_puppet_module_validator.rb +1 -1
  56. data/app/models/katello/activation_key.rb +2 -2
  57. data/app/models/katello/candlepin/repository_mapper.rb +1 -1
  58. data/app/models/katello/concerns/hostgroup_extensions.rb +2 -4
  59. data/app/models/katello/concerns/organization_extensions.rb +2 -2
  60. data/app/models/katello/concerns/pulp_database_unit.rb +0 -12
  61. data/app/models/katello/concerns/redhat_extensions.rb +8 -9
  62. data/app/models/katello/concerns/smart_proxy_extensions.rb +24 -0
  63. data/app/models/katello/content_view.rb +5 -1
  64. data/app/models/katello/content_view_environment.rb +2 -2
  65. data/app/models/katello/content_view_puppet_environment.rb +2 -2
  66. data/app/models/katello/content_view_version.rb +2 -1
  67. data/app/models/katello/content_view_version_export_history.rb +20 -0
  68. data/app/models/katello/erratum.rb +3 -1
  69. data/app/models/katello/file_unit.rb +0 -4
  70. data/app/models/katello/glue/candlepin/pool.rb +2 -0
  71. data/app/models/katello/glue/pulp/repo.rb +0 -6
  72. data/app/models/katello/glue/pulp/repos.rb +1 -22
  73. data/app/models/katello/host/content_facet.rb +31 -9
  74. data/app/models/katello/ping.rb +19 -39
  75. data/app/models/katello/pool.rb +5 -0
  76. data/app/models/katello/product.rb +3 -3
  77. data/app/models/katello/repository.rb +3 -3
  78. data/app/presenters/katello/host_subscription_presenter.rb +3 -4
  79. data/app/presenters/katello/host_subscriptions_presenter.rb +24 -0
  80. data/app/services/katello/applicability/applicable_content_helper.rb +6 -8
  81. data/app/services/katello/candlepin_event_listener.rb +11 -19
  82. data/app/services/katello/event_monitor/poller_thread.rb +2 -11
  83. data/app/services/katello/pulp/repository.rb +2 -4
  84. data/app/services/katello/pulp/smart_proxy_repository.rb +0 -15
  85. data/app/services/katello/pulp3/api/core.rb +0 -14
  86. data/app/services/katello/pulp3/erratum.rb +1 -2
  87. data/app/services/katello/pulp3/migration.rb +9 -83
  88. data/app/services/katello/pulp3/migration_plan.rb +5 -54
  89. data/app/services/katello/pulp3/migration_switchover.rb +5 -36
  90. data/app/services/katello/pulp3/repository/apt.rb +2 -1
  91. data/app/services/katello/pulp3/repository/yum.rb +2 -11
  92. data/app/services/katello/pulp3/repository.rb +13 -34
  93. data/app/services/katello/pulp3/rpm.rb +1 -5
  94. data/app/services/katello/pulp3/task.rb +5 -8
  95. data/app/services/katello/pulp3/task_group.rb +5 -13
  96. data/app/services/katello/repository_type.rb +1 -1
  97. data/app/views/foreman/smart_proxies/_content_tab.html.erb +4 -47
  98. data/app/views/foreman/smart_proxies/show.html.erb +1 -1
  99. data/app/views/katello/api/v2/capsule_content/sync_status.json.rabl +22 -25
  100. data/app/views/katello/api/v2/content_view_version_export_histories/show.json.rabl +1 -0
  101. data/app/views/katello/api/v2/organizations/show.json.rabl +7 -9
  102. data/app/views/katello/sync_management/_products.html.erb +1 -1
  103. data/app/views/overrides/organizations/_edit_override.html.erb +1 -4
  104. data/app/views/overrides/smart_proxies/_environment_tab.html.erb +1 -1
  105. data/app/views/overrides/smart_proxies/_environment_tab_pane.html.erb +1 -1
  106. data/config/katello.yaml.example +0 -3
  107. data/config/routes/api/v2.rb +8 -10
  108. data/db/migrate/20191204214919_add_content_view_version_counts.rb +0 -1
  109. data/db/migrate/20200514092553_move_katello_fields_from_hostgroups.katello.rb +1 -1
  110. data/db/migrate/20210119162528_delete_puppet_and_ostree_repos.rb +56 -0
  111. data/db/migrate/20210128231228_add_type_and_from_cvv_to_cvv_export_history.rb +14 -0
  112. data/db/migrate/20210201163238_migrate_background_download_policy_to_migrate.rb +7 -0
  113. data/db/seeds.d/104-proxy.rb +1 -1
  114. data/db/seeds.d/111-upgrade_tasks.rb +2 -1
  115. data/engines/bastion/app/assets/javascripts/bastion/auth/authorization.service.js +1 -1
  116. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/capsule-content/capsule-content.controller.js +1 -1
  117. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content-host-register-os-client.directive.js +17 -0
  118. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/views/content-host-info.html +2 -2
  119. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/views/content-hosts.html +2 -2
  120. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/views/register-client.html +11 -4
  121. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/views/register-deb-client.html +38 -0
  122. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/views/register-oracle-client.html +5 -0
  123. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/views/register-sles-client.html +28 -0
  124. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/views/register.html +14 -11
  125. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/filters/views/package-filter-details.html +2 -2
  126. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/repository-details-info.controller.js +2 -2
  127. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-info.html +1 -1
  128. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/download-policy.service.js +0 -1
  129. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/new/views/new-repository.html +1 -1
  130. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/products.controller.js +2 -2
  131. data/lib/katello/engine.rb +4 -5
  132. data/lib/katello/middleware/event_daemon.rb +1 -1
  133. data/lib/katello/permission_creator.rb +3 -2
  134. data/lib/katello/plugin.rb +2 -2
  135. data/lib/katello/tasks/jenkins.rake +1 -1
  136. data/lib/katello/tasks/pulp3_content_switchover.rake +20 -31
  137. data/lib/katello/tasks/pulp3_migration.rake +25 -45
  138. data/lib/katello/tasks/pulp3_migration_abort.rake +0 -8
  139. data/lib/katello/tasks/pulp3_migration_stats.rake +3 -46
  140. data/lib/katello/tasks/upgrades/4.0/remove_ostree_puppet_content.rake +16 -0
  141. data/lib/katello/version.rb +1 -1
  142. data/lib/proxy_api/container_gateway.rb +21 -0
  143. data/locale/bn/katello.edit.po +0 -0
  144. data/locale/cs/katello.edit.po +0 -0
  145. data/locale/de/katello.edit.po +0 -0
  146. data/locale/en/katello.edit.po +0 -0
  147. data/locale/es/katello.edit.po +0 -0
  148. data/locale/fr/katello.edit.po +0 -0
  149. data/locale/gu/katello.edit.po +0 -0
  150. data/locale/hi/katello.edit.po +0 -0
  151. data/locale/it/katello.edit.po +0 -0
  152. data/locale/ja/katello.edit.po +0 -0
  153. data/locale/kn/katello.edit.po +0 -0
  154. data/locale/ko/katello.edit.po +0 -0
  155. data/locale/mr/katello.edit.po +0 -0
  156. data/locale/or/katello.edit.po +0 -0
  157. data/locale/pa/katello.edit.po +0 -0
  158. data/locale/pt/katello.edit.po +0 -0
  159. data/locale/pt_BR/katello.edit.po +0 -0
  160. data/locale/ru/katello.edit.po +0 -0
  161. data/locale/ta/katello.edit.po +0 -0
  162. data/locale/te/katello.edit.po +0 -0
  163. data/locale/zh_CN/katello.edit.po +0 -0
  164. data/locale/zh_TW/katello.edit.po +0 -0
  165. data/package.json +1 -1
  166. data/webpack/__mocks__/foremanReact/Root/Context/ForemanContext.js +0 -1
  167. data/webpack/__mocks__/foremanReact/components/Pagination/PaginationHooks.js +2 -0
  168. data/webpack/__mocks__/foremanReact/components/common/dates/LongDateTime.js +5 -0
  169. data/webpack/{scenes/ContentViews/Details/Repositories → components/SelectableDropdown}/SelectableDropdown.js +20 -3
  170. data/webpack/components/SelectableDropdown/__tests__/SelectableDropdown.test.js +45 -0
  171. data/webpack/components/SelectableDropdown/index.js +3 -0
  172. data/webpack/components/Table/TableWrapper.js +2 -1
  173. data/webpack/components/Table/helpers.js +14 -0
  174. data/webpack/components/TypeAhead/pf4Search/TypeAheadSearch.js +0 -1
  175. data/webpack/containers/Application/overrides.scss +6 -0
  176. data/webpack/index.js +6 -0
  177. data/webpack/redux/actions/RedHatRepositories/helpers.js +5 -5
  178. data/webpack/scenes/ContentViews/ContentViewsActions.js +31 -2
  179. data/webpack/scenes/ContentViews/ContentViewsConstants.js +5 -1
  180. data/webpack/scenes/ContentViews/Copy/ContentViewCopySelectors.js +16 -0
  181. data/webpack/scenes/ContentViews/Copy/CopyContentViewForm.js +77 -0
  182. data/webpack/scenes/ContentViews/Copy/CopyContentViewModal.js +44 -0
  183. data/webpack/scenes/ContentViews/Copy/__tests__/contentViewCopyResult.fixtures.json +42 -0
  184. data/webpack/scenes/ContentViews/Copy/__tests__/copyContentView.test.js +39 -0
  185. data/webpack/scenes/ContentViews/Copy/index.js +4 -0
  186. data/webpack/scenes/ContentViews/Create/ContentViewCreateSelectors.js +16 -0
  187. data/webpack/scenes/ContentViews/Create/ContentViewFormComponents.js +58 -0
  188. data/webpack/scenes/ContentViews/Create/CreateContentViewForm.js +175 -0
  189. data/webpack/scenes/ContentViews/Create/CreateContentViewModal.js +27 -0
  190. data/webpack/scenes/ContentViews/Create/__tests__/contentViewCreateResult.fixtures.json +42 -0
  191. data/webpack/scenes/ContentViews/Create/__tests__/createContentView.test.js +92 -0
  192. data/webpack/scenes/ContentViews/Create/index.js +4 -0
  193. data/webpack/scenes/ContentViews/Details/ContentViewDetailActions.js +16 -0
  194. data/webpack/scenes/ContentViews/Details/ContentViewDetailSelectors.js +20 -1
  195. data/webpack/scenes/ContentViews/Details/ContentViewDetails.js +17 -7
  196. data/webpack/scenes/ContentViews/Details/ContentViewInfo.js +19 -13
  197. data/webpack/scenes/ContentViews/Details/Filters/ContentType.js +40 -0
  198. data/webpack/scenes/ContentViews/Details/Filters/ContentViewFilters.js +124 -0
  199. data/webpack/scenes/ContentViews/Details/Filters/__tests__/contentViewFilters.fixtures.json +134 -0
  200. data/webpack/scenes/ContentViews/Details/Filters/__tests__/contentViewFilters.test.js +92 -0
  201. data/webpack/scenes/ContentViews/Details/Repositories/ContentViewRepositories.js +44 -25
  202. data/webpack/scenes/ContentViews/Details/Repositories/__tests__/contentViewDetailRepos.test.js +17 -7
  203. data/webpack/scenes/ContentViews/Details/__tests__/contentViewDetail.test.js +24 -0
  204. data/webpack/scenes/ContentViews/Table/ContentViewsTable.js +53 -3
  205. data/webpack/scenes/ContentViews/Table/tableDataGenerator.js +4 -3
  206. data/webpack/scenes/ContentViews/__tests__/contentViewPage.test.js +41 -0
  207. data/webpack/scenes/ContentViews/helpers.js +13 -0
  208. data/webpack/scenes/SmartProxy/Content.js +17 -0
  209. data/webpack/scenes/SmartProxy/SmartProxyContentActions.js +11 -0
  210. data/webpack/scenes/SmartProxy/SmartProxyContentConstants.js +3 -0
  211. data/webpack/scenes/SmartProxy/SmartProxyContentSelectors.js +16 -0
  212. data/webpack/scenes/SmartProxy/SmartProxyContentTable.js +152 -0
  213. data/webpack/scenes/SmartProxy/__tests__/SmartProxyContentResult.fixtures.json +140 -0
  214. data/webpack/scenes/SmartProxy/__tests__/SmartProxyContentTest.js +38 -0
  215. data/webpack/scenes/SmartProxy/index.js +4 -0
  216. data/webpack/scenes/Subscriptions/Manifest/ManageManifestModal.js +2 -7
  217. data/webpack/scenes/Subscriptions/Manifest/ManifestActions.js +3 -3
  218. data/webpack/scenes/Subscriptions/Manifest/__tests__/ManifestActions.test.js +2 -2
  219. data/webpack/scenes/Subscriptions/Manifest/__tests__/SimpleContentAccess.test.js +2 -2
  220. data/webpack/scenes/Subscriptions/Manifest/index.js +0 -1
  221. data/webpack/test-utils/react-testing-lib-wrapper.js +5 -2
  222. data/webpack/utils/helpers.js +3 -0
  223. metadata +103 -63
  224. data/app/controllers/katello/api/v2/gpg_keys_controller.rb +0 -114
  225. data/app/lib/actions/pulp3/content_migration_reset.rb +0 -22
  226. data/app/lib/katello/util/hostgroup_facets_helper.rb +0 -126
  227. data/app/overrides/disable_turbolinks_on_proxies_index.rb +0 -5
  228. data/app/services/katello/event_daemon.rb +0 -135
  229. data/app/services/katello/pulp/content_counts_calculator.rb +0 -60
  230. data/db/migrate/20210201165835_add_migration_missing_content.rb +0 -12
  231. data/db/migrate/20210420140050_add_pulp3_hrefs_to_content_types_deb.rb +0 -5
  232. data/lib/katello/tasks/check_config.rake +0 -11
  233. data/lib/katello/tasks/fix_hostgroup_facets.rake +0 -8
  234. data/lib/katello/tasks/pulp3_migration_approve_corrupted.rake +0 -21
  235. data/lib/katello/tasks/pulp3_migration_reset.rake +0 -26
  236. data/lib/katello/tasks/reports.rake +0 -7
  237. data/lib/katello/tasks/upgrades/3.10/update_gpg_key_urls.rake +0 -32
  238. data/webpack/components/TypeAhead/pf4Search/TypeAheadSearch.scss +0 -5
  239. data/webpack/scenes/ContentViews/Table/actionResolver.js +0 -28
@@ -0,0 +1,99 @@
1
+ module Katello
2
+ module EventDaemon
3
+ class Runner
4
+ STATUS_CACHE_KEY = "katello_event_daemon_status".freeze
5
+ @services = {}
6
+ @cache = ActiveSupport::Cache::MemoryStore.new
7
+
8
+ class << self
9
+ def initialize
10
+ FileUtils.touch(lock_file)
11
+ end
12
+
13
+ def settings
14
+ SETTINGS[:katello][:event_daemon]
15
+ end
16
+
17
+ def pid
18
+ return unless pid_file && File.exist?(pid_file)
19
+
20
+ File.open(pid_file) { |f| f.read.to_i }
21
+ end
22
+
23
+ def pid_file
24
+ pid_dir.join('katello_event_daemon.pid')
25
+ end
26
+
27
+ def pid_dir
28
+ Rails.root.join('tmp', 'pids')
29
+ end
30
+
31
+ def lock_file
32
+ Rails.root.join('tmp', 'katello_event_daemon.lock')
33
+ end
34
+
35
+ def write_pid_file
36
+ return unless pid_file
37
+
38
+ FileUtils.mkdir_p(pid_dir)
39
+ File.open(pid_file, 'w') { |f| f.puts Process.pid }
40
+ end
41
+
42
+ def stop
43
+ return unless pid == Process.pid
44
+ @monitor_thread.kill
45
+ @cache.clear
46
+ @services.values.each(&:close)
47
+ File.unlink(pid_file) if pid_file && File.exist?(pid_file)
48
+ end
49
+
50
+ def start
51
+ return unless runnable?
52
+ lockfile = File.open(lock_file, 'r')
53
+ begin
54
+ lockfile.flock(File::LOCK_EX)
55
+ return if started? # ensure it wasn't started while we waited for the lock
56
+ start_monitor_thread
57
+ write_pid_file
58
+
59
+ at_exit do
60
+ stop
61
+ end
62
+
63
+ Rails.logger.info("Katello event daemon started process=#{Process.pid}")
64
+ ensure
65
+ lockfile.flock(File::LOCK_UN)
66
+ end
67
+ end
68
+
69
+ def started?
70
+ Process.kill(0, pid)
71
+ true
72
+ rescue Errno::ESRCH, TypeError # process no longer exists or we had no PID cached
73
+ false
74
+ end
75
+
76
+ def start_monitor_thread
77
+ @monitor_thread = Thread.new do
78
+ Katello::EventDaemon::Monitor.new(@services).start
79
+ end
80
+ end
81
+
82
+ def runnable?
83
+ # avoid accessing the disk on each request
84
+ @cache.fetch('katello_event_daemon_runnable', expires_in: 1.minute) do
85
+ !started? && settings[:enabled] && !::Foreman.in_rake? && !Rails.env.test?
86
+ end
87
+ end
88
+
89
+ def register_service(name, klass)
90
+ @services[name] = klass
91
+ end
92
+
93
+ def service_status(service_name = nil)
94
+ Rails.cache.read(STATUS_CACHE_KEY)&.dig(service_name)
95
+ end
96
+ end
97
+ end
98
+ end
99
+ end
@@ -10,5 +10,37 @@ module Katello
10
10
 
11
11
  logger.send(level, "#{message} #{data_string}")
12
12
  end
13
+
14
+ class Timer
15
+ def initialize(key = "default")
16
+ @key = key
17
+ @start_time = Time.now
18
+ Thread.current[:timers] ||= {}
19
+ Thread.current[:timers][key] = self
20
+ end
21
+
22
+ def start
23
+ Rails.logger.info "Timer #{@key} already started; resetting start time" if @start_time
24
+ Rails.logger.info "Timer #{@key} starting at #{Time.now}"
25
+ @start_time = Time.now
26
+ self
27
+ end
28
+
29
+ def stop
30
+ fail ::StandardError, "Timer #{@key} is not started" unless @start_time
31
+ duration = (Time.now - @start_time).truncate(2)
32
+ @start_time = nil
33
+ Rails.logger.info "Timer #{@key} stopping at #{Time.now}: #{duration} sec"
34
+ end
35
+
36
+ def self.find_by_key(key)
37
+ if Thread.current&.[](:timers)&.[](key)
38
+ Thread.current[:timers][key]
39
+ else
40
+ Rails.logger.warn "Timer #{key} not found on current thread; creating a new timer"
41
+ self.new(key)
42
+ end
43
+ end
44
+ end
13
45
  end
14
46
  end
@@ -2,13 +2,7 @@ module Katello
2
2
  module Messaging
3
3
  class Connection
4
4
  def self.create(connection_class:, settings:)
5
- connection = connection_class.new(settings: settings)
6
-
7
- at_exit do
8
- connection.close
9
- end
10
-
11
- connection
5
+ connection_class.new(settings: settings)
12
6
  end
13
7
  end
14
8
  end
@@ -8,7 +8,7 @@ module Katello
8
8
  def filter_package_groups_by_pulp_href(package_groups, package_pulp_hrefs)
9
9
  rpms = Katello::Rpm.where(:pulp_id => package_pulp_hrefs)
10
10
  package_groups.reject do |package_group|
11
- (package_group.package_names - rpms.pluck(:name)).any?
11
+ (package_group.package_names & rpms.pluck(:name)).empty?
12
12
  end
13
13
  end
14
14
 
@@ -1,7 +1,7 @@
1
1
  module Katello
2
2
  module Validators
3
3
  class ContentViewPuppetModuleValidator < ActiveModel::Validator
4
- def validate(record)
4
+ def validate(record) # rubocop:disable Metrics/CyclomaticComplexity
5
5
  if record.uuid.blank? && (record.name.blank? || record.author.blank?)
6
6
  record.errors[:base] << _("Invalid puppet module parameters specified. \
7
7
  Either 'uuid' or 'name' and 'author' must be specified.")
@@ -1,8 +1,8 @@
1
1
  module Katello
2
2
  class ActivationKey < Katello::Model
3
3
  audited :except => [:cp_id], :associations => [:host_collections]
4
- include Glue::Candlepin::ActivationKey if SETTINGS[:katello][:use_cp]
5
- include Glue if SETTINGS[:katello][:use_cp]
4
+ include Glue::Candlepin::ActivationKey
5
+ include Glue
6
6
  include Katello::Authorization::ActivationKey
7
7
  include ForemanTasks::Concerns::ActionSubject
8
8
  include ScopedSearchExtensions
@@ -114,7 +114,7 @@ module Katello
114
114
  end
115
115
 
116
116
  def suse?
117
- content.content_type == Repository::YUM_TYPE && !!path.downcase.match(/suse/) # rubocop:disable Style/DoubleNegation
117
+ content.content_type == Repository::YUM_TYPE && !!path.downcase.match(/suse/)
118
118
  end
119
119
 
120
120
  def file?
@@ -107,9 +107,7 @@ module Katello
107
107
  return true unless operatingsystem
108
108
 
109
109
  if operatingsystem.respond_to? :kickstart_repos
110
- operatingsystem.kickstart_repos(self, content_facet: content_facet).any? do |repo|
111
- repo[:id] == (content_facet&.kickstart_repository_id || content_facet&.kickstart_repository&.id)
112
- end
110
+ return operatingsystem.kickstart_repos(self).any? { |repo| repo[:id] == (content_facet&.kickstart_repository_id || content_facet&.kickstart_repository&.id) }
113
111
  end
114
112
  end
115
113
 
@@ -128,7 +126,7 @@ module Katello
128
126
  facet_model = Facets.registered_facets[facet].hostgroup_configuration.model
129
127
  value = facet_model.where.not(attribute => nil).joins(:hostgroup).merge(
130
128
  ::Hostgroup.where(id: self.ancestor_ids).reorder(ancestry: :desc)
131
- ).limit(1).pluck(attribute).first
129
+ ).limit(1).pluck(attribute)
132
130
  end
133
131
  value
134
132
  end
@@ -9,8 +9,8 @@ module Katello
9
9
 
10
10
  include ForemanTasks::Concerns::ActionSubject
11
11
  prepend ForemanTasks::Concerns::ActionTriggering
12
- include Glue::Candlepin::Owner if SETTINGS[:katello][:use_cp]
13
- include Glue if SETTINGS[:katello][:use_cp]
12
+ include Glue::Candlepin::Owner
13
+ include Glue
14
14
 
15
15
  include Katello::Authorization::Organization
16
16
  include Ext::LabelFromName
@@ -218,18 +218,6 @@ module Katello
218
218
  def db_values(new_ids, pulp_id_href_map, repository)
219
219
  new_ids.map { |unit_id| [unit_id.to_i, pulp_id_href_map.dig(unit_id), repository.id.to_i, Time.now.utc.to_s(:db), Time.now.utc.to_s(:db)].compact }
220
220
  end
221
-
222
- def unmigrated_content
223
- self.where(migrated_pulp3_href: nil, ignore_missing_from_migration: false)
224
- end
225
-
226
- def missing_migrated_content #missing or corrupted content that could not be migrated
227
- self.where(migrated_pulp3_href: nil, missing_from_migration: true, ignore_missing_from_migration: false)
228
- end
229
-
230
- def ignored_missing_migrated_content
231
- self.where(migrated_pulp3_href: nil, missing_from_migration: true, ignore_missing_from_migration: true)
232
- end
233
221
  end
234
222
  end
235
223
  end
@@ -42,11 +42,10 @@ module Katello
42
42
  end
43
43
  end
44
44
 
45
- def kickstart_repos(host, content_facet: nil)
46
- distros = distribution_repositories(host, content_facet: content_facet).where(distribution_bootable: true)
47
- content_facet ||= host.content_facet
48
- if distros && content_facet&.content_source
49
- distros.map { |distro| distro.to_hash(content_facet.content_source) }
45
+ def kickstart_repos(host)
46
+ distros = distribution_repositories(host).where(distribution_bootable: true)
47
+ if distros && host&.content_facet&.content_source
48
+ distros.map { |distro| distro.to_hash(host.content_facet.content_source) }
50
49
  else
51
50
  []
52
51
  end
@@ -66,10 +65,10 @@ module Katello
66
65
  end
67
66
  end
68
67
 
69
- def distribution_repositories(host, content_facet: nil)
70
- content_facet ||= host.content_facet
71
- content_view = content_facet.try(:content_view) || host.try(:content_view)
72
- lifecycle_environment = content_facet.try(:lifecycle_environment) || host.try(:lifecycle_environment)
68
+ def distribution_repositories(host)
69
+ content_view = host.try(:content_facet).try(:content_view) || host.try(:content_view)
70
+ lifecycle_environment = host.try(:content_facet).try(:lifecycle_environment) || host.try(:lifecycle_environment)
71
+
73
72
  if content_view && lifecycle_environment && host.os && host.architecture
74
73
  Katello::Repository.in_environment(lifecycle_environment).in_content_views([content_view]).
75
74
  where(:distribution_arch => host.architecture.name).
@@ -101,6 +101,10 @@ module Katello
101
101
  end
102
102
  end
103
103
 
104
+ def update_unauthenticated_repo_list(repo_names)
105
+ ProxyAPI::ContainerGateway.new(url: self.url).unauthenticated_repository_list("repositories": repo_names)
106
+ end
107
+
104
108
  def puppet_path
105
109
  self[:puppet_path] || update_puppet_path
106
110
  end
@@ -348,6 +352,26 @@ module Katello
348
352
  end
349
353
  end
350
354
 
355
+ def repos_in_env_cv(environment = nil, content_view = nil)
356
+ repos = Katello::Repository
357
+ repos = repos.in_environment(environment) if environment
358
+ repos = repos.in_content_views([content_view]) if content_view
359
+ repos
360
+ end
361
+
362
+ def repos_in_sync_history
363
+ smart_proxy_sync_histories.map { |sync_history| sync_history.repository }
364
+ end
365
+
366
+ def current_repositories_data(environment = nil, content_view = nil)
367
+ return repos_in_sync_history unless (environment || content_view)
368
+ repos_in_sync_history & repos_in_env_cv(environment, content_view)
369
+ end
370
+
371
+ def repos_pending_sync(environment = nil, content_view = nil)
372
+ repos_in_env_cv(environment, content_view) - repos_in_sync_history
373
+ end
374
+
351
375
  def smart_proxy_service
352
376
  @smart_proxy_service ||= Pulp::SmartProxyRepository.new(self)
353
377
  end
@@ -241,6 +241,10 @@ module Katello
241
241
  environments.include?(env)
242
242
  end
243
243
 
244
+ apipie :method, 'Returns the Katello::ContentViewVersion for a given Lifecycle Environment' do
245
+ required :env, 'Katello::KTEnvironment', desc: 'a __Katello::KTEnvironment__ object for which we load the __Katello::ContentViewVersion__ object'
246
+ returns 'Katello::ContentViewVersion'
247
+ end
244
248
  def version(env)
245
249
  self.versions.in_environment(env).order("#{Katello::ContentViewVersion.table_name}.id ASC").readonly(false).last
246
250
  end
@@ -760,7 +764,7 @@ module Katello
760
764
  prop_group :katello_basic_props, Katello::Model, meta: { friendly_name: 'Content View' }
761
765
  end
762
766
  class Jail < ::Safemode::Jail
763
- allow :name, :label
767
+ allow :name, :label, :version
764
768
  end
765
769
  end
766
770
  end
@@ -2,8 +2,8 @@ module Katello
2
2
  class ContentViewEnvironment < Katello::Model
3
3
  audited :associated_with => :content_view
4
4
  include ForemanTasks::Concerns::ActionSubject
5
- include Glue::Candlepin::Environment if SETTINGS[:katello][:use_cp]
6
- include Glue if SETTINGS[:katello][:use_cp]
5
+ include Glue::Candlepin::Environment
6
+ include Glue
7
7
  include Authorization::ContentViewEnvironment
8
8
 
9
9
  belongs_to :content_view, :class_name => "Katello::ContentView", :inverse_of => :content_view_environments
@@ -1,8 +1,8 @@
1
1
  module Katello
2
2
  class ContentViewPuppetEnvironment < Katello::Model
3
3
  include ForemanTasks::Concerns::ActionSubject
4
- include Glue::Pulp::Repo if SETTINGS[:katello][:use_pulp]
5
- include Glue if SETTINGS[:katello][:use_pulp]
4
+ include Glue::Pulp::Repo
5
+ include Glue
6
6
 
7
7
  belongs_to :environment, :class_name => "Katello::KTEnvironment",
8
8
  :inverse_of => :content_view_puppet_environments
@@ -322,7 +322,8 @@ module Katello
322
322
  end
323
323
 
324
324
  def content_counts_map
325
- return {} if content_counts.blank?
325
+ # if its empty, calculate it on demand
326
+ update_content_counts! if content_counts.blank?
326
327
  counts = Hash[content_counts.map { |key, value| ["#{key}_count", value] }]
327
328
  counts.merge("module_stream_count" => counts["modulemd_count"],
328
329
  "package_count" => counts["rpm_count"],
@@ -2,13 +2,24 @@ module Katello
2
2
  class ContentViewVersionExportHistory < Katello::Model
3
3
  include Authorization::ContentViewVersionExportHistory
4
4
 
5
+ COMPLETE = "complete".freeze
6
+ INCREMENTAL = "incremental".freeze
7
+ EXPORT_TYPES = [COMPLETE, INCREMENTAL].freeze
8
+
5
9
  belongs_to :content_view_version, :class_name => "Katello::ContentViewVersion", :inverse_of => :export_histories
6
10
  validates_lengths_from_database
7
11
  validates :content_view_version_id, :presence => true
8
12
  validates :destination_server, :uniqueness => { :scope => [:content_view_version_id, :destination_server, :path] }
13
+ validates :export_type, :inclusion => { :in => EXPORT_TYPES,
14
+ :allow_blank => false,
15
+ :message => _("Invalid export_type from one of the following: %s" % EXPORT_TYPES.join(', '))
16
+ }
17
+
9
18
  validates :metadata, :presence => true
10
19
  serialize :metadata, Hash
11
20
 
21
+ before_validation :set_export_type, :if => -> { export_type.blank? }
22
+
12
23
  scope :with_organization_id, ->(organization_id) do
13
24
  where(:content_view_version_id => ContentViewVersion.with_organization_id(organization_id))
14
25
  end
@@ -20,10 +31,19 @@ module Katello
20
31
  scoped_search :on => :content_view_id, :relation => :content_view_version, :validator => ScopedSearch::Validators::INTEGER, :only_explicit => true
21
32
  scoped_search :on => :content_view_version_id, :only_explicit => true, :validator => ScopedSearch::Validators::INTEGER
22
33
  scoped_search :on => :id, :only_explicit => true, :validator => ScopedSearch::Validators::INTEGER
34
+ scoped_search :on => :export_type, :rename => :type, :complete_value => EXPORT_TYPES
23
35
 
24
36
  def self.latest(content_view, destination_server: nil)
25
37
  where(content_view_version: content_view.versions,
26
38
  destination_server: destination_server).order(:created_at).last
27
39
  end
40
+
41
+ def export_type_from_metadata
42
+ cvve.metadata[:incremental] ? INCREMENTAL : COMPLETE
43
+ end
44
+
45
+ def set_export_type
46
+ self.export_type = export_type_from_metadata
47
+ end
28
48
  end
29
49
  end
@@ -173,9 +173,11 @@ module Katello
173
173
  property :package_names, array_of: String, desc: 'Returns names of packages the errata can be applied to'
174
174
  property :cves, array_of: 'ErratumCve', desc: 'Returns CVEs associated with the errata'
175
175
  property :reboot_suggested, one_of: [true, false], desc: 'Returns true if reboot is suggested after errata applying, false otherwise'
176
+ property :title, String, desc: 'Returns the errata title, e.g. "Important: net-snmp security update"'
177
+ property :summary, String, desc: 'Returns the errata summary, the length can very, it is usually in range of 60 to 1000 characters. It can include empty line characters.'
176
178
  end
177
179
  class Jail < ::Safemode::Jail
178
- allow :errata_id, :errata_type, :issued, :created_at, :severity, :package_names, :cves, :reboot_suggested
180
+ allow :errata_id, :errata_type, :issued, :created_at, :severity, :package_names, :cves, :reboot_suggested, :title, :summary
179
181
  end
180
182
  end
181
183
  end
@@ -13,10 +13,6 @@ module Katello
13
13
  order(:name)
14
14
  end
15
15
 
16
- def filename
17
- path
18
- end
19
-
20
16
  def self.total_for_repositories(repos)
21
17
  self.in_repositories(repos).count
22
18
  end
@@ -92,6 +92,8 @@ module Katello
92
92
  end
93
93
 
94
94
  # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
95
+ # rubocop:disable Metrics/CyclomaticComplexity
96
+ # rubocop:disable Metrics/PerceivedComplexity
95
97
  def import_data(index_hosts_and_activation_keys = false)
96
98
  pool_attributes = {}.with_indifferent_access
97
99
  pool_json = self.backend_data
@@ -113,12 +113,6 @@ module Katello
113
113
  backend_service(capsule).generate_distributors
114
114
  end
115
115
 
116
- def populate_from(repos_map)
117
- found = repos_map[self.pulp_id]
118
- prepopulate(found) if found
119
- !found.nil?
120
- end
121
-
122
116
  def package_group_count
123
117
  content_unit_counts = 0
124
118
  if self.pulp_repo_facts
@@ -12,27 +12,6 @@ module Katello
12
12
  "#{path_prefix}/#{path}"
13
13
  end
14
14
 
15
- def self.prepopulate!(products, environment, repos = [], content_view = nil)
16
- if content_view.nil?
17
- if environment.library?
18
- content_view = environment.default_content_view
19
- else
20
- fail "No content view specified for a Non library environment #{environment.inspect}"
21
- end
22
- end
23
-
24
- items = Katello.pulp_server.extensions.repository.search_by_repository_ids(Repository.in_environment(environment).pluck(:pulp_id))
25
- full_repos = {}
26
- items.each { |item| full_repos[item["id"]] = item }
27
-
28
- products.each do |prod|
29
- prod.repos(environment, content_view).each do |repo|
30
- repo.populate_from(full_repos)
31
- end
32
- end
33
- repos.each { |repo| repo.populate_from(full_repos) }
34
- end
35
-
36
15
  module InstanceMethods
37
16
  def distributions(env)
38
17
  to_ret = []
@@ -125,7 +104,7 @@ module Katello
125
104
  AND inner_select.resource_id = locks_foreman_tasks_tasks.resource_id")
126
105
  .distinct
127
106
 
128
- max_per_repoid.map { |x| [x.resource_id, x] }.to_h
107
+ max_per_repoid.index_by { |x| [x.resource_id, x] }
129
108
  end
130
109
 
131
110
  def sync_state_aggregated
@@ -31,21 +31,43 @@ module Katello
31
31
  validates :host, :presence => true, :allow_blank => false
32
32
  validates_with Validators::ContentViewEnvironmentValidator
33
33
 
34
+ def bindable_types
35
+ [
36
+ {
37
+ type: Repository::DEB_TYPE,
38
+ matcher: '/pulp/deb/',
39
+ paths: []
40
+ },
41
+ {
42
+ type: Repository::YUM_TYPE,
43
+ matcher: '/pulp/repos/',
44
+ paths: []
45
+ }
46
+ ]
47
+ end
48
+
34
49
  def update_repositories_by_paths(paths)
35
- prefixes = %w(/pulp/deb/ /pulp/repos/ /pulp/content/)
50
+ bindable_paths = bindable_types
36
51
  relative_paths = []
37
52
 
38
- # paths == ["/pulp/repos/Default_Organization/Library/custom/Test_product/test2"]
39
- paths.each do |path|
40
- if (prefix = prefixes.find { |pre| path.start_with?(pre) })
41
- relative_paths << path.gsub(prefix, '')
42
- else
43
- Rails.logger.warn("System #{self.host.name} (#{self.host.id}) requested binding to repo with unknown prefix. #{path}")
53
+ # paths == ["/pulp/repos/Default_Organization/Library/custom/Test_product/test2",
54
+ # "/pulp/repos/Default_Organization/Library/custom/Test_product/My_repo"]
55
+ paths.each do |absolute_path|
56
+ bindable_paths.each do |supported|
57
+ relative_path = absolute_path.gsub(supported[:matcher], '') # remove e.g. '/pulp/repos/' from beginning of string
58
+ relative_paths << relative_path unless relative_path == absolute_path
59
+ if absolute_path.starts_with?(supported[:matcher])
60
+ supported[:paths] << relative_path
61
+ break
62
+ end
44
63
  end
45
64
  end
46
65
 
47
- repos = Repository.where(relative_path: relative_paths)
48
- relative_paths -= repos.pluck(:relative_path) # remove relative paths that match our repos
66
+ repos = bindable_paths.flat_map do |supported|
67
+ repos = Repository.joins(:root).where(RootRepository.table_name => {content_type: supported[:type]}, relative_path: supported[:paths])
68
+ relative_paths -= repos.pluck(:relative_path) # remove relative paths that match our repos
69
+ repos
70
+ end
49
71
 
50
72
  # Any leftover relative paths do not match the repos we've just retrieved from the db,
51
73
  # so we should log warnings about them.
@@ -9,7 +9,7 @@ module Katello
9
9
  SETTINGS[:katello][:use_pulp_2_for_content_type].nil? || (!SETTINGS[:katello][:use_pulp_2_for_content_type][:yum] &&
10
10
  !SETTINGS[:katello][:use_pulp_2_for_content_type][:docker] &&
11
11
  !SETTINGS[:katello][:use_pulp_2_for_content_type][:file]) ||
12
- File.exist?('/etc/systemd/system/multi-user.target.wants/pulpcore-api.service')
12
+ system('systemctl is-enabled pulpcore-api.service')
13
13
  end
14
14
 
15
15
  def services(capsule_id = nil)
@@ -23,18 +23,25 @@ module Katello
23
23
  services
24
24
  end
25
25
 
26
+ # Calls "status" services in all backend engines.
26
27
  def ping(services: nil, capsule_id: nil)
27
- ping_services_for_capsule(services, capsule_id)
28
- end
28
+ services ||= self.services(capsule_id)
29
+ result = {}
30
+ services.each { |service| result[service] = {} }
29
31
 
30
- def ping!(services: nil, capsule_id: nil)
31
- result = ping_services_for_capsule(services, capsule_id)
32
+ ping_pulp3_without_auth(result[:pulp3], capsule_id) if result.include?(:pulp3)
33
+ ping_pulp_without_auth(result[:pulp], capsule_id) if result.include?(:pulp)
34
+ ping_candlepin_without_auth(result[:candlepin]) if result.include?(:candlepin)
32
35
 
33
- if result[:status] != OK_RETURN_CODE
34
- failed_names = failed_services(result).keys
35
- fail("The following services have not been started or are reporting errors: #{failed_names.join(', ')}")
36
- end
36
+ ping_pulp_with_auth(result[:pulp_auth], result[:pulp][:status]) if result.include?(:pulp_auth)
37
+ ping_candlepin_with_auth(result[:candlepin_auth]) if result.include?(:candlepin_auth)
38
+ ping_foreman_tasks(result[:foreman_tasks]) if result.include?(:foreman_tasks)
39
+ ping_katello_events(result[:katello_events]) if result.include?(:katello_events)
40
+ ping_candlepin_events(result[:candlepin_events]) if result.include?(:candlepin_events)
37
41
 
42
+ # set overall status result code
43
+ result = {:services => result}
44
+ result[:status] = result[:services].each_value.any? { |v| v[:status] == FAIL_RETURN_CODE } ? FAIL_RETURN_CODE : OK_RETURN_CODE
38
45
  result
39
46
  end
40
47
 
@@ -49,7 +56,7 @@ module Katello
49
56
  running = status&.dig(:running)
50
57
 
51
58
  if running
52
- result[:message] = "#{status[:processed_count]} Processed, #{status[:failed_count]} Failed"
59
+ result[:message] = "#{status[:processed_count].to_i} Processed, #{status[:failed_count].to_i} Failed"
53
60
  else
54
61
  result[:status] = FAIL_RETURN_CODE
55
62
  result[:message] = _("Not running")
@@ -58,14 +65,14 @@ module Katello
58
65
 
59
66
  def ping_katello_events(result)
60
67
  exception_watch(result) do
61
- status = Katello::EventMonitor::PollerThread.status(refresh: false)
68
+ status = Katello::EventDaemon::Runner.service_status(:katello_events)
62
69
  event_daemon_status(status, result)
63
70
  end
64
71
  end
65
72
 
66
73
  def ping_candlepin_events(result)
67
74
  exception_watch(result) do
68
- status = Katello::CandlepinEventListener.status(refresh: false)
75
+ status = Katello::EventDaemon::Runner.service_status(:candlepin_events)
69
76
  event_daemon_status(status, result)
70
77
  end
71
78
  end
@@ -214,33 +221,6 @@ module Katello
214
221
 
215
222
  private
216
223
 
217
- def failed_services(result)
218
- result[:services].reject do |_name, details|
219
- details[:status] != OK_RETURN_CODE
220
- end
221
- end
222
-
223
- def ping_services_for_capsule(services, capsule_id)
224
- services ||= self.services(capsule_id)
225
- result = {}
226
- services.each { |service| result[service] = {} }
227
-
228
- ping_pulp3_without_auth(result[:pulp3], capsule_id) if result.include?(:pulp3)
229
- ping_pulp_without_auth(result[:pulp], capsule_id) if result.include?(:pulp)
230
- ping_candlepin_without_auth(result[:candlepin]) if result.include?(:candlepin)
231
-
232
- ping_pulp_with_auth(result[:pulp_auth], result[:pulp][:status]) if result.include?(:pulp_auth)
233
- ping_candlepin_with_auth(result[:candlepin_auth]) if result.include?(:candlepin_auth)
234
- ping_foreman_tasks(result[:foreman_tasks]) if result.include?(:foreman_tasks)
235
- ping_katello_events(result[:katello_events]) if result.include?(:katello_events)
236
- ping_candlepin_events(result[:candlepin_events]) if result.include?(:candlepin_events)
237
-
238
- # set overall status result code
239
- result = {:services => result}
240
- result[:status] = result[:services].each_value.any? { |v| v[:status] == FAIL_RETURN_CODE } ? FAIL_RETURN_CODE : OK_RETURN_CODE
241
- result
242
- end
243
-
244
224
  def fetch_proxy(capsule_id)
245
225
  capsule_id ? SmartProxy.unscoped.find(capsule_id) : SmartProxy.pulp_primary
246
226
  end