katello 4.7.3 → 4.8.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 (333) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/katello/api/registry/registry_proxies_controller.rb +6 -4
  3. data/app/controllers/katello/api/rhsm/candlepin_proxies_controller.rb +15 -12
  4. data/app/controllers/katello/api/v2/capsule_content_controller.rb +0 -4
  5. data/app/controllers/katello/api/v2/content_export_incrementals_controller.rb +22 -81
  6. data/app/controllers/katello/api/v2/content_exports_controller.rb +11 -80
  7. data/app/controllers/katello/api/v2/content_imports_controller.rb +1 -0
  8. data/app/controllers/katello/api/v2/exports_controller.rb +130 -0
  9. data/app/controllers/katello/api/v2/host_subscriptions_controller.rb +7 -8
  10. data/app/controllers/katello/api/v2/hosts_bulk_actions_controller.rb +8 -4
  11. data/app/controllers/katello/api/v2/organizations_controller.rb +3 -0
  12. data/app/controllers/katello/api/v2/package_groups_controller.rb +0 -52
  13. data/app/controllers/katello/concerns/api/v2/bulk_hosts_extensions.rb +4 -6
  14. data/app/controllers/katello/concerns/api/v2/registration_controller_extensions.rb +1 -2
  15. data/app/controllers/katello/concerns/authorization/api/v2/content_views_controller.rb +4 -1
  16. data/app/controllers/katello/concerns/content_facet_hosts_controller_extensions.rb +24 -0
  17. data/app/controllers/katello/concerns/hosts_controller_extensions.rb +3 -3
  18. data/app/helpers/katello/hosts_and_hostgroups_helper.rb +55 -24
  19. data/app/helpers/katello/katello_urls_helper.rb +0 -15
  20. data/app/helpers/katello/sync_management_helper.rb +0 -4
  21. data/app/lib/actions/candlepin/owner/destroy_imports.rb +1 -1
  22. data/app/lib/actions/katello/capsule_content/sync.rb +0 -4
  23. data/app/lib/actions/katello/capsule_content/sync_capsule.rb +1 -2
  24. data/app/lib/actions/katello/content_view/publish.rb +6 -2
  25. data/app/lib/actions/katello/content_view/remove.rb +8 -2
  26. data/app/lib/actions/katello/content_view_version/destroy.rb +1 -1
  27. data/app/lib/actions/katello/environment/destroy.rb +8 -2
  28. data/app/lib/actions/katello/host/reassign.rb +4 -2
  29. data/app/lib/actions/katello/orphan_cleanup/remove_orphans.rb +0 -1
  30. data/app/lib/actions/katello/product/destroy.rb +2 -1
  31. data/app/lib/actions/katello/repository/filtered_index_content.rb +2 -10
  32. data/app/lib/actions/katello/repository/import_upload.rb +0 -1
  33. data/app/lib/actions/katello/repository/sync.rb +0 -1
  34. data/app/lib/actions/katello/repository/update.rb +5 -3
  35. data/app/lib/actions/katello/repository/upload_files.rb +0 -1
  36. data/app/lib/actions/pulp3/abstract.rb +0 -6
  37. data/app/lib/actions/pulp3/content_view/delete_repository_references.rb +1 -2
  38. data/app/lib/actions/pulp3/content_view_version/create_syncable_export_history.rb +4 -0
  39. data/app/lib/actions/pulp3/orchestration/content_view_version/export.rb +1 -0
  40. data/app/lib/actions/pulp3/orchestration/content_view_version/export_repository.rb +7 -2
  41. data/app/lib/actions/pulp3/orchestration/content_view_version/syncable_export.rb +7 -2
  42. data/app/lib/actions/pulp3/repository/refresh_distribution.rb +1 -2
  43. data/app/lib/actions/pulp3/repository/save_distribution_references.rb +2 -2
  44. data/app/lib/katello/concerns/renderer_extensions.rb +1 -1
  45. data/app/lib/katello/event_daemon/runner.rb +12 -9
  46. data/app/lib/katello/resources/candlepin/consumer.rb +6 -6
  47. data/app/lib/katello/resources/candlepin/owner.rb +1 -1
  48. data/app/lib/katello/resources/candlepin/upstream_consumer.rb +3 -4
  49. data/app/lib/katello/resources/candlepin.rb +4 -4
  50. data/app/lib/katello/util/errata.rb +12 -10
  51. data/app/lib/katello/util/search.rb +0 -1
  52. data/app/lib/katello/validators/content_view_environment_org_validator.rb +5 -2
  53. data/app/lib/katello/validators/content_view_environment_validator.rb +1 -2
  54. data/app/lib/katello/validators/generated_content_view_validator.rb +16 -0
  55. data/app/mailers/katello/errata_mailer.rb +4 -2
  56. data/app/models/katello/alternate_content_source.rb +5 -1
  57. data/app/models/katello/concerns/content_facet_host_extensions.rb +25 -14
  58. data/app/models/katello/concerns/host_managed_extensions.rb +17 -8
  59. data/app/models/katello/concerns/redhat_extensions.rb +16 -6
  60. data/app/models/katello/concerns/smart_proxy_extensions.rb +0 -12
  61. data/app/models/katello/concerns/subscription_facet_host_extensions.rb +1 -0
  62. data/app/models/katello/content_view.rb +22 -5
  63. data/app/models/katello/content_view_environment.rb +11 -2
  64. data/app/models/katello/content_view_environment_content_facet.rb +9 -0
  65. data/app/models/katello/content_view_version.rb +10 -5
  66. data/app/models/katello/erratum.rb +6 -1
  67. data/app/models/katello/glue/candlepin/pool.rb +6 -0
  68. data/app/models/katello/glue/candlepin/product.rb +7 -1
  69. data/app/models/katello/glue/candlepin/subscription.rb +5 -0
  70. data/app/models/katello/glue/provider.rb +26 -26
  71. data/app/models/katello/host/content_facet.rb +106 -18
  72. data/app/models/katello/host/info_provider.rb +25 -21
  73. data/app/models/katello/host/subscription_facet.rb +18 -14
  74. data/app/models/katello/kt_environment.rb +12 -7
  75. data/app/models/katello/package_group.rb +0 -12
  76. data/app/models/katello/pool.rb +4 -1
  77. data/app/models/katello/product.rb +11 -1
  78. data/app/models/katello/repository.rb +11 -11
  79. data/app/models/katello/root_repository.rb +5 -4
  80. data/app/models/katello/task_status.rb +0 -18
  81. data/app/services/katello/candlepin/consumer.rb +2 -2
  82. data/app/services/katello/host/package_profile_uploader.rb +1 -1
  83. data/app/services/katello/product_content_finder.rb +11 -8
  84. data/app/services/katello/pulp3/content_view_version/export.rb +8 -65
  85. data/app/services/katello/pulp3/content_view_version/export_validation_error.rb +7 -0
  86. data/app/services/katello/pulp3/content_view_version/export_validator.rb +105 -0
  87. data/app/services/katello/pulp3/content_view_version/importable_products.rb +1 -1
  88. data/app/services/katello/pulp3/content_view_version/syncable_format_export.rb +7 -1
  89. data/app/services/katello/pulp3/erratum.rb +1 -0
  90. data/app/services/katello/pulp3/module_stream.rb +26 -11
  91. data/app/services/katello/pulp3/repository/yum.rb +2 -1
  92. data/app/services/katello/pulp3/smart_proxy_mirror_repository.rb +2 -1
  93. data/app/services/katello/registration_manager.rb +46 -26
  94. data/app/services/katello/repository_type.rb +3 -9
  95. data/app/services/katello/simple_package.rb +22 -0
  96. data/app/views/foreman/smart_proxies/_content_sync.html.erb +1 -0
  97. data/app/views/foreman/smart_proxies/_reclaim_space.html.erb +1 -0
  98. data/app/views/katello/api/v2/content_facet/base.json.rabl +23 -2
  99. data/app/views/katello/api/v2/content_facet/show.json.rabl +11 -8
  100. data/app/views/katello/api/v2/content_views/base.json.rabl +1 -1
  101. data/app/views/katello/api/v2/hosts/base.json.rabl +22 -2
  102. data/app/views/overrides/activation_keys/_host_environment_select.html.erb +2 -2
  103. data/config/initializers/monkeys.rb +0 -2
  104. data/config/routes/api/registry.rb +8 -7
  105. data/config/routes/api/v2.rb +0 -2
  106. data/config/routes.rb +3 -0
  107. data/db/migrate/20200429153103_installed_package_bad_nvrea.rb +1 -1
  108. data/db/migrate/20220228173251_remove_drpm_from_ignorable_content.rb +7 -3
  109. data/db/migrate/20220419193414_content_settings_to_dsl_category.rb +1 -1
  110. data/db/migrate/20220929204746_add_content_view_environment_content_facet.rb +52 -0
  111. data/db/migrate/20221123212341_remove_pulp_docker_registry_port_setting.rb +5 -0
  112. data/db/seeds.d/111-upgrade_tasks.rb +2 -1
  113. data/engines/bastion/app/assets/stylesheets/bastion/bastion.scss +4 -0
  114. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/activation-keys/details/activation-key-details.controller.js +2 -4
  115. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/bulk/content-hosts-bulk-errata-modal.controller.js +0 -1
  116. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/content-host-details.controller.js +2 -4
  117. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/views/content-hosts.html +2 -1
  118. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/errata/apply-errata.controller.js +11 -3
  119. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/host-collections/details/views/host-collection-hosts-list.html +1 -1
  120. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/bastion_katello.pot +8 -4
  121. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/de.po +5485 -0
  122. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/es.po +5397 -0
  123. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/fr.po +5658 -0
  124. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/ja.po +5284 -0
  125. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/ka.po +5231 -0
  126. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/ko.po +5275 -0
  127. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/pt_BR.po +5389 -0
  128. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/zh_CN.po +5212 -0
  129. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/zh_TW.po +5145 -0
  130. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/translations.js +9 -0
  131. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/views/content-access-mode-banner.html +2 -2
  132. data/lib/katello/engine.rb +2 -1
  133. data/lib/katello/permission_creator.rb +2 -4
  134. data/lib/katello/permissions/registry_permissions.rb +5 -5
  135. data/lib/katello/plugin.rb +22 -14
  136. data/lib/katello/repository_types/README.md +136 -19
  137. data/lib/katello/repository_types/deb.rb +0 -1
  138. data/lib/katello/repository_types/docker.rb +0 -1
  139. data/lib/katello/repository_types/file.rb +0 -1
  140. data/lib/katello/repository_types/yum.rb +0 -4
  141. data/lib/katello/tasks/clean_candlepin_orphaned_products.rake +38 -0
  142. data/lib/katello/tasks/clean_orphaned_facets.rb +20 -0
  143. data/lib/katello/tasks/reimport.rake +1 -2
  144. data/lib/katello/tasks/repository.rake +1 -22
  145. data/lib/katello/tasks/reset.rake +1 -0
  146. data/lib/katello/tasks/upgrades/4.8/fix_incorrect_providers.rake +29 -0
  147. data/lib/katello/version.rb +1 -1
  148. data/lib/katello.rb +0 -5
  149. data/locale/bn/katello.po +69 -27
  150. data/locale/cs/katello.po +69 -27
  151. data/locale/de/katello.po +78 -36
  152. data/locale/en/katello.po +69 -27
  153. data/locale/es/katello.po +70 -28
  154. data/locale/fr/katello.po +73 -31
  155. data/locale/gu/katello.po +69 -27
  156. data/locale/hi/katello.po +69 -27
  157. data/locale/it/katello.po +69 -27
  158. data/locale/ja/katello.po +73 -31
  159. data/locale/ka/katello.po +73 -31
  160. data/locale/katello.pot +335 -262
  161. data/locale/kn/katello.po +69 -27
  162. data/locale/ko/katello.po +69 -27
  163. data/locale/mr/katello.po +69 -27
  164. data/locale/or/katello.po +69 -27
  165. data/locale/pa/katello.po +69 -27
  166. data/locale/pt/katello.po +69 -27
  167. data/locale/pt_BR/katello.po +70 -28
  168. data/locale/ru/katello.po +70 -28
  169. data/locale/ta/katello.po +69 -27
  170. data/locale/te/katello.po +69 -27
  171. data/locale/zh_CN/katello.po +73 -31
  172. data/locale/zh_TW/katello.po +70 -28
  173. data/webpack/components/Content/ContentPage.js +51 -35
  174. data/webpack/components/Content/__tests__/ContentPage.test.js +2 -4
  175. data/webpack/components/Content/__tests__/__snapshots__/ContentPage.test.js.snap +22 -3
  176. data/webpack/components/Table/EmptyStateMessage.js +14 -11
  177. data/webpack/components/Table/MainTable.js +36 -15
  178. data/webpack/components/Table/TableWrapper.js +25 -25
  179. data/webpack/components/Table/__test__/emptyStateMessage.test.js +51 -0
  180. data/webpack/components/extensions/HostDetails/Cards/ErrataOverviewCard.js +5 -4
  181. data/webpack/components/extensions/HostDetails/Cards/HostCollectionsCard/HostCollectionsModal.js +1 -1
  182. data/webpack/components/extensions/HostDetails/Cards/HostCollectionsCard/__tests__/hostCollectionsModal.test.js +1 -17
  183. data/webpack/components/extensions/HostDetails/Tabs/ErrataTab/ErrataTab.js +18 -9
  184. data/webpack/components/extensions/HostDetails/Tabs/ModuleStreamsTab/ModuleStreamsTab.js +1 -2
  185. data/webpack/components/extensions/HostDetails/Tabs/PackagesTab/PackageInstallModal.js +1 -2
  186. data/webpack/components/extensions/HostDetails/Tabs/PackagesTab/PackagesTab.js +1 -2
  187. data/webpack/components/extensions/HostDetails/Tabs/RepositorySetsTab/RepositorySetsTab.js +47 -27
  188. data/webpack/components/extensions/HostDetails/Tabs/TracesTab/TracesTab.js +1 -2
  189. data/webpack/components/extensions/HostDetails/Tabs/__tests__/errataTab.test.js +2 -21
  190. data/webpack/components/extensions/HostDetails/Tabs/__tests__/moduleStreamsTab.test.js +1 -28
  191. data/webpack/components/extensions/HostDetails/Tabs/__tests__/packageInstallModal.test.js +1 -10
  192. data/webpack/components/extensions/HostDetails/Tabs/__tests__/packagesTab.test.js +1 -18
  193. data/webpack/components/extensions/HostDetails/Tabs/__tests__/repositorySetsTab.test.js +1 -17
  194. data/webpack/components/extensions/HostDetails/Tabs/__tests__/tracesTab.test.js +1 -15
  195. data/webpack/global_test_setup.js +1 -1
  196. data/webpack/scenes/AlternateContentSources/Create/ACSCreateWizard.js +12 -10
  197. data/webpack/scenes/AlternateContentSources/Create/Steps/ACSCredentials.js +6 -0
  198. data/webpack/scenes/AlternateContentSources/Create/Steps/ACSSmartProxies.js +1 -0
  199. data/webpack/scenes/AlternateContentSources/Create/Steps/AcsUrlPaths.js +3 -10
  200. data/webpack/scenes/AlternateContentSources/Create/Steps/NameACS.js +1 -0
  201. data/webpack/scenes/AlternateContentSources/Create/__tests__/acsCreate.test.js +3 -3
  202. data/webpack/scenes/AlternateContentSources/Details/EditModals/ACSEditDetails.js +1 -0
  203. data/webpack/scenes/AlternateContentSources/Details/EditModals/ACSEditURLPaths.js +12 -4
  204. data/webpack/scenes/AlternateContentSources/MainTable/ACSTable.js +7 -4
  205. data/webpack/scenes/AlternateContentSources/MainTable/__tests__/acsTable.test.js +4 -8
  206. data/webpack/scenes/AlternateContentSources/helpers.js +1 -1
  207. data/webpack/scenes/Content/Details/ContentRepositories.js +5 -4
  208. data/webpack/scenes/Content/Details/__tests__/contentDetail.test.js +1 -12
  209. data/webpack/scenes/Content/Table/ContentTable.js +2 -1
  210. data/webpack/scenes/Content/__tests__/contentTable.test.js +1 -14
  211. data/webpack/scenes/ContentViews/Delete/__tests__/contentViewDelete.test.js +1 -25
  212. data/webpack/scenes/ContentViews/Details/ComponentContentViews/ContentViewComponents.js +2 -1
  213. data/webpack/scenes/ContentViews/Details/ComponentContentViews/__tests__/contentViewComponents.test.js +44 -31
  214. data/webpack/scenes/ContentViews/Details/ContentViewDetails.js +2 -0
  215. data/webpack/scenes/ContentViews/Details/Filters/AffectedRepositories/AffectedRepositoryTable.js +6 -1
  216. data/webpack/scenes/ContentViews/Details/Filters/CVContainerImageFilterContent.js +2 -1
  217. data/webpack/scenes/ContentViews/Details/Filters/CVDebFilterContent.js +2 -1
  218. data/webpack/scenes/ContentViews/Details/Filters/CVErrataIDFilterContent.js +3 -1
  219. data/webpack/scenes/ContentViews/Details/Filters/CVModuleStreamFilterContent.js +3 -1
  220. data/webpack/scenes/ContentViews/Details/Filters/CVPackageGroupFilterContent.js +3 -1
  221. data/webpack/scenes/ContentViews/Details/Filters/CVRpmFilterContent.js +2 -1
  222. data/webpack/scenes/ContentViews/Details/Filters/ContentViewFilterDetailsHeader.js +2 -0
  223. data/webpack/scenes/ContentViews/Details/Filters/ContentViewFilters.js +2 -1
  224. data/webpack/scenes/ContentViews/Details/Filters/MatchContentModal/CVDebMatchContentModal.js +1 -1
  225. data/webpack/scenes/ContentViews/Details/Filters/MatchContentModal/CVRpmMatchContentModal.js +1 -1
  226. data/webpack/scenes/ContentViews/Details/Filters/MatchContentModal/__tests__/CVRpmMatchContentModal.test.js +35 -33
  227. data/webpack/scenes/ContentViews/Details/Filters/__tests__/CVContainerImageFilterContent.test.js +48 -45
  228. data/webpack/scenes/ContentViews/Details/Filters/__tests__/CVRpmFilterContent.test.js +58 -24
  229. data/webpack/scenes/ContentViews/Details/Filters/__tests__/ContentViewPackageGroupFilter.test.js +64 -0
  230. data/webpack/scenes/ContentViews/Details/Filters/__tests__/contentViewFilterDetails.test.js +36 -20
  231. data/webpack/scenes/ContentViews/Details/Filters/__tests__/contentViewFilters.test.js +40 -23
  232. data/webpack/scenes/ContentViews/Details/Filters/__tests__/cvErrataIDFilter.test.js +0 -13
  233. data/webpack/scenes/ContentViews/Details/Filters/__tests__/cvModuleStreamFilter.test.js +0 -13
  234. data/webpack/scenes/ContentViews/Details/Histories/ContentViewHistories.js +2 -1
  235. data/webpack/scenes/ContentViews/Details/Histories/__tests__/contentViewHistory.test.js +1 -10
  236. data/webpack/scenes/ContentViews/Details/Repositories/ContentViewRepositories.js +2 -1
  237. data/webpack/scenes/ContentViews/Details/Repositories/__tests__/contentViewAddRemove.test.js +1 -10
  238. data/webpack/scenes/ContentViews/Details/Versions/Compare/CVVersionCompareConfig.js +21 -9
  239. data/webpack/scenes/ContentViews/Details/Versions/Compare/CVVersionCompareTable.js +4 -0
  240. data/webpack/scenes/ContentViews/Details/Versions/Compare/__tests__/CVVersionCompare.test.js +1 -32
  241. data/webpack/scenes/ContentViews/Details/Versions/ContentViewVersions.js +3 -1
  242. data/webpack/scenes/ContentViews/Details/Versions/Delete/__tests__/cvVersionRemove.test.js +1 -15
  243. data/webpack/scenes/ContentViews/Details/Versions/Delete/affectedActivationKeys.js +1 -1
  244. data/webpack/scenes/ContentViews/Details/Versions/Delete/affectedHosts.js +1 -2
  245. data/webpack/scenes/ContentViews/Details/Versions/VersionDetails/ContentViewVersionDetailConfig.js +31 -9
  246. data/webpack/scenes/ContentViews/Details/Versions/VersionDetails/ContentViewVersionDetailsTable.js +4 -0
  247. data/webpack/scenes/ContentViews/Details/Versions/VersionDetails/__tests__/ContentViewVersionDetails.test.js +30 -14
  248. data/webpack/scenes/ContentViews/Table/ContentViewsTable.js +1 -1
  249. data/webpack/scenes/ContentViews/__tests__/contentViewPage.test.js +55 -120
  250. data/webpack/scenes/ContentViews/components/WizardHeader.js +1 -1
  251. data/webpack/scenes/ContentViews/expansions/RelatedContentViewComponentsModal.js +1 -1
  252. data/webpack/scenes/ContentViews/expansions/__tests__/contentViewComponentsModal.test.js +8 -1
  253. data/webpack/scenes/ModuleStreams/ModuleStreamsPage.js +3 -9
  254. data/webpack/scenes/ModuleStreams/__tests__/__snapshots__/ModuleStreamPage.test.js.snap +7 -1
  255. data/webpack/scenes/RedHatRepositories/components/Search.js +22 -16
  256. data/webpack/scenes/RedHatRepositories/index.scss +20 -1
  257. data/webpack/scenes/SmartProxy/SmartProxyContentTable.js +12 -1
  258. data/webpack/scenes/Subscriptions/Manifest/CdnConfigurationTab/CdnTypeForm.js +1 -1
  259. data/webpack/scenes/Subscriptions/Manifest/CdnConfigurationTab/CustomCdnTypeForm.js +1 -1
  260. data/webpack/scenes/Subscriptions/SubscriptionsPage.js +21 -19
  261. data/webpack/scenes/Subscriptions/__tests__/__snapshots__/SubscriptionsPage.test.js.snap +34 -1
  262. data/webpack/scenes/Subscriptions/components/SubscriptionsToolbar/SubscriptionsToolbar.js +20 -7
  263. data/webpack/scenes/Subscriptions/components/SubscriptionsToolbar/SubscriptionsToolbar.test.js +0 -1
  264. data/webpack/scenes/Subscriptions/components/SubscriptionsToolbar/__snapshots__/SubscriptionsToolbar.test.js.snap +65 -15
  265. metadata +47 -113
  266. data/app/lib/actions/katello/pulp_selector.rb +0 -24
  267. data/app/lib/actions/katello/repository/correct_checksum.rb +0 -24
  268. data/app/lib/actions/katello/repository/destroy_package_group.rb +0 -26
  269. data/app/lib/actions/katello/repository/upload_package_group.rb +0 -24
  270. data/app/lib/actions/pulp/abstract.rb +0 -37
  271. data/app/lib/actions/pulp/abstract_async_task.rb +0 -154
  272. data/app/lib/actions/pulp/abstract_async_task_group.rb +0 -94
  273. data/app/lib/actions/pulp/consumer/sync_capsule.rb +0 -45
  274. data/app/lib/actions/pulp/consumer/unassociate_units.rb +0 -20
  275. data/app/lib/actions/pulp/expect_one_task.rb +0 -11
  276. data/app/lib/actions/pulp/orchestration/orphan_cleanup/remove_orphans.rb +0 -16
  277. data/app/lib/actions/pulp/orchestration/repository/copy_all_units.rb +0 -19
  278. data/app/lib/actions/pulp/orchestration/repository/delete.rb +0 -15
  279. data/app/lib/actions/pulp/orchestration/repository/refresh.rb +0 -14
  280. data/app/lib/actions/pulp/orchestration/repository/refresh_if_needed.rb +0 -13
  281. data/app/lib/actions/pulp/orchestration/repository/refresh_repos.rb +0 -19
  282. data/app/lib/actions/pulp/orchestration/repository/remove_units.rb +0 -14
  283. data/app/lib/actions/pulp/orchestration/repository/smart_proxy_sync.rb +0 -34
  284. data/app/lib/actions/pulp/orchestration/repository/sync.rb +0 -18
  285. data/app/lib/actions/pulp/orchestration/repository/upload_content.rb +0 -37
  286. data/app/lib/actions/pulp/orphan_cleanup/remove_orphans.rb +0 -15
  287. data/app/lib/actions/pulp/orphan_cleanup/remove_unneeded_repos.rb +0 -16
  288. data/app/lib/actions/pulp/repository/abstract_copy_content.rb +0 -45
  289. data/app/lib/actions/pulp/repository/abstract_remove_content.rb +0 -32
  290. data/app/lib/actions/pulp/repository/clear.rb +0 -18
  291. data/app/lib/actions/pulp/repository/copy_all_units.rb +0 -30
  292. data/app/lib/actions/pulp/repository/copy_units.rb +0 -25
  293. data/app/lib/actions/pulp/repository/create.rb +0 -28
  294. data/app/lib/actions/pulp/repository/create_in_plan.rb +0 -15
  295. data/app/lib/actions/pulp/repository/create_upload_request.rb +0 -20
  296. data/app/lib/actions/pulp/repository/delete_upload_request.rb +0 -19
  297. data/app/lib/actions/pulp/repository/destroy.rb +0 -28
  298. data/app/lib/actions/pulp/repository/distributor_publish.rb +0 -25
  299. data/app/lib/actions/pulp/repository/download.rb +0 -16
  300. data/app/lib/actions/pulp/repository/import_upload.rb +0 -19
  301. data/app/lib/actions/pulp/repository/presenters/abstract_sync_presenter.rb +0 -47
  302. data/app/lib/actions/pulp/repository/presenters/deb_presenter.rb +0 -95
  303. data/app/lib/actions/pulp/repository/presenters/docker_presenter.rb +0 -103
  304. data/app/lib/actions/pulp/repository/presenters/file_unit_presenter.rb +0 -42
  305. data/app/lib/actions/pulp/repository/presenters/yum_presenter.rb +0 -131
  306. data/app/lib/actions/pulp/repository/refresh.rb +0 -21
  307. data/app/lib/actions/pulp/repository/regenerate_applicability.rb +0 -21
  308. data/app/lib/actions/pulp/repository/remove_distribution.rb +0 -11
  309. data/app/lib/actions/pulp/repository/remove_units.rb +0 -44
  310. data/app/lib/actions/pulp/repository/sync.rb +0 -99
  311. data/app/lib/actions/pulp/repository/upload_file.rb +0 -28
  312. data/app/lib/actions/pulp/repository_group/create.rb +0 -31
  313. data/app/lib/actions/pulp/repository_group/delete.rb +0 -17
  314. data/app/lib/actions/pulp/repository_group/export.rb +0 -51
  315. data/app/lib/katello/util/package_clause_generator.rb +0 -77
  316. data/app/models/katello/glue/pulp/pulp_errors.rb +0 -9
  317. data/app/models/katello/glue/pulp/repo.rb +0 -353
  318. data/app/models/katello/pulp_sync_status.rb +0 -165
  319. data/app/models/katello/pulp_task_status.rb +0 -63
  320. data/app/services/katello/pulp/content.rb +0 -24
  321. data/app/services/katello/pulp/importer_comparison.rb +0 -28
  322. data/app/services/katello/pulp/repository/deb.rb +0 -61
  323. data/app/services/katello/pulp/repository/docker.rb +0 -82
  324. data/app/services/katello/pulp/repository/file.rb +0 -52
  325. data/app/services/katello/pulp/repository/yum.rb +0 -205
  326. data/app/services/katello/pulp/repository.rb +0 -327
  327. data/app/services/katello/pulp/server.rb +0 -35
  328. data/app/services/katello/pulp/simple_package.rb +0 -24
  329. data/app/services/katello/pulp/smart_proxy_repository.rb +0 -52
  330. data/lib/monkeys/fix_deb_optimized_sync.rb +0 -35
  331. data/lib/monkeys/fix_pulp_container_path.rb +0 -35
  332. data/locale/zanata.xml +0 -30
  333. data/webpack/scenes/ContentViews/Details/Filters/MatchContentModal/__tests__/CVRpmMatchContentSearch.fixtures.json +0 -33
@@ -8,9 +8,13 @@ module Katello
8
8
 
9
9
  belongs_to :content_view, :class_name => "Katello::ContentView", :inverse_of => :content_view_environments
10
10
  belongs_to :environment, :class_name => "Katello::KTEnvironment", :inverse_of => :content_view_environments
11
+ belongs_to :lifecycle_environment, :class_name => "Katello::KTEnvironment", :foreign_key => :environment_id, :inverse_of => :content_view_environments
11
12
  belongs_to :content_view_version, :class_name => "Katello::ContentViewVersion",
12
13
  :inverse_of => :content_view_environments
13
14
 
15
+ has_many :content_view_environment_content_facets, :class_name => "Katello::ContentViewEnvironmentContentFacet", :dependent => :destroy, :inverse_of => :content_view_environment
16
+ has_many :content_facets, through: :content_view_environment_content_facets, :class_name => "::Katello::Host::ContentFacet", :inverse_of => :content_view_environments
17
+
14
18
  validates_lengths_from_database
15
19
  validates :environment_id, uniqueness: {scope: :content_view_id}, presence: true
16
20
  validates :content_view_id, presence: true
@@ -19,10 +23,10 @@ module Katello
19
23
  before_save :generate_info
20
24
 
21
25
  scope :non_default, -> { joins(:content_view).where("katello_content_views.default" => false) }
26
+ alias :lifecycle_environment :environment
22
27
 
23
28
  def self.for_content_facets(content_facets)
24
- joins("INNER JOIN #{Host::ContentFacet.table_name} on #{Host::ContentFacet.table_name}.lifecycle_environment_id = #{ContentViewEnvironment.table_name}.environment_id").
25
- where("#{Host::ContentFacet.table_name}.content_view_id = #{ContentViewEnvironment.table_name}.content_view_id").where("#{Host::ContentFacet.table_name}.id" => content_facets).uniq
29
+ joins(:content_view_environment_content_facets, :content_facets).where("#{Katello::ContentViewEnvironmentContentFacet.table_name}.content_facet_id" => content_facets).uniq
26
30
  end
27
31
 
28
32
  # retrieve the owning environment for this content view environment.
@@ -38,6 +42,11 @@ module Katello
38
42
  content_view.activation_keys.in_environment(environment)
39
43
  end
40
44
 
45
+ # TODO: uncomment when we need to start showing multiple CVE names in UI
46
+ # def candlepin_name
47
+ # "#{environment.label}/#{content_view.label}"
48
+ # end
49
+
41
50
  private
42
51
 
43
52
  def generate_info
@@ -0,0 +1,9 @@
1
+ module Katello
2
+ class ContentViewEnvironmentContentFacet < Katello::Model
3
+ belongs_to :content_view_environment, :class_name => "::Katello::ContentViewEnvironment", :inverse_of => :content_view_environment_content_facets
4
+ belongs_to :content_facet, :class_name => "::Katello::Host::ContentFacet", :inverse_of => :content_view_environment_content_facets
5
+
6
+ validates :content_view_environment_id, presence: true
7
+ validates :content_facet_id, presence: true, unless: :new_record?
8
+ end
9
+ end
@@ -99,8 +99,7 @@ module Katello
99
99
  def self.for_version(version)
100
100
  major, minor = version.to_s.split('.')
101
101
  minor ||= 0
102
- query = where(:major => major, :minor => minor)
103
- query
102
+ where(:major => major, :minor => minor)
104
103
  end
105
104
 
106
105
  def to_s
@@ -165,6 +164,10 @@ module Katello
165
164
  "#{major}.#{minor}"
166
165
  end
167
166
 
167
+ def incrementally_updated?
168
+ minor != 0
169
+ end
170
+
168
171
  def repos(env)
169
172
  self.repositories.in_environment(env)
170
173
  end
@@ -333,9 +336,10 @@ module Katello
333
336
  def update_content_counts!
334
337
  self.content_counts = {}
335
338
  RepositoryTypeManager.indexable_content_types.each do |content_type|
336
- if content_type&.model_class::CONTENT_TYPE == DockerTag::CONTENT_TYPE
339
+ case content_type&.model_class::CONTENT_TYPE
340
+ when DockerTag::CONTENT_TYPE
337
341
  content_counts[DockerTag::CONTENT_TYPE] = docker_tags.count
338
- elsif content_type&.model_class::CONTENT_TYPE == GenericContentUnit::CONTENT_TYPE
342
+ when GenericContentUnit::CONTENT_TYPE
339
343
  content_counts[content_type.content_type] = content_type&.model_class&.in_repositories(self.repositories.archived)&.where(:content_type => content_type.content_type)&.count
340
344
  else
341
345
  content_counts[content_type&.model_class::CONTENT_TYPE] = content_type&.model_class&.in_repositories(self.repositories.archived)&.count
@@ -376,9 +380,10 @@ module Katello
376
380
  fail _("Default content view versions cannot be promoted") if default?
377
381
  content_view.check_composite_action_allowed!(to_env)
378
382
  content_view.check_docker_repository_names!(to_env)
383
+ content_view.check_orphaned_content_facets!(environments: [to_env])
379
384
  end
380
385
 
381
- def validate_destroyable!(skip_environment_check = false)
386
+ def validate_destroyable!(skip_environment_check: false)
382
387
  unless organization.being_deleted?
383
388
  if !skip_environment_check && in_environment?
384
389
  fail _("Cannot delete version while it is in environments: %s") %
@@ -24,7 +24,8 @@ module Katello
24
24
  has_many :cves, :class_name => "Katello::ErratumCve", :dependent => :destroy, :inverse_of => :erratum
25
25
  has_many :packages, :class_name => "Katello::ErratumPackage", :dependent => :destroy, :inverse_of => :erratum
26
26
 
27
- scoped_search :on => :errata_id, :only_explicit => true
27
+ scoped_search :on => :id, :rename => :db_id, :only_explicit => true, :validator => ScopedSearch::Validators::INTEGER
28
+ scoped_search :on => :errata_id, :complete_value => true, :only_explicit => true
28
29
  scoped_search :on => :errata_id, :rename => :id, :complete_value => true, :only_explicit => true
29
30
  scoped_search :on => :title
30
31
  scoped_search :on => :title, :rename => :synopsis, :complete_value => true, :only_explicit => true
@@ -152,6 +153,10 @@ module Katello
152
153
  end
153
154
  end
154
155
 
156
+ def module_stream_specs
157
+ packages.collect { |package| package.module_streams.map(&:module_spec) }.flatten.uniq
158
+ end
159
+
155
160
  def module_stream_objects
156
161
  streams = packages.map do |pack|
157
162
  pack.module_streams
@@ -56,6 +56,12 @@ module Katello
56
56
  end
57
57
  end
58
58
 
59
+ def import_candlepin_records(pools, org)
60
+ # Skip import of pools that were associated with an orphaned custom product
61
+ pools = pools.reject { |cp_pool| ::Katello::Glue::Provider.orphaned_custom_product?(cp_pool['productId'], org) }
62
+ super(pools, org)
63
+ end
64
+
59
65
  def import_candlepin_record(record:, organization:)
60
66
  subscription = determine_subscription(
61
67
  product_id: record['productId'],
@@ -32,7 +32,7 @@ module Katello
32
32
  id.match(/^\d+$/) #engineering products are numeric
33
33
  end
34
34
 
35
- def self.import_from_cp(attrs, organization)
35
+ def self.import_redhat_product_from_cp(attrs, organization)
36
36
  import_logger = attrs[:import_logger]
37
37
 
38
38
  product_attrs = {'name' => attrs['name'],
@@ -50,6 +50,12 @@ module Katello
50
50
  raise e
51
51
  end
52
52
 
53
+ def self.custom_product_id?(id)
54
+ # Engineering products with 12 digits are custom products (see Katello::Product#unused_product_id)
55
+ # however, previously generated ids are random and can be shorter than 12 digits
56
+ id =~ /^\d{8,12}$/
57
+ end
58
+
53
59
  module InstanceMethods
54
60
  def support_level
55
61
  return _attr(:support_level)
@@ -21,6 +21,11 @@ module Katello
21
21
  !Glue::Candlepin::Product.engineering_product_id?(product['id']) || Katello::Product.find_by(:cp_id => product['id']).try(:custom?)
22
22
  end
23
23
  end
24
+
25
+ def import_candlepin_records(cp_subs, org)
26
+ cp_subs = cp_subs.reject { |cp_subscription| ::Katello::Glue::Provider.orphaned_custom_product?(cp_subscription['productId'], org) }
27
+ super(cp_subs, org)
28
+ end
24
29
  end
25
30
 
26
31
  module InstanceMethods
@@ -6,6 +6,30 @@ module Katello
6
6
  base.send :include, InstanceMethods
7
7
  end
8
8
 
9
+ def self.orphaned_custom_product?(cp_id, organization)
10
+ return unless cp_id.present? && orphaned_product?(cp_id, organization)
11
+ product_provider = provider_for_cp_id(cp_id: cp_id, organization: organization)
12
+ if product_provider.redhat_provider?
13
+ false
14
+ else
15
+ Rails.logger.warn "Found orphaned object with id #{cp_id} in Candlepin. Skipping import into Katello; run rake katello:delete_orphaned_custom_products to remove it from Candlepin."
16
+ true
17
+ end
18
+ end
19
+
20
+ def self.orphaned_product?(cp_id, organization)
21
+ !organization.products.where(:cp_id => cp_id).exists?
22
+ end
23
+
24
+ def self.provider_for_cp_id(cp_id:, organization:)
25
+ return organization.redhat_provider unless ::Katello::Glue::Candlepin::Product.engineering_product_id?(cp_id)
26
+ if ::Katello::Glue::Candlepin::Product.custom_product_id?(cp_id)
27
+ organization.anonymous_provider
28
+ else
29
+ organization.redhat_provider
30
+ end
31
+ end
32
+
9
33
  module InstanceMethods
10
34
  API_URL = 'https://subscription.rhsm.redhat.com/subscription/consumers/'.freeze
11
35
 
@@ -21,31 +45,6 @@ module Katello
21
45
  self.products.any? { |p| p.synced? }
22
46
  end
23
47
 
24
- # Get the most relavant status for all the repos in this Provider
25
- def sync_status
26
- statuses = self.products.reject { |r| r.empty? }.map { |r| r.sync_status }
27
- return PulpSyncStatus.new(:state => PulpSyncStatus::Status::NOT_SYNCED) if statuses.empty?
28
-
29
- [PulpSyncStatus::Status::RUNNING,
30
- PulpSyncStatus::Status::NOT_SYNCED,
31
- PulpSyncStatus::Status::CANCELED,
32
- PulpSyncStatus::Status::ERROR].each do |interesting_status|
33
- relevant_status = statuses.find { |s| s[:state].to_s == interesting_status.to_s }
34
- return relevant_status if relevant_status
35
- end
36
-
37
- #else -> all finished
38
- return statuses[0]
39
- end
40
-
41
- def sync_state
42
- self.sync_status[:state]
43
- end
44
-
45
- def sync_size
46
- self.products.inject(0) { |sum, v| sum + v.sync_status.progress.total_size }
47
- end
48
-
49
48
  def last_sync
50
49
  sync_times = []
51
50
  self.products.each do |prod|
@@ -126,6 +125,7 @@ module Katello
126
125
 
127
126
  Katello::Logging.time("Imported #{cp_products.size} products") do
128
127
  cp_products.each do |product_json|
128
+ next if ::Katello::Glue::Provider.orphaned_custom_product?(product_json['id'], organization)
129
129
  product = import_product(product_json)
130
130
  prod_content_importer.add_product_content(product, product_json['productContent']) if product.redhat?
131
131
  end
@@ -144,7 +144,7 @@ module Katello
144
144
  if product&.redhat?
145
145
  product.update!(:name => product_json['name']) unless product.name == product_json['name']
146
146
  elsif product.nil?
147
- product = Glue::Candlepin::Product.import_from_cp(product_json, organization)
147
+ product = Glue::Candlepin::Product.import_redhat_product_from_cp(product_json, organization)
148
148
  end
149
149
  product
150
150
  end
@@ -10,10 +10,15 @@ module Katello
10
10
  SUBSCRIPTION_MANAGER_PACKAGE_NAME = 'subscription-manager'.freeze
11
11
 
12
12
  belongs_to :kickstart_repository, :class_name => "::Katello::Repository", :inverse_of => :kickstart_content_facets
13
- belongs_to :content_view, :inverse_of => :content_facets, :class_name => "Katello::ContentView"
14
- belongs_to :lifecycle_environment, :inverse_of => :content_facets, :class_name => "Katello::KTEnvironment"
15
13
  belongs_to :content_source, :class_name => "::SmartProxy", :inverse_of => :content_facets
16
14
 
15
+ has_many :content_view_environment_content_facets, :class_name => "Katello::ContentViewEnvironmentContentFacet", :dependent => :destroy, :inverse_of => :content_facet
16
+ has_many :content_view_environments, :through => :content_view_environment_content_facets,
17
+ :class_name => "Katello::ContentViewEnvironment", :source => :content_view_environment,
18
+ :after_add => :mark_cves_changed, :after_remove => :mark_cves_changed
19
+ has_many :content_views, :through => :content_view_environments, :class_name => "Katello::ContentView"
20
+ has_many :lifecycle_environments, :through => :content_view_environments, :class_name => "Katello::KTEnvironment"
21
+
17
22
  has_many :content_facet_errata, :class_name => "Katello::ContentFacetErratum", :dependent => :delete_all, :inverse_of => :content_facet
18
23
  has_many :applicable_errata, :through => :content_facet_errata, :class_name => "Katello::Erratum", :source => :erratum
19
24
 
@@ -31,11 +36,85 @@ module Katello
31
36
  has_many :content_facet_applicable_module_streams, :class_name => "Katello::ContentFacetApplicableModuleStream", :dependent => :delete_all, :inverse_of => :content_facet
32
37
  has_many :applicable_module_streams, :through => :content_facet_applicable_module_streams, :class_name => "Katello::ModuleStream", :source => :module_stream
33
38
 
34
- validates :content_view, :presence => true, :allow_blank => false
35
- validates :lifecycle_environment, :presence => true, :allow_blank => false
36
39
  validates_with ::AssociationExistsValidator, attributes: [:content_source]
40
+ validates_with Katello::Validators::GeneratedContentViewValidator
37
41
  validates :host, :presence => true, :allow_blank => false
38
- validates_with Validators::ContentViewEnvironmentValidator
42
+
43
+ attr_accessor :cves_changed
44
+
45
+ def initialize(*args)
46
+ init_args = args.first || {}
47
+ env_id = init_args.delete(:lifecycle_environment_id)
48
+ cv_id = init_args.delete(:content_view_id)
49
+ super(*args)
50
+ if env_id && cv_id
51
+ assign_single_environment(
52
+ lifecycle_environment_id: env_id,
53
+ content_view_id: cv_id
54
+ )
55
+ end
56
+ self.cves_changed = false
57
+ end
58
+
59
+ def mark_cves_changed(_cve)
60
+ self.cves_changed = true
61
+ end
62
+
63
+ def cves_changed?
64
+ cves_changed
65
+ end
66
+
67
+ def multi_content_view_environment?
68
+ content_view_environments.size > 1
69
+ end
70
+
71
+ def single_content_view_environment?
72
+ content_view_environments.size == 1
73
+ end
74
+
75
+ def single_content_view
76
+ if multi_content_view_environment?
77
+ Rails.logger.warn _("Content facet for host %s has more than one content view. Use #content_views instead.") % host.name
78
+ end
79
+ content_view_environments&.first&.content_view
80
+ end
81
+
82
+ def single_lifecycle_environment
83
+ if multi_content_view_environment?
84
+ Rails.logger.warn _("Content facet for host %s has more than one lifecycle environment. Use #lifecycle_environments instead.") % host.name
85
+ end
86
+ content_view_environments&.first&.lifecycle_environment
87
+ end
88
+
89
+ def assign_single_environment(
90
+ content_view_id: nil, lifecycle_environment_id: nil, environment_id: nil,
91
+ content_view: nil, lifecycle_environment: nil, environment: nil
92
+ )
93
+ lifecycle_environment_id ||= environment_id || lifecycle_environment&.id || environment&.id
94
+ content_view_id ||= content_view&.id
95
+
96
+ unless lifecycle_environment_id
97
+ fail _("Lifecycle environment must be specified")
98
+ end
99
+
100
+ unless content_view_id
101
+ fail _("Content view must be specified")
102
+ end
103
+
104
+ content_view_environment = ::Katello::ContentViewEnvironment
105
+ .where(:content_view_id => content_view_id, :environment_id => lifecycle_environment_id)
106
+ .first_or_create do |cve|
107
+ Rails.logger.info("ContentViewEnvironment not found for content view '#{cve.content_view_name}' and environment '#{cve.environment&.name}'; creating a new one.")
108
+ end
109
+ fail _("Unable to create ContentViewEnvironment. Check the logs for more information.") if content_view_environment.nil?
110
+ self.content_view_environments = [content_view_environment]
111
+ end
112
+
113
+ def default_environment?
114
+ content_view_environments.any? do |cve|
115
+ cve.content_view.default? && cve.lifecycle_environment.library?
116
+ end
117
+ end
39
118
 
40
119
  def update_repositories_by_paths(paths)
41
120
  prefixes = %w(/pulp/deb/ /pulp/repos/ /pulp/content/)
@@ -138,13 +217,21 @@ module Katello
138
217
  end
139
218
 
140
219
  def self.in_content_view_version_environments(version_environments)
141
- #takes a structure of [{:content_view_version => ContentViewVersion, :environments => [KTEnvironment]}]
220
+ # takes a structure of [{:content_view_version => ContentViewVersion, :environments => [KTEnvironment]}]
221
+ relation = self.joins(:content_view_environment_content_facets => :content_view_environment)
142
222
  queries = version_environments.map do |version_environment|
143
223
  version = version_environment[:content_view_version]
144
224
  env_ids = version_environment[:environments].map(&:id)
145
- "(#{table_name}.content_view_id = #{version.content_view_id} AND #{table_name}.lifecycle_environment_id IN (#{env_ids.join(',')}))"
225
+ "(#{::Katello::ContentViewEnvironment.table_name}.content_view_version_id = #{version.id} AND #{::Katello::ContentViewEnvironment.table_name}.environment_id IN (#{env_ids.join(',')}))"
146
226
  end
147
- where(queries.join(" OR "))
227
+ relation.where(queries.join(" OR "))
228
+ end
229
+
230
+ def self.in_content_views_and_environments(content_views: nil, lifecycle_environments: nil)
231
+ relation = self.joins(:content_view_environment_content_facets => :content_view_environment)
232
+ relation = relation.where("#{::Katello::ContentViewEnvironment.table_name}.content_view_id" => content_views) if content_views
233
+ relation = relation.where("#{::Katello::ContentViewEnvironment.table_name}.environment_id" => lifecycle_environments) if lifecycle_environments
234
+ relation
148
235
  end
149
236
 
150
237
  def self.with_non_installable_errata(errata, hosts = nil)
@@ -202,12 +289,10 @@ module Katello
202
289
  where("#{facet_repository}.content_facet_id = #{self.table_name}.id")
203
290
  end
204
291
 
205
- def content_view_version
206
- content_view.version(lifecycle_environment)
207
- end
208
-
209
292
  def available_releases
210
- self.content_view.version(self.lifecycle_environment).available_releases
293
+ self.content_view_environments.flat_map do |cve|
294
+ cve.content_view.version(cve.lifecycle_environment).available_releases
295
+ end
211
296
  end
212
297
 
213
298
  def katello_agent_installed?
@@ -231,6 +316,11 @@ module Katello
231
316
  host.refresh_global_status!
232
317
  end
233
318
 
319
+ # TODO: uncomment when we need to display multiple CVE names in the UI
320
+ # def content_view_environment_names
321
+ # content_view_environments.map(&:candlepin_name).join(', ')
322
+ # end
323
+
234
324
  def self.joins_installable_relation(content_model, facet_join_model)
235
325
  facet_repository = Katello::ContentFacetRepository.table_name
236
326
  content_table = content_model.table_name
@@ -267,16 +357,14 @@ module Katello
267
357
  property :upgradable_rpm_count, Integer, desc: 'Returns upgradable RPM count'
268
358
  property :content_source, 'SmartProxy', desc: 'Returns Smart Proxy object as the content source'
269
359
  prop_group :katello_idname_props, Katello::Model, meta: { resource: 'content_source' }
270
- prop_group :katello_idname_props, Katello::Model, meta: { resource: 'content_view' }
271
360
  property :errata_counts, Hash, desc: 'Returns key=value object with errata counts, e.g. {security: 0, bugfix: 0, enhancement: 0, total: 0}'
272
361
  property :kickstart_repository, 'Repository', desc: 'Returns Kickstart repository object'
273
362
  prop_group :katello_idname_props, Katello::Model, meta: { resource: 'kickstart_repository' }
274
- prop_group :katello_idname_props, Katello::Model, meta: { resource: 'lifecycle_environment' }
275
363
  end
276
364
  class Jail < ::Safemode::Jail
277
- allow :applicable_deb_count, :applicable_module_stream_count, :applicable_rpm_count, :content_source, :content_source_id, :content_source_name, :content_view_id,
278
- :content_view_name, :errata_counts, :id, :kickstart_repository, :kickstart_repository_id, :kickstart_repository_name,
279
- :lifecycle_environment_id, :lifecycle_environment_name, :upgradable_deb_count, :upgradable_module_stream_count, :upgradable_rpm_count, :uuid
365
+ allow :applicable_deb_count, :applicable_module_stream_count, :applicable_rpm_count, :content_source, :content_source_id, :content_source_name,
366
+ :errata_counts, :id, :kickstart_repository, :kickstart_repository_id, :kickstart_repository_name,
367
+ :upgradable_deb_count, :upgradable_module_stream_count, :upgradable_rpm_count, :uuid
280
368
  end
281
369
  end
282
370
  end
@@ -6,15 +6,21 @@ module Katello
6
6
  def host_info
7
7
  info = {}
8
8
  info['parameters'] = {
9
- 'foreman_host_collections' => host.host_collections.map(&:name),
10
- 'lifecycle_environment' => host.lifecycle_environment.try(:label),
11
-
12
- 'content_view' => host.content_view.try(:label),
13
- 'content_view_info' => content_view_info
9
+ 'foreman_host_collections' => host.host_collections.map(&:name)
14
10
  }
15
11
 
16
12
  if host.content_facet.present?
17
13
  info['parameters']['kickstart_repository'] = host.content_facet.kickstart_repository.try(:label)
14
+ if host.single_content_view_environment?
15
+ info['parameters']['lifecycle_environment'] = host.single_lifecycle_environment.try(:label)
16
+ info['parameters']['content_view'] = host.single_content_view.try(:label)
17
+ info['parameters']['content_view_info'] = content_view_info(host.content_view_environments.first)
18
+ end
19
+ info['parameters']['content_views'] = host.content_view_environments.map do |cve|
20
+ content_view_info(cve).merge(
21
+ 'lifecycle_environment' => cve.lifecycle_environment.try(:label)
22
+ )
23
+ end
18
24
  end
19
25
 
20
26
  if (rhsm_url = host.content_source&.rhsm_url)
@@ -28,25 +34,23 @@ module Katello
28
34
  info
29
35
  end
30
36
 
31
- def content_view_info
32
- return {} if host.content_view.blank?
33
-
34
- content_view_info = {
35
- 'label' => host.content_view.try(:label),
36
- 'latest-version' => host.content_view.try(:latest_version),
37
- 'version' => content_version.try(:version),
38
- 'published' => content_version.try(:created_at).try(:time).to_s,
39
- 'components' => content_view_components
37
+ def content_view_info(content_view_environment)
38
+ content_view = content_view_environment.content_view
39
+ return {} if content_view.blank?
40
+ {
41
+ 'label' => content_view.try(:label),
42
+ 'latest-version' => content_view.try(:latest_version),
43
+ 'version' => content_version(content_view_environment).try(:version),
44
+ 'published' => content_version(content_view_environment).try(:created_at).try(:time).to_s,
45
+ 'components' => content_view_components(content_view_environment)
40
46
  }
41
-
42
- content_view_info
43
47
  end
44
48
 
45
- def content_view_components
46
- return {} unless host.content_view.try(:composite)
49
+ def content_view_components(content_view_environment)
50
+ return {} unless content_view_environment.content_view.try(:composite)
47
51
 
48
52
  components = {}
49
- content_version.try(:content_view_version_components).map do |cv|
53
+ content_version(content_view_environment).try(:content_view_version_components).map do |cv|
50
54
  cv_label = cv.component_version.content_view.label
51
55
  components[cv_label] = {}
52
56
  components[cv_label]['version'] = cv.component_version.try(:version)
@@ -55,8 +59,8 @@ module Katello
55
59
  components
56
60
  end
57
61
 
58
- def content_version
59
- host.content_view.try(:version, host.lifecycle_environment)
62
+ def content_version(content_view_environment)
63
+ content_view_environment.content_view.try(:version, content_view_environment.lifecycle_environment)
60
64
  end
61
65
  end
62
66
  end
@@ -114,9 +114,10 @@ module Katello
114
114
  if self.hypervisor
115
115
  if !consumer_params.try(:[], 'guestIds').empty?
116
116
  guest_ids = consumer_params['guestIds'].map do |id|
117
- if id.is_a?(Hash)
117
+ case id
118
+ when Hash
118
119
  id['guestId'].downcase
119
- elsif id.is_a?(String)
120
+ when String
120
121
  id.downcase
121
122
  end
122
123
  end
@@ -144,7 +145,7 @@ module Katello
144
145
  :addOns => purpose_addons.pluck(:name),
145
146
  :serviceLevel => service_level,
146
147
  :releaseVer => release_version,
147
- :environment => {:id => self.candlepin_environment_id},
148
+ :environments => self.candlepin_environments,
148
149
  :installedProducts => self.installed_products.map(&:consumer_attributes),
149
150
  :guestIds => virtual_guest_uuids
150
151
  }
@@ -152,20 +153,18 @@ module Katello
152
153
  HashWithIndifferentAccess.new(attrs)
153
154
  end
154
155
 
155
- def candlepin_environment_id
156
+ def candlepin_environments
156
157
  if self.host.content_facet
157
- self.host.content_facet.content_view.cp_environment_id(self.host.content_facet.lifecycle_environment)
158
+ self.host.content_facet.content_view_environments.map do |cve|
159
+ { :id => cve.content_view.cp_environment_id(cve.lifecycle_environment) }
160
+ end
158
161
  else
159
162
  self.host.organization.default_content_view.cp_environment_id(self.host.organization.library)
160
163
  end
161
164
  end
162
165
 
163
- def content_view
164
- self.host.content_facet.try(:content_view) || self.organization.default_content_view
165
- end
166
-
167
- def lifecycle_environment
168
- self.host.content_facet.try(:lifecycle_environment) || self.organization.library
166
+ def content_view_environments
167
+ self.host.content_facet.try(:content_view_environments)
169
168
  end
170
169
 
171
170
  def organization
@@ -294,10 +293,15 @@ module Katello
294
293
 
295
294
  def backend_update_needed?
296
295
  %w(release_version service_level autoheal purpose_role purpose_usage purpose_addon_ids).each do |method|
297
- return true if self.send("#{method}_changed?")
296
+ if self.send("#{method}_changed?")
297
+ Rails.logger.debug("backend_update_needed: subscription facet #{method} changed")
298
+ return true
299
+ end
298
300
  end
299
- if self.host.content_facet
300
- return true if (self.host.content_facet.content_view_id_changed? || self.host.content_facet.lifecycle_environment_id_changed?)
301
+ facet = self.host&.content_facet
302
+ if facet&.cves_changed? && !facet.new_record?
303
+ Rails.logger.debug("backend_update_needed: content facet CVEs changed")
304
+ return true
301
305
  end
302
306
  false
303
307
  end
@@ -18,17 +18,22 @@ module Katello
18
18
  has_many :successors, :class_name => "Katello::KTEnvironment", :through => :env_successors, :source => :env
19
19
 
20
20
  has_many :repositories, :class_name => "Katello::Repository", dependent: :destroy, foreign_key: :environment_id
21
+ has_many :content_view_histories, :class_name => "Katello::ContentViewHistory", :dependent => :destroy,
22
+ :inverse_of => :environment, :foreign_key => :katello_environment_id
23
+
21
24
  has_many :content_view_environments, :class_name => "Katello::ContentViewEnvironment",
22
- :foreign_key => :environment_id, :inverse_of => :environment, :dependent => :restrict_with_exception
25
+ :foreign_key => :environment_id, :inverse_of => :environment, :dependent => :destroy
26
+ has_many :content_view_environment_content_facets, :through => :content_view_environments,
27
+ :class_name => "Katello::ContentViewEnvironmentContentFacet",
28
+ :inverse_of => :lifecycle_environment
29
+ has_many :content_facets, :through => :content_view_environment_content_facets,
30
+ :class_name => "Katello::Host::ContentFacet",
31
+ :inverse_of => :lifecycle_environments
32
+ has_many :content_views, :through => :content_view_environments
23
33
  has_many :content_view_versions, :through => :content_view_environments, :inverse_of => :environments
24
- has_many :content_views, :through => :content_view_environments, :inverse_of => :environments
25
- has_many :content_view_histories, :class_name => "Katello::ContentViewHistory", :dependent => :destroy,
26
- :inverse_of => :environment, :foreign_key => :katello_environment_id
27
34
 
28
- has_many :content_facets, :class_name => "Katello::Host::ContentFacet", :foreign_key => :lifecycle_environment_id,
29
- :inverse_of => :lifecycle_environment, :dependent => :restrict_with_exception
30
35
  has_many :hosts, :class_name => "::Host::Managed", :through => :content_facets,
31
- :inverse_of => :lifecycle_environment
36
+ :inverse_of => :lifecycle_environments
32
37
  has_many :hostgroup_content_facets, :class_name => "Katello::Hostgroup::ContentFacet", :foreign_key => :lifecycle_environment_id,
33
38
  :inverse_of => :lifecycle_environment, :dependent => :restrict_with_exception
34
39
  has_many :hostgroups, :class_name => "::Hostgroup", :through => :hostgroup_content_facets,
@@ -12,18 +12,6 @@ module Katello
12
12
  self.repositories.first
13
13
  end
14
14
 
15
- def self.list_by_filter_clauses(clauses)
16
- package_names = []
17
- pulp_package_groups = Katello.pulp_server.extensions.package_group.search(Katello::PackageGroup::CONTENT_TYPE, :filters => clauses)
18
- groupings = [:default_package_names, :conditional_package_names, :optional_package_names, :mandatory_package_names]
19
- if pulp_package_groups.any?
20
- pulp_package_groups.flat_map { |group| groupings.each { |grouping| package_names << group[grouping] } }
21
- package_names.flatten!
22
- else
23
- []
24
- end
25
- end
26
-
27
15
  def package_names
28
16
  service_class = SmartProxy.pulp_primary!.content_service(CONTENT_TYPE)
29
17
  group = service_class.new(self.pulp_id)
@@ -56,7 +56,10 @@ module Katello
56
56
  validate :subscription_matches_organization
57
57
 
58
58
  def subscription_matches_organization
59
- errors.add(:base, _("A Pool and its Subscription cannot belong to different organizations")) unless subscription&.organization_id == self.organization_id
59
+ return if errors[:subscription].any? || errors[:organization].any? # let other validations catch this
60
+ unless subscription&.organization_id == self.organization_id
61
+ errors.add(:base, _("A Pool and its Subscription cannot belong to different organizations."))
62
+ end
60
63
  end
61
64
 
62
65
  DAYS_RECENTLY_EXPIRED = 30