katello 3.9.1 → 3.10.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 (229) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/katello/hosts/host_and_hostgroup_edit.js +28 -12
  3. data/app/controllers/katello/api/rhsm/candlepin_dynflow_proxy_controller.rb +12 -3
  4. data/app/controllers/katello/api/rhsm/candlepin_proxies_controller.rb +4 -13
  5. data/app/controllers/katello/api/v2/content_credentials_controller.rb +1 -1
  6. data/app/controllers/katello/api/v2/content_view_filter_rules_controller.rb +1 -1
  7. data/app/controllers/katello/api/v2/content_view_versions_controller.rb +6 -4
  8. data/app/controllers/katello/api/v2/content_views_controller.rb +8 -3
  9. data/app/controllers/katello/api/v2/gpg_keys_controller.rb +2 -1
  10. data/app/controllers/katello/api/v2/host_module_streams_controller.rb +39 -0
  11. data/app/controllers/katello/api/v2/hosts_bulk_actions_controller.rb +20 -11
  12. data/app/controllers/katello/api/v2/module_streams_controller.rb +2 -1
  13. data/app/controllers/katello/api/v2/repository_sets_controller.rb +17 -8
  14. data/app/controllers/katello/application_controller.rb +0 -2
  15. data/app/controllers/katello/concerns/hosts_controller_extensions.rb +5 -2
  16. data/app/lib/actions/candlepin/consumer/attach_subscription.rb +0 -2
  17. data/app/lib/actions/candlepin/consumer/remove_subscription.rb +0 -2
  18. data/app/lib/actions/katello/capsule_content/create_repos.rb +1 -25
  19. data/app/lib/actions/katello/capsule_content/sync.rb +1 -1
  20. data/app/lib/actions/katello/content_view/promote.rb +2 -5
  21. data/app/lib/actions/katello/content_view/promote_to_environment.rb +2 -5
  22. data/app/lib/actions/katello/content_view/publish.rb +1 -4
  23. data/app/lib/actions/katello/content_view_puppet_environment/create.rb +6 -10
  24. data/app/lib/actions/katello/content_view_version/export.rb +0 -2
  25. data/app/lib/actions/katello/content_view_version/incremental_update.rb +19 -1
  26. data/app/lib/actions/katello/environment/publish_repositories.rb +2 -1
  27. data/app/lib/actions/katello/gpg_key/update.rb +17 -0
  28. data/app/lib/actions/katello/host/attach_subscriptions.rb +0 -2
  29. data/app/lib/actions/katello/host/erratum/install.rb +6 -0
  30. data/app/lib/actions/katello/host/generate_applicability.rb +0 -2
  31. data/app/lib/actions/katello/host/hypervisors_update.rb +11 -6
  32. data/app/lib/actions/katello/host/package/install.rb +6 -0
  33. data/app/lib/actions/katello/host/package/remove.rb +6 -0
  34. data/app/lib/actions/katello/host/package/update.rb +7 -1
  35. data/app/lib/actions/katello/host/package_group/install.rb +6 -0
  36. data/app/lib/actions/katello/host/package_group/remove.rb +6 -0
  37. data/app/lib/actions/katello/host/recalculate_errata_status.rb +0 -2
  38. data/app/lib/actions/katello/host/remove_subscriptions.rb +0 -2
  39. data/app/lib/actions/katello/host/update.rb +1 -0
  40. data/app/lib/actions/katello/host/update_content_overrides.rb +0 -2
  41. data/app/lib/actions/katello/host/upload_package_profile.rb +13 -12
  42. data/app/lib/actions/katello/host/upload_profiles.rb +70 -0
  43. data/app/lib/actions/katello/product/reindex_subscriptions.rb +0 -2
  44. data/app/lib/actions/katello/product/repositories_certs_reset.rb +4 -4
  45. data/app/lib/actions/katello/product/repositories_gpg_reset.rb +2 -2
  46. data/app/lib/actions/katello/repository/check_matching_content.rb +18 -6
  47. data/app/lib/actions/katello/repository/clone_deb_content.rb +1 -1
  48. data/app/lib/actions/katello/repository/clone_to_environment.rb +3 -5
  49. data/app/lib/actions/katello/repository/clone_to_version.rb +2 -3
  50. data/app/lib/actions/katello/repository/clone_yum_content.rb +1 -2
  51. data/app/lib/actions/katello/repository/clone_yum_metadata.rb +2 -2
  52. data/app/lib/actions/katello/repository/create.rb +1 -31
  53. data/app/lib/actions/katello/repository/destroy.rb +1 -2
  54. data/app/lib/actions/katello/repository/export.rb +0 -2
  55. data/app/lib/actions/katello/repository/fetch_pxe_files.rb +0 -2
  56. data/app/lib/actions/katello/repository/filtered_index_content.rb +0 -2
  57. data/app/lib/actions/katello/repository/finish_upload.rb +0 -2
  58. data/app/lib/actions/katello/repository/import_upload.rb +0 -2
  59. data/app/lib/actions/katello/repository/index_content.rb +0 -1
  60. data/app/lib/actions/katello/repository/index_package_groups.rb +0 -2
  61. data/app/lib/actions/katello/repository/instance_update.rb +21 -0
  62. data/app/lib/actions/katello/repository/remove_content.rb +0 -2
  63. data/app/lib/actions/katello/repository/sync.rb +0 -1
  64. data/app/lib/actions/katello/repository/update.rb +0 -2
  65. data/app/lib/actions/katello/upstream_subscriptions/bind_entitlement.rb +0 -2
  66. data/app/lib/actions/katello/upstream_subscriptions/bind_entitlements.rb +0 -2
  67. data/app/lib/actions/katello/upstream_subscriptions/remove_entitlement.rb +0 -1
  68. data/app/lib/actions/katello/upstream_subscriptions/remove_entitlements.rb +0 -2
  69. data/app/lib/actions/katello/upstream_subscriptions/update_entitlement.rb +0 -1
  70. data/app/lib/actions/katello/upstream_subscriptions/update_entitlements.rb +0 -2
  71. data/app/lib/actions/pulp/abstract.rb +13 -14
  72. data/app/lib/actions/pulp/repository/create.rb +13 -211
  73. data/app/lib/actions/pulp/repository/create_in_plan.rb +4 -18
  74. data/app/lib/actions/pulp/repository/refresh.rb +7 -70
  75. data/app/lib/actions/pulp/repository/sync.rb +1 -2
  76. data/app/lib/katello/capsule_content.rb +3 -3
  77. data/app/lib/katello/resources/candlepin/consumer.rb +1 -1
  78. data/app/lib/katello/resources/candlepin/product.rb +1 -1
  79. data/app/lib/katello/validators/hostgroup_kickstart_repository_validator.rb +1 -1
  80. data/app/models/katello/available_module_stream.rb +11 -0
  81. data/app/models/katello/concerns/content_facet_host_extensions.rb +1 -0
  82. data/app/models/katello/concerns/host_managed_extensions.rb +56 -0
  83. data/app/models/katello/concerns/hostgroup_extensions.rb +17 -0
  84. data/app/models/katello/concerns/redhat_extensions.rb +20 -6
  85. data/app/models/katello/concerns/search_by_repository_name.rb +0 -1
  86. data/app/models/katello/concerns/smart_proxy_extensions.rb +26 -12
  87. data/app/models/katello/content_facet_applicable_module_stream.rb +7 -0
  88. data/app/models/katello/content_view_puppet_environment.rb +14 -35
  89. data/app/models/katello/erratum.rb +54 -24
  90. data/app/models/katello/erratum_package.rb +6 -0
  91. data/app/models/katello/glue/pulp/repo.rb +5 -228
  92. data/app/models/katello/gpg_key.rb +1 -0
  93. data/app/models/katello/host/content_facet.rb +38 -83
  94. data/app/models/katello/host_available_module_stream.rb +47 -0
  95. data/app/models/katello/module_stream.rb +18 -0
  96. data/app/models/katello/module_stream_erratum_package.rb +6 -0
  97. data/app/models/katello/product.rb +0 -2
  98. data/app/models/katello/product_content.rb +1 -0
  99. data/app/models/katello/repository.rb +15 -6
  100. data/app/models/katello/root_repository.rb +1 -1
  101. data/app/models/katello/rpm.rb +5 -17
  102. data/app/services/katello/applicable_content_helper.rb +111 -0
  103. data/app/services/katello/managed_content_medium_provider.rb +7 -0
  104. data/app/services/katello/pulp/consumer.rb +13 -7
  105. data/app/services/katello/pulp/repository.rb +157 -4
  106. data/app/services/katello/pulp/repository/deb.rb +47 -0
  107. data/app/services/katello/pulp/repository/docker.rb +43 -0
  108. data/app/services/katello/pulp/repository/file.rb +31 -0
  109. data/app/services/katello/pulp/repository/ostree.rb +40 -0
  110. data/app/services/katello/pulp/repository/puppet.rb +43 -0
  111. data/app/services/katello/pulp/repository/yum.rb +61 -0
  112. data/app/services/katello/repository_type.rb +1 -1
  113. data/app/views/katello/api/v2/content_facet/base.json.rabl +1 -0
  114. data/app/views/katello/api/v2/content_view_versions/base.json.rabl +0 -1
  115. data/app/views/katello/api/v2/errata/_counts.json.rabl +0 -1
  116. data/app/views/katello/api/v2/errata/show.json.rabl +9 -3
  117. data/app/views/katello/api/v2/host_collections/delta_activation_keys.rabl +0 -1
  118. data/app/views/katello/api/v2/host_module_streams/base.json.rabl +8 -0
  119. data/app/views/katello/api/v2/host_module_streams/index.json.rabl +7 -0
  120. data/app/views/katello/api/v2/packages/backend.json.rabl +0 -1
  121. data/app/views/katello/api/v2/repositories/show.json.rabl +6 -6
  122. data/app/views/katello/layouts/react.html.erb +2 -2
  123. data/app/views/overrides/activation_keys/_host_synced_content_select.html.erb +0 -1
  124. data/config/routes/api/rhsm.rb +1 -0
  125. data/config/routes/overrides.rb +4 -0
  126. data/db/migrate/20181008201422_add_modules_to_errata_packages.rb +29 -0
  127. data/db/migrate/20181017181806_available_module_streams.rb +34 -0
  128. data/db/migrate/20181027014323_add_applicable_modules.rb +24 -0
  129. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/common/module-stream-actions.service.js +2 -1
  130. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/details/views/content-credential-info.html +1 -1
  131. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-credentials/new/views/new-content-credential.html +1 -0
  132. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/bulk/views/content-host-bulk-module-streams-modal.html +2 -2
  133. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/bulk/views/content-hosts-bulk-errata-modal.html +37 -22
  134. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content-hosts.controller.js +4 -1
  135. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content/content-host-module-streams.controller.js +27 -7
  136. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content/views/content-host-module-streams.html +29 -0
  137. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content/views/errata-details.html +15 -1
  138. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/views/content-hosts.html +1 -1
  139. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/content-view-promotion.controller.js +0 -1
  140. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/content-view-publish.controller.js +1 -2
  141. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/content-view-versions.controller.js +3 -1
  142. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/histories/content-view-history.controller.js +1 -1
  143. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/views/content-view-promotion.html +0 -15
  144. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/views/content-view-publish.html +0 -14
  145. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/errata/details/erratum.controller.js +19 -0
  146. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/errata/details/views/erratum-info.html +0 -12
  147. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/errata/details/views/erratum-packages.html +36 -0
  148. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/errata/details/views/erratum.html +7 -0
  149. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/errata/errata.routes.js +9 -0
  150. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/hosts/host-module-streams.factory.js +18 -0
  151. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-info.html +4 -2
  152. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/new/views/new-repository.html +2 -2
  153. data/engines/bastion_katello/app/assets/stylesheets/bastion_katello/bastion_katello.scss +13 -0
  154. data/lib/katello/permissions/host_permissions.rb +3 -0
  155. data/lib/katello/repository_types/deb.rb +3 -1
  156. data/lib/katello/repository_types/docker.rb +3 -1
  157. data/lib/katello/repository_types/file.rb +1 -0
  158. data/lib/katello/repository_types/ostree.rb +3 -1
  159. data/lib/katello/repository_types/puppet.rb +3 -1
  160. data/lib/katello/repository_types/yum.rb +3 -1
  161. data/lib/katello/tasks/delete_orphaned_content.rake +1 -1
  162. data/lib/katello/tasks/reset.rake +1 -0
  163. data/lib/katello/tasks/test.rake +14 -0
  164. data/lib/katello/tasks/unify_hosts.rake +2 -0
  165. data/lib/katello/tasks/virt_who_report.rake +2 -1
  166. data/lib/katello/version.rb +1 -1
  167. data/locale/Makefile +52 -17
  168. data/locale/update-i18n +22 -0
  169. data/package.json +11 -1
  170. data/webpack/__mocks__/foremanReact/components/common/EmptyState.js +8 -0
  171. data/webpack/move_to_foreman/components/common/table/components/Table.js +2 -1
  172. data/webpack/move_to_pf/react-bootstrap-select/index.js +4 -2
  173. data/webpack/move_to_pf/test-utils/testHelpers.js +9 -0
  174. data/webpack/redux/OrganizationProducts/OrganizationProductsActions.js +24 -0
  175. data/webpack/redux/OrganizationProducts/OrganizationProductsConstants.js +5 -0
  176. data/webpack/redux/OrganizationProducts/OrganizationProductsReducer.js +38 -0
  177. data/webpack/redux/OrganizationProducts/OrganizationProductsSelectors.js +7 -0
  178. data/webpack/redux/OrganizationProducts/__tests__/OrganizationProductsActions.test.js +47 -0
  179. data/webpack/redux/OrganizationProducts/__tests__/OrganizationProductsReducer.test.js +33 -0
  180. data/webpack/redux/OrganizationProducts/__tests__/OrganizationProductsSelectors.test.js +19 -0
  181. data/webpack/redux/OrganizationProducts/__tests__/__snapshots__/OrganizationProductsActions.test.js.snap +49 -0
  182. data/webpack/redux/OrganizationProducts/__tests__/__snapshots__/OrganizationProductsReducer.test.js.snap +36 -0
  183. data/webpack/redux/OrganizationProducts/__tests__/__snapshots__/OrganizationProductsSelectors.test.js.snap +9 -0
  184. data/webpack/redux/OrganizationProducts/index.js +13 -0
  185. data/webpack/redux/actions/RedHatRepositories/enabled.js +7 -1
  186. data/webpack/redux/actions/RedHatRepositories/helpers.js +4 -0
  187. data/webpack/redux/actions/RedHatRepositories/sets.js +2 -0
  188. data/webpack/redux/reducers/RedHatRepositories/enabled.fixtures.js +8 -2
  189. data/webpack/redux/reducers/RedHatRepositories/enabled.js +1 -1
  190. data/webpack/redux/reducers/RedHatRepositories/sets.fixtures.js +12 -3
  191. data/webpack/redux/reducers/index.js +2 -0
  192. data/webpack/scenes/RedHatRepositories/components/SearchBar.js +68 -33
  193. data/webpack/scenes/RedHatRepositories/index.js +13 -2
  194. data/webpack/scenes/RedHatRepositories/index.scss +26 -0
  195. data/webpack/scenes/Subscriptions/Manifest/ManageManifestModal.js +1 -1
  196. data/webpack/scenes/Subscriptions/Manifest/__tests__/__snapshots__/ManageManifestModal.test.js.snap +1 -1
  197. data/webpack/scenes/Subscriptions/SubscriptionActions.js +18 -2
  198. data/webpack/scenes/Subscriptions/SubscriptionConstants.js +8 -0
  199. data/webpack/scenes/Subscriptions/SubscriptionHelpers.js +15 -0
  200. data/webpack/scenes/Subscriptions/SubscriptionReducer.js +22 -14
  201. data/webpack/scenes/Subscriptions/SubscriptionsPage.js +39 -90
  202. data/webpack/scenes/Subscriptions/SubscriptionsSelectors.js +14 -0
  203. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsPage.js +1 -3
  204. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/__snapshots__/UpstreamSubscriptionsPage.test.js.snap +0 -1
  205. data/webpack/scenes/Subscriptions/__tests__/SubscriptionHelpers.test.js +84 -0
  206. data/webpack/scenes/Subscriptions/__tests__/SubscriptionsActions.test.js +26 -1
  207. data/webpack/scenes/Subscriptions/__tests__/SubscriptionsPage.test.js +5 -0
  208. data/webpack/scenes/Subscriptions/__tests__/SubscriptionsReducer.test.js +177 -75
  209. data/webpack/scenes/Subscriptions/__tests__/SubscriptionsSelectors.test.js +29 -0
  210. data/webpack/scenes/Subscriptions/__tests__/__snapshots__/SubscriptionHelpers.test.js.snap +31 -0
  211. data/webpack/scenes/Subscriptions/__tests__/__snapshots__/SubscriptionsActions.test.js.snap +32 -0
  212. data/webpack/scenes/Subscriptions/__tests__/__snapshots__/SubscriptionsPage.test.js.snap +18 -96
  213. data/webpack/scenes/Subscriptions/__tests__/__snapshots__/SubscriptionsReducer.test.js.snap +511 -0
  214. data/webpack/scenes/Subscriptions/__tests__/__snapshots__/SubscriptionsSelectors.test.js.snap +26 -0
  215. data/webpack/scenes/Subscriptions/__tests__/subscriptions.fixtures.js +6 -1
  216. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/__tests__/__snapshots__/SubscriptionsTable.test.js.snap +3 -21
  217. data/webpack/scenes/Subscriptions/components/SubscriptionsToolbar/SubscriptionsToolbar.js +113 -0
  218. data/webpack/scenes/Subscriptions/components/SubscriptionsToolbar/SubscriptionsToolbar.test.js +47 -0
  219. data/webpack/scenes/Subscriptions/components/SubscriptionsToolbar/__snapshots__/SubscriptionsToolbar.test.js.snap +504 -0
  220. data/webpack/scenes/Subscriptions/components/SubscriptionsToolbar/index.js +1 -0
  221. data/webpack/scenes/Subscriptions/index.js +15 -4
  222. metadata +59 -14
  223. data/app/lib/actions/pulp/repository/associate_distributor.rb +0 -20
  224. data/app/lib/actions/pulp/repository/associate_importer.rb +0 -23
  225. data/app/lib/actions/pulp/repository/delete_distributor.rb +0 -18
  226. data/app/lib/actions/pulp/repository/refresh_distributor.rb +0 -19
  227. data/app/lib/actions/pulp/repository/update_importer.rb +0 -33
  228. data/app/lib/katello/bulk_actions.rb +0 -63
  229. data/webpack/move_to_foreman/components/common/EmptyState/index.js +0 -68
@@ -4,80 +4,17 @@ module Actions
4
4
  class Refresh < Pulp::Abstract
5
5
  input_format do
6
6
  param :capsule_id
7
+ param :pulp_id
7
8
  end
8
9
 
9
- def plan(repository, input = {})
10
- input[:capsule_id] ||= SmartProxy.default_capsule!.id
11
- repository_details = pulp_extensions(input[:capsule_id]).repository.retrieve_with_details(repository.pulp_id)
12
- update_or_associate_importer(input[:capsule_id], repository, repository_details)
13
- update_or_associate_distributors(input[:capsule_id], repository, repository_details)
14
- remove_unnecessary_distributors(input[:capsule_id], repository, repository_details)
10
+ def plan(repository, options = {})
11
+ options[:capsule_id] ||= SmartProxy.default_capsule!.id
12
+ plan_self(:capsule_id => options[:capsule_id], :pulp_id => repository.pulp_id)
15
13
  end
16
14
 
17
- def update_or_associate_importer(capsule_id, repository, repository_details)
18
- existing_importers = repository_details["importers"]
19
- importer = repository.generate_importer(::SmartProxy.find_by(:id => capsule_id))
20
- found = existing_importers.find { |i| i['importer_type_id'] == importer.id }
21
-
22
- if found
23
- plan_action(::Actions::Pulp::Repository::UpdateImporter,
24
- :repo_id => repository.pulp_id,
25
- :id => found['id'],
26
- :config => importer.config,
27
- :capsule_id => capsule_id
28
- )
29
- else
30
- plan_action(::Actions::Pulp::Repository::AssociateImporter,
31
- :repo_id => repository.pulp_id,
32
- :type_id => repository.importers.first['importer_type_id'],
33
- :config => importer.config,
34
- :capsule_id => capsule_id,
35
- :hash => { :importer_id => importer.id }
36
- )
37
- end
38
- end
39
-
40
- def update_or_associate_distributors(capsule_id, repository, repository_details)
41
- concurrence do
42
- existing_distributors = repository_details["distributors"]
43
- capsule = capsule_id ? SmartProxy.find(capsule_id) : nil
44
- repository.generate_distributors(capsule).each do |distributor|
45
- found = existing_distributors.find { |i| i['distributor_type_id'] == distributor.type_id }
46
- if found
47
- plan_action(::Actions::Pulp::Repository::RefreshDistributor,
48
- :repo_id => repository.pulp_id,
49
- :id => found['id'],
50
- :config => distributor.config,
51
- :capsule_id => capsule_id
52
- )
53
- else
54
- plan_action(::Actions::Pulp::Repository::AssociateDistributor,
55
- :repo_id => repository.pulp_id,
56
- :type_id => distributor.type_id,
57
- :config => distributor.config,
58
- :capsule_id => capsule_id,
59
- :hash => { :distributor_id => distributor.id }
60
- )
61
- end
62
- end
63
- end
64
- end
65
-
66
- def remove_unnecessary_distributors(capsule_id, repository, repository_details)
67
- concurrence do
68
- existing_distributors = repository_details["distributors"]
69
- capsule = capsule_id ? SmartProxy.find(capsule_id) : nil
70
- generated_distributors = repository.generate_distributors(capsule)
71
- existing_distributors.each do |distributor|
72
- found = generated_distributors.find { |dist| dist.type_id == distributor['distributor_type_id'] }
73
- unless found
74
- plan_action(Pulp::Repository::DeleteDistributor, :repo_id => repository.pulp_id,
75
- :distributor_id => distributor['id'],
76
- :capsule_id => capsule_id
77
- )
78
- end
79
- end
80
- end
15
+ def run
16
+ repo = ::Katello::Repository.find_by(:pulp_id => input[:pulp_id])
17
+ output[:results] = repo.backend_service(smart_proxy(input[:capsule_id])).refresh
81
18
  end
82
19
  end
83
20
  end
@@ -21,8 +21,7 @@ module Actions
21
21
  overrides[:validate] = !(SETTINGS[:katello][:pulp][:skip_checksum_validation])
22
22
  overrides[:options] = input[:options] if input[:options]
23
23
  repo = ::Katello::Repository.find_by(:pulp_id => input[:pulp_id])
24
- output[:pulp_tasks] = pulp_tasks = ::Katello::Pulp::Repository.new(repo, smart_proxy(input[:capsule_id])).sync(overrides)
25
- pulp_tasks
24
+ output[:pulp_tasks] = repo.backend_service(::SmartProxy.pulp_master).sync(overrides)
26
25
  end
27
26
  end
28
27
 
@@ -92,7 +92,7 @@ module Katello
92
92
  end
93
93
 
94
94
  def default_capsule?
95
- @capsule.default_capsule?
95
+ @capsule.pulp_master?
96
96
  end
97
97
 
98
98
  def orphaned_repos
@@ -132,7 +132,7 @@ module Katello
132
132
  end
133
133
 
134
134
  def pulp_url
135
- "https://" + self.capsule.hostname + "/pulp/api/v2/"
135
+ self.capsule.pulp_url
136
136
  end
137
137
 
138
138
  def pulp_repo_facts(pulp_id)
@@ -164,7 +164,7 @@ module Katello
164
164
  end
165
165
 
166
166
  def self.default_capsule
167
- proxy = SmartProxy.with_features(SmartProxy::PULP_FEATURE).first
167
+ proxy = SmartProxy.pulp_master
168
168
  self.new(proxy) if proxy
169
169
  end
170
170
 
@@ -22,7 +22,7 @@ module Katello
22
22
  includes = params.key?(:include_only) ? "&" + included_list(params.delete(:include_only)) : ""
23
23
  fetch_paged do |page_add|
24
24
  response = super(path + hash_to_query(params) + includes + "&#{page_add}", self.default_headers).body
25
- JSON.parse(response)
25
+ JSON.parse(response).map(&:with_indifferent_access)
26
26
  end
27
27
  end
28
28
  end
@@ -9,7 +9,7 @@ module Katello
9
9
  end
10
10
 
11
11
  def find_for_stacking_id(owner_key, stacking_id)
12
- Subscription.get_for_owner(owner_key).each do |subscription|
12
+ Resources::Candlepin::Subscription.get_for_owner(owner_key).each do |subscription|
13
13
  if subscription['product']['attributes'].any? { |attr| attr['name'] == 'stacking_id' && attr['value'] == stacking_id }
14
14
  return subscription['product']
15
15
  end
@@ -18,7 +18,7 @@ module Katello
18
18
  _("Kickstart repositories can only be assigned to hosts in the Red Hat family")
19
19
  elsif hostgroup.architecture.blank?
20
20
  _("Please select an architecture before assigning a kickstart repository")
21
- elsif hostgroup.operatingsystem.kickstart_repos(hostgroup).none? { |repo| repo[:id] == hostgroup.kickstart_repository_id }
21
+ elsif !hostgroup.matching_kickstart_repository?
22
22
  _("The selected kickstart repository is not part of the assigned content view, lifecycle environment,
23
23
  content source, operating system, and architecture")
24
24
  end
@@ -0,0 +1,11 @@
1
+ module Katello
2
+ class AvailableModuleStream < Katello::Model
3
+ has_many :hosts, :through => :host_available_module_streams, :class_name => "::Host"
4
+ has_many :host_available_module_streams, :class_name => "Katello::HostAvailableModuleStream", :dependent => :destroy, :inverse_of => :available_module_stream
5
+ serialize :profiles
6
+
7
+ def module_spec
8
+ "#{name}:#{stream}"
9
+ end
10
+ end
11
+ end
@@ -30,6 +30,7 @@ module Katello
30
30
  has_one :content_source, :through => :content_facet
31
31
  has_many :applicable_errata, :through => :content_facet
32
32
  has_many :applicable_rpms, :through => :content_facet
33
+ has_many :applicable_module_streams, :through => :content_facet
33
34
 
34
35
  scoped_search :relation => :content_view, :on => :name, :complete_value => true, :rename => :content_view
35
36
  scoped_search :relation => :content_facet, :on => :content_view_id, :rename => :content_view_id, :only_explicit => true, :validator => ScopedSearch::Validators::INTEGER
@@ -35,6 +35,10 @@ module Katello
35
35
 
36
36
  has_many :host_installed_packages, :class_name => "::Katello::HostInstalledPackage", :foreign_key => :host_id, :dependent => :delete_all
37
37
  has_many :installed_packages, :class_name => "::Katello::InstalledPackage", :through => :host_installed_packages
38
+
39
+ has_many :host_available_module_streams, :class_name => "::Katello::HostAvailableModuleStream", :foreign_key => :host_id, :dependent => :delete_all
40
+ has_many :available_module_streams, :class_name => "::Katello::AvailableModuleStream", :through => :host_available_module_streams
41
+
38
42
  has_many :host_traces, :class_name => "::Katello::HostTracer", :foreign_key => :host_id, :dependent => :destroy
39
43
 
40
44
  has_many :host_collection_hosts, :class_name => "::Katello::HostCollectionHosts", :foreign_key => :host_id, :dependent => :destroy
@@ -49,6 +53,8 @@ module Katello
49
53
  scoped_search :relation => :host_collections, :on => :name, :complete_value => true, :rename => :host_collection
50
54
  scoped_search :relation => :installed_packages, :on => :nvra, :complete_value => true, :rename => :installed_package, :only_explicit => true
51
55
  scoped_search :relation => :installed_packages, :on => :name, :complete_value => true, :rename => :installed_package_name, :only_explicit => true
56
+ scoped_search :relation => :available_module_streams, :on => :name, :complete_value => true, :rename => :available_module_stream_name, :only_explicit => true
57
+ scoped_search :relation => :available_module_streams, :on => :stream, :complete_value => true, :rename => :available_module_stream_stream, :only_explicit => true
52
58
  scoped_search :relation => :host_traces, :on => :application, :complete_value => true, :rename => :trace_app, :only_explicit => true
53
59
  scoped_search :relation => :host_traces, :on => :app_type, :complete_value => true, :rename => :trace_app_type, :only_explicit => true
54
60
  scoped_search :relation => :host_traces, :on => :helper, :complete_value => true, :rename => :trace_helper, :only_explicit => true
@@ -110,6 +116,56 @@ module Katello
110
116
  found
111
117
  end
112
118
 
119
+ def import_enabled_repositories(repos)
120
+ paths = repos.map do |repo|
121
+ if !repo['baseurl'].blank?
122
+ URI(repo['baseurl'].first).path
123
+ else
124
+ logger.warn("System #{name} (#{id}) attempted to bind to unspecific repo (#{repo}).")
125
+ nil
126
+ end
127
+ end
128
+ content_facet.update_repositories_by_paths(paths.compact)
129
+ end
130
+
131
+ def import_module_streams(module_streams)
132
+ streams = {}
133
+ module_streams.each do |module_stream|
134
+ stream = AvailableModuleStream.where(name: module_stream["name"],
135
+ stream: module_stream["stream"]).first_or_create!
136
+ streams[stream.id] = module_stream
137
+ end
138
+ sync_available_module_stream_associations(streams)
139
+ end
140
+
141
+ def sync_available_module_stream_associations(new_available_module_streams)
142
+ upgradable_streams = self.host_available_module_streams.where(:available_module_stream_id => new_available_module_streams.keys)
143
+ old_associated_ids = self.available_module_stream_ids
144
+ delete_ids = old_associated_ids - new_available_module_streams.keys
145
+
146
+ if delete_ids.any?
147
+ self.host_available_module_streams.where(:available_module_stream_id => delete_ids).delete_all
148
+ end
149
+
150
+ new_ids = new_available_module_streams.keys - old_associated_ids
151
+ new_ids.each do |new_id|
152
+ module_stream = new_available_module_streams[new_id]
153
+ self.host_available_module_streams.create!(host_id: self.id,
154
+ available_module_stream_id: new_id,
155
+ installed_profiles: module_stream["installed_profiles"],
156
+ status: module_stream["status"])
157
+ end
158
+
159
+ upgradable_streams.each do |hams|
160
+ module_stream = new_available_module_streams[hams.available_module_stream_id]
161
+ shared_keys = hams.attributes.keys & module_stream.keys
162
+ module_stream_data = module_stream.slice(*shared_keys)
163
+ if hams.attributes.slice(*shared_keys) != module_stream_data
164
+ hams.update_attributes!(module_stream_data)
165
+ end
166
+ end
167
+ end
168
+
113
169
  def sync_package_associations(new_installed_package_ids)
114
170
  old_associated_ids = self.installed_package_ids
115
171
  table_name = self.host_installed_packages.table_name
@@ -30,6 +30,12 @@ module Katello
30
30
  elsif kickstart_repository && medium
31
31
  self.medium = nil
32
32
  end
33
+
34
+ unless matching_kickstart_repository?
35
+ if (equivalent = equivalent_kickstart_repository)
36
+ self.kickstart_repository_id = equivalent[:id]
37
+ end
38
+ end
33
39
  end
34
40
 
35
41
  def content_view
@@ -81,6 +87,17 @@ module Katello
81
87
  self.lifecycle_environment == self.environment.try(:lifecycle_environment)
82
88
  end
83
89
 
90
+ def equivalent_kickstart_repository
91
+ return unless operatingsystem && kickstart_repository
92
+ ks_repos = operatingsystem.kickstart_repos(self)
93
+ ks_repos.find { |repo| repo[:name] == kickstart_repository.label }
94
+ end
95
+
96
+ def matching_kickstart_repository?
97
+ return true unless operatingsystem
98
+ operatingsystem.kickstart_repos(self).any? { |repo| repo[:id] == kickstart_repository_id }
99
+ end
100
+
84
101
  private
85
102
 
86
103
  def inherited_ancestry_attribute(attribute)
@@ -41,16 +41,31 @@ module Katello
41
41
  end
42
42
 
43
43
  def kickstart_repos(host)
44
- distros = distribution_repositories(host)
44
+ distribution_repos = distribution_repositories(host)
45
+
46
+ return [] if distribution_repos.empty?
47
+
48
+ distros = distribution_repos.where(distribution_bootable: true)
45
49
  if distros && host.content_source
46
- distros.map do |distro|
47
- {:id => distro.id, :name => distro.name, :path => distro.full_path(host.content_source)}
48
- end
50
+ distros.map { |distro| distro.to_hash(host.content_source) }
49
51
  else
50
52
  []
51
53
  end
52
54
  end
53
55
 
56
+ def variant_repo(host, variant)
57
+ if variant && host.content_source
58
+ product_id = host&.content_facet&.kickstart_repository&.product_id
59
+ distro = distribution_repositories(host)
60
+ .joins(:product)
61
+ .where(
62
+ distribution_variant: variant,
63
+ "#{Katello::Product.table_name}.id": product_id
64
+ ).first
65
+ distro.to_hash(host.content_source) if distro
66
+ end
67
+ end
68
+
54
69
  def distribution_repositories(host)
55
70
  content_view = host.try(:content_facet).try(:content_view) || host.try(:content_view)
56
71
  lifecycle_environment = host.try(:content_facet).try(:lifecycle_environment) || host.try(:lifecycle_environment)
@@ -58,8 +73,7 @@ module Katello
58
73
  if content_view && lifecycle_environment && host.os && host.architecture
59
74
  Katello::Repository.in_environment(lifecycle_environment).in_content_views([content_view]).
60
75
  where(:distribution_version => host.os.release,
61
- :distribution_arch => host.architecture.name,
62
- :distribution_bootable => true)
76
+ :distribution_arch => host.architecture.name)
63
77
  else
64
78
  []
65
79
  end
@@ -1,4 +1,3 @@
1
-
2
1
  module Katello
3
2
  module Concerns
4
3
  module SearchByRepositoryName
@@ -62,14 +62,20 @@ module Katello
62
62
  }
63
63
  scope :with_content, -> { with_features(PULP_FEATURE, PULP_NODE_FEATURE) }
64
64
 
65
- def self.default_capsule
65
+ def self.pulp_master
66
66
  unscoped.with_features(PULP_FEATURE).first
67
67
  end
68
68
 
69
+ def self.pulp_master!
70
+ pulp_master || fail(_("Could not find a smart proxy with pulp feature."))
71
+ end
72
+
73
+ def self.default_capsule
74
+ pulp_master
75
+ end
76
+
69
77
  def self.default_capsule!
70
- capsule = default_capsule
71
- fail _("Could not find a smart proxy with pulp feature.") if capsule.nil?
72
- capsule
78
+ pulp_master!
73
79
  end
74
80
  end
75
81
 
@@ -87,26 +93,34 @@ module Katello
87
93
  path
88
94
  end
89
95
 
90
- def pulp_node
91
- @pulp_node ||= Katello::Pulp::Server.config(pulp_url, User.remote_user)
92
- end
93
-
94
96
  def pulp_url
95
97
  uri = URI.parse(url)
96
98
  "#{uri.scheme}://#{uri.host}/pulp/api/v2/"
97
99
  end
98
100
 
99
- def default_capsule?
101
+ def pulp_api
102
+ @pulp_api ||= Katello::Pulp::Server.config(pulp_url, User.remote_user)
103
+ end
104
+
105
+ def pulp_mirror?
106
+ self.features.map(&:name).include?(PULP_NODE_FEATURE)
107
+ end
108
+
109
+ def pulp_master?
100
110
  # use map instead of pluck in case the features aren't saved yet during create
101
111
  self.features.map(&:name).include?(PULP_FEATURE)
102
112
  end
103
113
 
114
+ #deprecated methods
115
+ alias_method :pulp_node, :pulp_api
116
+ alias_method :default_capsule?, :pulp_master?
117
+
104
118
  def associate_organizations
105
- self.organizations = Organization.all if self.default_capsule?
119
+ self.organizations = Organization.all if self.pulp_master?
106
120
  end
107
121
 
108
122
  def associate_default_locations
109
- return unless default_capsule?
123
+ return unless pulp_master?
110
124
  ['puppet_content', 'subscribed_hosts'].each do |type|
111
125
  default_location = ::Location.unscoped.find_by_title(
112
126
  ::Setting[:"default_location_#{type}"])
@@ -121,7 +135,7 @@ module Katello
121
135
  end
122
136
 
123
137
  def associate_lifecycle_environments
124
- self.lifecycle_environments = Katello::KTEnvironment.all if self.default_capsule?
138
+ self.lifecycle_environments = Katello::KTEnvironment.all if self.pulp_master?
125
139
  end
126
140
  end
127
141
  end
@@ -0,0 +1,7 @@
1
+ module Katello
2
+ class ContentFacetApplicableModuleStream < Katello::Model
3
+ # Do not use active record callbacks in this join model. Direct INSERTs and DELETEs are done
4
+ belongs_to :content_facet, :inverse_of => :content_facet_applicable_rpms, :class_name => 'Katello::Host::ContentFacet'
5
+ belongs_to :module_stream, :inverse_of => :content_facet_applicable_module_streams, :class_name => 'Katello::ModuleStream'
6
+ end
7
+ end
@@ -34,10 +34,6 @@ module Katello
34
34
  Repository::PUPPET_TYPE
35
35
  end
36
36
 
37
- def unprotected
38
- false
39
- end
40
-
41
37
  def mirror_on_sync?
42
38
  true
43
39
  end
@@ -50,20 +46,12 @@ module Katello
50
46
  true
51
47
  end
52
48
 
53
- def node_syncable?
54
- environment
55
- end
56
-
57
- def ssl_client_cert
58
- false
59
- end
60
-
61
- def ssl_client_key
62
- false
49
+ def backend_service(smart_proxy)
50
+ @service ||= Katello::Pulp::Repository.instance_for_type(nonpersisted_repository, smart_proxy)
63
51
  end
64
52
 
65
- def ssl_ca_cert
66
- false
53
+ def node_syncable?
54
+ environment
67
55
  end
68
56
 
69
57
  def organization
@@ -91,25 +79,16 @@ module Katello
91
79
  self.environment.nil?
92
80
  end
93
81
 
94
- def generate_puppet_path(capsule)
95
- # rubocop:disable Style/EmptyElse
96
- if self.environment
97
- File.join(capsule.puppet_path, generate_puppet_env_name, 'modules')
98
- else
99
- nil #don't generate archived content view puppet environments
100
- end
101
- end
102
-
103
- def generate_puppet_env_name
104
- if self.environment
105
- Environment.construct_name(self.organization,
106
- self.environment,
107
- self.content_view)
108
- end
109
- end
110
-
111
- def ignore_global_proxy
112
- false
82
+ def nonpersisted_repository
83
+ #This creates a mock repository that can be used
84
+ root = ::Katello::RootRepository.new(content_type: ::Katello::Repository::PUPPET_TYPE,
85
+ name: "#{content_view.name} Puppet Environment",
86
+ mirror_on_sync: true,
87
+ product: Product.new(:organization => organization))
88
+ ::Katello::Repository.new(root: root,
89
+ pulp_id: pulp_id,
90
+ content_view_version: content_view_version,
91
+ environment: environment)
113
92
  end
114
93
 
115
94
  def set_pulp_id