katello 4.1.4 → 4.2.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 (240) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/katello/api/rhsm/candlepin_proxies_controller.rb +2 -2
  3. data/app/controllers/katello/api/v2/content_credentials_controller.rb +3 -3
  4. data/app/controllers/katello/api/v2/content_uploads_controller.rb +3 -1
  5. data/app/controllers/katello/api/v2/content_view_components_controller.rb +33 -1
  6. data/app/controllers/katello/api/v2/content_views_controller.rb +12 -0
  7. data/app/controllers/katello/api/v2/host_errata_controller.rb +1 -1
  8. data/app/controllers/katello/api/v2/products_bulk_actions_controller.rb +1 -2
  9. data/app/controllers/katello/api/v2/products_controller.rb +4 -4
  10. data/app/controllers/katello/api/v2/repositories_bulk_actions_controller.rb +3 -11
  11. data/app/controllers/katello/api/v2/repositories_controller.rb +68 -47
  12. data/app/controllers/katello/api/v2/upstream_subscriptions_controller.rb +0 -28
  13. data/app/controllers/katello/concerns/api/v2/registration_commands_controller_extensions.rb +26 -5
  14. data/app/controllers/katello/concerns/api/v2/registration_controller_extensions.rb +26 -1
  15. data/app/lib/actions/candlepin/environment/destroy.rb +2 -0
  16. data/app/lib/actions/katello/agent_action.rb +2 -2
  17. data/app/lib/actions/katello/capsule_content/sync_capsule.rb +3 -2
  18. data/app/lib/actions/katello/{gpg_key → content_credential}/update.rb +1 -1
  19. data/app/lib/actions/katello/content_view/publish.rb +6 -1
  20. data/app/lib/actions/katello/content_view_version/create_repos.rb +1 -1
  21. data/app/lib/actions/katello/content_view_version/incremental_update.rb +0 -47
  22. data/app/lib/actions/katello/orphan_cleanup/remove_orphans.rb +1 -1
  23. data/app/lib/actions/katello/repository/clone_contents.rb +1 -7
  24. data/app/lib/actions/katello/repository/clone_to_environment.rb +1 -7
  25. data/app/lib/actions/katello/repository/create.rb +4 -8
  26. data/app/lib/actions/katello/repository/create_root.rb +1 -1
  27. data/app/lib/actions/katello/repository/destroy.rb +1 -3
  28. data/app/lib/actions/katello/repository/import_upload.rb +3 -2
  29. data/app/lib/actions/katello/repository/instance_update.rb +1 -1
  30. data/app/lib/actions/katello/repository/metadata_generate.rb +2 -8
  31. data/app/lib/actions/katello/repository/multi_clone_contents.rb +0 -1
  32. data/app/lib/actions/katello/repository/refresh_repository.rb +1 -4
  33. data/app/lib/actions/katello/repository/remove_content.rb +6 -4
  34. data/app/lib/actions/katello/repository/sync.rb +5 -25
  35. data/app/lib/actions/katello/repository/update.rb +1 -2
  36. data/app/lib/actions/katello/repository/update_http_proxy_details.rb +2 -5
  37. data/app/lib/actions/katello/repository/update_redhat_repository.rb +1 -1
  38. data/app/lib/actions/katello/repository/upload_files.rb +8 -3
  39. data/app/lib/actions/katello/repository/upload_package_group.rb +2 -11
  40. data/app/lib/actions/katello/repository/verify_checksum.rb +0 -1
  41. data/app/lib/actions/katello/repository_set/enable_repository.rb +1 -1
  42. data/app/lib/actions/pulp3/orchestration/repository/create.rb +2 -2
  43. data/app/lib/actions/pulp3/repository/create.rb +3 -4
  44. data/app/lib/actions/pulp3/repository/create_remote.rb +1 -6
  45. data/app/lib/actions/pulp3/repository/repair.rb +4 -0
  46. data/app/lib/katello/errors.rb +1 -0
  47. data/app/lib/katello/http_resource.rb +26 -73
  48. data/app/lib/katello/qpid/connection.rb +1 -3
  49. data/app/lib/katello/resources/candlepin/consumer.rb +1 -1
  50. data/app/lib/katello/resources/candlepin/environment.rb +2 -0
  51. data/app/lib/katello/resources/registry.rb +7 -20
  52. data/app/lib/katello/util/http_proxy.rb +0 -3
  53. data/app/lib/katello/validators/gpg_key_content_validator.rb +1 -1
  54. data/app/models/katello/authorization/{gpg_key.rb → content_credential.rb} +1 -1
  55. data/app/models/katello/authorization/product.rb +0 -4
  56. data/app/models/katello/concerns/host_managed_extensions.rb +2 -16
  57. data/app/models/katello/concerns/organization_extensions.rb +1 -1
  58. data/app/models/katello/concerns/pulp_database_unit.rb +13 -5
  59. data/app/models/katello/concerns/smart_proxy_extensions.rb +45 -41
  60. data/app/models/katello/{gpg_key.rb → content_credential.rb} +4 -4
  61. data/app/models/katello/content_view.rb +6 -1
  62. data/app/models/katello/generic_content_unit.rb +16 -0
  63. data/app/models/katello/glue/pulp/repos.rb +9 -25
  64. data/app/models/katello/kt_environment.rb +1 -1
  65. data/app/models/katello/product.rb +4 -4
  66. data/app/models/katello/repository.rb +13 -7
  67. data/app/models/katello/repository_generic_content_unit.rb +7 -0
  68. data/app/models/katello/root_repository.rb +38 -7
  69. data/app/models/setting/content.rb +5 -0
  70. data/app/services/cert/certs.rb +16 -8
  71. data/app/services/katello/applicability/applicable_content_helper.rb +1 -2
  72. data/app/services/katello/candlepin/consumer.rb +6 -0
  73. data/app/services/katello/component_view_presenter.rb +27 -0
  74. data/app/services/katello/pulp/repository.rb +1 -1
  75. data/app/services/katello/pulp/server.rb +2 -2
  76. data/app/services/katello/pulp3/api/core.rb +4 -0
  77. data/app/services/katello/pulp3/api/generic.rb +68 -0
  78. data/app/services/katello/pulp3/generic_content_unit.rb +29 -0
  79. data/app/services/katello/pulp3/pulp_content_unit.rb +5 -1
  80. data/app/services/katello/pulp3/repository/generic.rb +94 -0
  81. data/app/services/katello/pulp3/repository/yum.rb +4 -5
  82. data/app/services/katello/pulp3/repository.rb +27 -12
  83. data/app/services/katello/pulp3/repository_mirror.rb +2 -2
  84. data/app/services/katello/pulp3/smart_proxy_repository.rb +4 -4
  85. data/app/services/katello/registration_manager.rb +18 -7
  86. data/app/services/katello/repository_type.rb +59 -1
  87. data/app/services/katello/repository_type_manager.rb +116 -24
  88. data/app/views/katello/api/v2/content_views/base.json.rabl +4 -4
  89. data/app/views/katello/api/v2/repositories/show.json.rabl +1 -0
  90. data/app/views/smart_proxies/plugins/_pulpcore.html.erb +2 -5
  91. data/app/views/smart_proxies/pulp_status.html.erb +0 -7
  92. data/config/katello.yaml.example +0 -21
  93. data/config/routes/api/v2.rb +2 -1
  94. data/db/functions/deb_version_cmp_v01.sql +200 -0
  95. data/db/migrate/20171110082124_add_ssl_certs_to_products_and_repos.rb +5 -1
  96. data/db/migrate/20200402130013_add_repsoitory_docker_meta_tag_f_key.rb +3 -1
  97. data/db/migrate/20210624221630_katello_generic_content.rb +22 -0
  98. data/db/migrate/20210625095042_add_retain_package_versions_count.rb +9 -0
  99. data/db/migrate/20210628182553_add_generic_remote_options_to_root_repository.rb +5 -0
  100. data/db/migrate/20210714140440_remove_repo_export_permission.rb +5 -0
  101. data/db/migrate/20210721163730_change_gpg_keys_to_content_credentials.rb +8 -0
  102. data/db/migrate/20210728130748_create_function_deb_version_cmp.rb +12 -0
  103. data/db/seeds.d/111-upgrade_tasks.rb +1 -2
  104. data/engines/bastion/app/views/bastion/layouts/assets.html.erb +1 -1
  105. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/capsule-content/capsule-content.controller.js +7 -5
  106. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/bulk/views/content-hosts-bulk-errata-modal.html +4 -1
  107. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/views/content-view-details.html +1 -1
  108. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/errata/apply-errata.controller.js +1 -1
  109. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/errata/views/apply-errata-confirm.html +2 -1
  110. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/bastion_katello.pot +25 -33
  111. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/bulk/views/products-bulk-advanced-sync-modal.html +1 -1
  112. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/product-repositories.controller.js +1 -6
  113. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/repository-details-info.controller.js +10 -2
  114. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/repository-details-info.filter.js +9 -0
  115. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/repository-details.controller.js +0 -2
  116. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-advanced-sync-options.html +1 -25
  117. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-details.html +1 -1
  118. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-info.html +31 -13
  119. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/new/views/new-repository.html +11 -3
  120. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/views/product-repositories.html +0 -6
  121. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/tasks/aggregate-task.factory.js +3 -3
  122. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/tasks/task.factory.js +1 -1
  123. data/lib/katello/engine.rb +2 -4
  124. data/lib/katello/permission_creator.rb +6 -12
  125. data/lib/katello/plugin.rb +76 -80
  126. data/lib/katello/repository_types/python.rb +37 -0
  127. data/lib/katello/tasks/reimport.rake +0 -9
  128. data/lib/katello/tasks/repository.rake +3 -4
  129. data/lib/katello/version.rb +1 -1
  130. data/locale/action_names.rb +28 -29
  131. data/locale/bn/katello.po +699 -221
  132. data/locale/cs/katello.po +167 -59
  133. data/locale/de/katello.po +585 -352
  134. data/locale/en/katello.po +167 -59
  135. data/locale/es/katello.po +1388 -1189
  136. data/locale/fr/katello.po +1740 -1494
  137. data/locale/gu/katello.po +896 -416
  138. data/locale/hi/katello.po +892 -415
  139. data/locale/it/katello.po +371 -170
  140. data/locale/ja/katello.po +1657 -1439
  141. data/locale/katello.pot +933 -736
  142. data/locale/kn/katello.po +894 -416
  143. data/locale/ko/katello.po +515 -317
  144. data/locale/mr/katello.po +857 -415
  145. data/locale/or/katello.po +894 -416
  146. data/locale/pa/katello.po +874 -411
  147. data/locale/pt/katello.po +347 -154
  148. data/locale/pt_BR/katello.po +1398 -1215
  149. data/locale/ru/katello.po +671 -463
  150. data/locale/ta/katello.po +697 -221
  151. data/locale/te/katello.po +891 -415
  152. data/locale/zh_CN/katello.po +2029 -1845
  153. data/locale/zh_TW/katello.po +735 -407
  154. data/package.json +3 -1
  155. data/webpack/components/EditableTextInput/EditableTextInput.js +3 -3
  156. data/webpack/components/RoutedTabs/RoutedTabs.js +7 -8
  157. data/webpack/components/Table/TableWrapper.js +19 -11
  158. data/webpack/components/Table/helpers.js +1 -1
  159. data/webpack/components/extensions/HostDetails/Tabs/ContentTab.js +42 -0
  160. data/webpack/components/extensions/HostDetails/Tabs/SubscriptionTab.js +12 -0
  161. data/webpack/components/extensions/RegistrationCommands/__tests__/__snapshots__/ActivationKeys.test.js.snap +4 -0
  162. data/webpack/components/extensions/RegistrationCommands/fields/ActivationKeys.js +1 -1
  163. data/webpack/components/extensions/RegistrationCommands/index.js +1 -2
  164. data/webpack/components/pf3Table/formatters/selectionHeaderCellFormatter.js +2 -1
  165. data/webpack/fills_index.js +4 -1
  166. data/webpack/redux/actions/RedHatRepositories/helpers.js +2 -4
  167. data/webpack/redux/reducers/RedHatRepositories/enabled.js +4 -1
  168. data/webpack/scenes/ContentViews/ContentViewsActions.js +16 -1
  169. data/webpack/scenes/ContentViews/ContentViewsConstants.js +15 -0
  170. data/webpack/scenes/ContentViews/ContentViewsPage.js +12 -22
  171. data/webpack/scenes/ContentViews/Copy/CopyContentViewForm.js +4 -3
  172. data/webpack/scenes/ContentViews/Create/CreateContentViewForm.js +25 -14
  173. data/webpack/scenes/ContentViews/Create/CreateContentViewModal.js +4 -2
  174. data/webpack/scenes/ContentViews/Details/ComponentContentViews/ComponentContentViewAddModal.js +153 -0
  175. data/webpack/scenes/ContentViews/Details/ComponentContentViews/ComponentVersion.js +21 -10
  176. data/webpack/scenes/ContentViews/Details/ComponentContentViews/ContentViewComponents.js +157 -19
  177. data/webpack/scenes/ContentViews/Details/ComponentContentViews/__tests__/contentViewComponents.fixtures.json +100 -108
  178. data/webpack/scenes/ContentViews/Details/ComponentContentViews/__tests__/contentViewComponents.test.js +140 -16
  179. data/webpack/scenes/ContentViews/Details/ComponentContentViews/__tests__/publishedContentViewDetails.fixtures.json +367 -0
  180. data/webpack/scenes/ContentViews/Details/ContentViewDetailActions.js +59 -6
  181. data/webpack/scenes/ContentViews/Details/ContentViewDetailSelectors.js +43 -0
  182. data/webpack/scenes/ContentViews/Details/ContentViewDetails.js +44 -13
  183. data/webpack/scenes/ContentViews/Details/Filters/Add/CVFilterAddModal.js +161 -0
  184. data/webpack/scenes/ContentViews/Details/Filters/Add/__tests__/cvFilterAdd.test.js +54 -0
  185. data/webpack/scenes/ContentViews/Details/Filters/Add/__tests__/cvFilterCreateResult.fixtures.json +124 -0
  186. data/webpack/scenes/ContentViews/Details/Filters/CVPackageGroupFilterContent.js +8 -6
  187. data/webpack/scenes/ContentViews/Details/Filters/CVRpmFilterContent.js +7 -6
  188. data/webpack/scenes/ContentViews/Details/Filters/ContentViewFilterDetails.js +4 -3
  189. data/webpack/scenes/ContentViews/Details/Filters/ContentViewFilters.js +71 -12
  190. data/webpack/scenes/ContentViews/Details/Filters/__tests__/contentViewFilters.test.js +77 -0
  191. data/webpack/scenes/ContentViews/Details/Histories/ContentViewHistories.js +13 -12
  192. data/webpack/scenes/ContentViews/Details/Histories/__tests__/contentViewHistory.test.js +2 -2
  193. data/webpack/scenes/ContentViews/Details/Repositories/ContentViewRepositories.js +17 -14
  194. data/webpack/scenes/ContentViews/Details/Repositories/LastSync.js +3 -3
  195. data/webpack/scenes/ContentViews/Details/Repositories/__tests__/contentViewAddRemove.test.js +2 -2
  196. data/webpack/scenes/ContentViews/Details/Repositories/__tests__/contentViewDetailRepos.test.js +6 -2
  197. data/webpack/scenes/ContentViews/Details/Versions/ContentViewVersions.js +61 -20
  198. data/webpack/scenes/ContentViews/Details/Versions/__tests__/contentViewTaskInProgressResponse.fixtures.json +71 -0
  199. data/webpack/scenes/ContentViews/Details/Versions/__tests__/contentViewTaskResponse.fixtures.json +75 -0
  200. data/webpack/scenes/ContentViews/Details/Versions/__tests__/contentViewVersions.test.js +86 -1
  201. data/webpack/scenes/ContentViews/Details/Versions/__tests__/contentViewVersionsWithTask.fixtures.json +713 -0
  202. data/webpack/scenes/ContentViews/Details/__tests__/contentViewDetail.test.js +3 -0
  203. data/webpack/scenes/ContentViews/Publish/CVPublishFinish.js +184 -0
  204. data/webpack/scenes/ContentViews/Publish/CVPublishForm.js +104 -0
  205. data/webpack/scenes/ContentViews/Publish/CVPublishReview.js +71 -0
  206. data/webpack/scenes/ContentViews/Publish/ContentViewPublishSelectors.js +17 -0
  207. data/webpack/scenes/ContentViews/Publish/PublishContentViewWizard.js +145 -0
  208. data/webpack/scenes/ContentViews/Publish/__tests__/environmentPaths.fixtures.json +352 -0
  209. data/webpack/scenes/ContentViews/Publish/__tests__/publishContentView.test.js +184 -0
  210. data/webpack/scenes/ContentViews/Publish/__tests__/publishResponse.fixture.json +69 -0
  211. data/webpack/scenes/ContentViews/Publish/cvPublishForm.scss +3 -0
  212. data/webpack/scenes/ContentViews/Table/ContentViewsTable.js +75 -48
  213. data/webpack/scenes/ContentViews/Table/tableDataGenerator.js +15 -2
  214. data/webpack/scenes/ContentViews/__tests__/contentViewPage.test.js +6 -10
  215. data/webpack/scenes/ContentViews/components/EnvironmentLabels.js +22 -10
  216. data/webpack/scenes/ContentViews/components/EnvironmentPaths/EnvironmentPathActions.js +12 -0
  217. data/webpack/scenes/ContentViews/components/EnvironmentPaths/EnvironmentPathConstants.js +2 -0
  218. data/webpack/scenes/ContentViews/components/EnvironmentPaths/EnvironmentPathSelectors.js +16 -0
  219. data/webpack/scenes/ContentViews/components/EnvironmentPaths/EnvironmentPaths.js +72 -0
  220. data/webpack/scenes/ContentViews/components/EnvironmentPaths/EnvironmentPaths.scss +8 -0
  221. data/webpack/scenes/ContentViews/components/TaskPresenter/TaskPresenter.js +85 -0
  222. data/webpack/scenes/SmartProxy/SmartProxyContentTable.js +9 -8
  223. data/webpack/scenes/Subscriptions/SubscriptionsPage.js +4 -25
  224. data/webpack/scenes/Subscriptions/__tests__/SubscriptionsPage.test.js +0 -3
  225. data/webpack/scenes/Subscriptions/__tests__/__snapshots__/SubscriptionsPage.test.js.snap +3 -3
  226. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/SubscriptionsTableSchema.js +4 -2
  227. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/__tests__/__snapshots__/SubscriptionsTable.test.js.snap +24 -0
  228. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/components/Table.js +4 -1
  229. data/webpack/scenes/Subscriptions/index.js +1 -4
  230. metadata +74 -39
  231. data/app/lib/actions/candlepin/environment/create.rb +0 -21
  232. data/app/lib/actions/foreman/environment/destroy.rb +0 -23
  233. data/app/lib/actions/katello/content_view/environment_create.rb +0 -21
  234. data/app/lib/actions/katello/repository/export.rb +0 -85
  235. data/app/lib/actions/katello/repository/purge_empty_content.rb +0 -16
  236. data/app/lib/actions/katello/repository/upload_errata.rb +0 -38
  237. data/app/lib/katello/util/proxy_uri.rb +0 -64
  238. data/app/models/katello/rhsm_fact_importer.rb +0 -20
  239. data/app/models/katello/rhsm_fact_name.rb +0 -17
  240. data/app/models/katello/rhsm_fact_parser.rb +0 -120
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c5585f90b341b73cc8ff5d0b5adea7f31e794da93c42e6f755de36b86f0fe12
4
- data.tar.gz: fea8f7973ec98df5967310fcd025767d7fe03ee8077a388c64bb8b50101190b1
3
+ metadata.gz: 8aa0f375342de9345f09a8a5b1cd5d7ab68af3282a4b8863cf9b63c33130fbcd
4
+ data.tar.gz: 871e47ae53fdd69760c042278b9feb68a1b0d81599db67cfae9ee375a270034e
5
5
  SHA512:
6
- metadata.gz: aabf11851850da36e0a135c9a8dc0e0561ab4791c234bdd47e63caef2342cd60bf8428060399161f17eafe22878144dac4b7277250b68ae1a9c15e63c7ed4fac
7
- data.tar.gz: 4b72e1f19961cf571056f14291e2bb811c29c353ae7453175a8afd2bf83b29f02709ad540a82230fcbc982923e5025cb19f37730373ea90c16afe7818f745c66
6
+ metadata.gz: 11757b1ba7c279ca6a6b70760996c8e81d0be8fc935ba0da3dd531beb69d00a4dadd9b113a7dd8f036ecd9d035c71a7f8ce2a5bebf4e53e8f0d9b80cccef4b92
7
+ data.tar.gz: 4c9337e95fda3f0e010f9fc11c3e838f15aea5f10fae1dd17312ea067c2bb20d5f5d2b05c36fee9ce274c3916db2c866d10e321c7b9a278eb2c8543983a7e3b4
@@ -48,7 +48,8 @@ module Katello
48
48
  end
49
49
 
50
50
  rescue_from RestClient::Exception do |e|
51
- Rails.logger.error pp_exception(e)
51
+ Rails.logger.error(pp_exception(e, with_backtrace: false))
52
+ Rails.logger.error(e.backtrace.detect { |line| line.match("katello.*controller") })
52
53
  if request_from_katello_cli?
53
54
  render :json => { :errors => [e.http_body] }, :status => e.http_code
54
55
  else
@@ -295,7 +296,6 @@ module Katello
295
296
  if facet.nil?
296
297
  # check with candlepin if consumer is Gone, raises RestClient::Gone
297
298
  User.as_anonymous_admin { Resources::Candlepin::Consumer.get(uuid) }
298
- fail HttpErrors::NotFound, _("Couldn't find consumer '%s'") % uuid
299
299
  end
300
300
  @host = ::Host::Managed.unscoped.find(facet.host_id)
301
301
  end
@@ -6,7 +6,7 @@ module Katello
6
6
  skip_before_action :check_media_type, :only => [:create, :content, :set_content]
7
7
 
8
8
  def resource_class
9
- Katello::GpgKey
9
+ Katello::ContentCredential
10
10
  end
11
11
 
12
12
  def_param_group :content_credential do
@@ -35,7 +35,7 @@ module Katello
35
35
  end
36
36
 
37
37
  def index_relation
38
- query = GpgKey.readable.where(:organization_id => @organization.id)
38
+ query = ContentCredential.readable.where(:organization_id => @organization.id)
39
39
  query = query.where(:name => params[:name]) if params[:name]
40
40
  query = query.where(:content_type => params[:content_type]) if params[:content_type]
41
41
  query
@@ -68,7 +68,7 @@ module Katello
68
68
  param :id, :number, :desc => N_('Content Credential ID'), :required => true
69
69
  param_group :content_credential
70
70
  def update
71
- sync_task(::Actions::Katello::GpgKey::Update, @content_credential, content_credential_params.to_h)
71
+ sync_task(::Actions::Katello::ContentCredential::Update, @content_credential, content_credential_params.to_h)
72
72
  respond_for_show(:resource => @content_credential)
73
73
  end
74
74
 
@@ -10,9 +10,11 @@ module Katello
10
10
  param :repository_id, :number, :required => true, :desc => N_("repository id")
11
11
  param :size, :number, :required => true, :desc => N_("Size of file to upload")
12
12
  param :checksum, String, :required => false, :desc => N_("Checksum of file to upload")
13
- param :content_type, RepositoryTypeManager.uploadable_content_types.map(&:label), :required => false, :desc => N_("content type ('deb', 'docker_manifest', 'file', 'ostree', 'rpm', 'srpm')")
13
+ param :content_type, RepositoryTypeManager.uploadable_content_types(false).map(&:label), :required => false, :desc => N_("content type ('deb', 'docker_manifest', 'file', 'ostree', 'rpm', 'srpm')")
14
14
  def create
15
15
  content_type = params[:content_type] || ::Katello::RepositoryTypeManager.find(@repository.content_type).default_managed_content_type.label
16
+ RepositoryTypeManager.check_content_matches_repo_type!(@repository, content_type)
17
+
16
18
  unit_type_id = SmartProxy.pulp_primary.content_service(content_type).content_type
17
19
  render :json => @repository.backend_content_service(::SmartProxy.pulp_primary).create_upload(params[:size], params[:checksum], unit_type_id)
18
20
  end
@@ -1,9 +1,10 @@
1
1
  module Katello
2
2
  class Api::V2::ContentViewComponentsController < Api::V2::ApiController
3
3
  include Katello::Concerns::FilteredAutoCompleteSearch
4
- before_action :find_composite_content_view, :only => [:show, :index]
4
+ before_action :find_composite_content_view, :only => [:show, :index, :show_all]
5
5
  before_action :find_composite_content_view_for_edit, :only => [:add_components, :remove_components, :update]
6
6
  before_action :find_authorized_katello_resource, :only => [:show, :update]
7
+ before_action :find_organization_from_cv, :only => [:show_all]
7
8
 
8
9
  wrap_parameters :include => %w(composite_content_view_id content_view_version_id content_view_id latest)
9
10
 
@@ -28,6 +29,33 @@ module Katello
28
29
  }
29
30
  end
30
31
 
32
+ # content_views/:id/components/show_all
33
+ # Shows all content views, added and available to add, for a content view
34
+ # Undocumented endpoint since the functionality exists in separate calls already.
35
+ # This was created for ease of pagination and search for the UI
36
+ # param :id, :number, desc: N_("Content View id"), required: true
37
+ # param :status, ["Added", "Not added", "All"], :desc => N_("Filter to show added, not added or all components")
38
+ def show_all
39
+ kc = Katello::ContentView.table_name
40
+ kcc = Katello::ContentViewComponent.table_name
41
+ join_query = <<-SQL
42
+ LEFT OUTER JOIN #{kcc}
43
+ ON #{kc}.id = #{kcc}.content_view_id
44
+ AND #{kcc}.composite_content_view_id = #{@view.id}
45
+ SQL
46
+ order_query = <<-SQL
47
+ CAST (#{kcc}.composite_content_view_id as BOOLEAN) ASC, #{kc}.name
48
+ SQL
49
+
50
+ query = Katello::ContentView.readable.in_organization(@organization)
51
+ query = query&.non_composite&.non_default
52
+ custom_sort = ->(sort_query) { sort_query.joins(join_query).order(order_query) }
53
+ options = { resource_class: Katello::ContentView, custom_sort: custom_sort }
54
+ collection = scoped_search(query, nil, nil, options)
55
+ collection[:results] = ComponentViewPresenter.component_presenter(@view, params[:status], views: collection[:results])
56
+ respond_for_index(:collection => collection, :template => "index")
57
+ end
58
+
31
59
  api :PUT, "/content_views/:composite_content_view_id/content_view_components/add",
32
60
  N_("Add components to the content view")
33
61
  param :composite_content_view_id, :number, :desc => N_("composite content view identifier"), :required => true
@@ -135,5 +163,9 @@ module Katello
135
163
  fail "Unsupported default_sort type"
136
164
  end
137
165
  end
166
+
167
+ def find_organization_from_cv
168
+ @organization = @view.organization
169
+ end
138
170
  end
139
171
  end
@@ -90,6 +90,8 @@ module Katello
90
90
  param :description, String, :desc => N_("Description for the new published content view version")
91
91
  param :major, :number, :desc => N_("Override the major version number"), :required => false
92
92
  param :minor, :number, :desc => N_("Override the minor version number"), :required => false
93
+ param :environment_ids, Array, :desc => N_("Identifiers for Lifecycle Environment"), :required => false
94
+ param :is_force_promote, :bool, :desc => N_("force content view promotion and bypass lifecycle environment restriction"), :required => false
93
95
  param :repos_units, Array, :desc => N_("Specify the list of units in each repo"), :required => false do
94
96
  param :label, String, :desc => N_("repo label"), :required => true
95
97
  param :rpm_filenames, Array, of: String, :desc => N_("list of rpm filename strings to include in published version"), :required => true
@@ -108,6 +110,8 @@ module Katello
108
110
  end
109
111
 
110
112
  task = async_task(::Actions::Katello::ContentView::Publish, @content_view, params[:description],
113
+ :environment_ids => params[:environment_ids],
114
+ :is_force_promote => params[:is_force_promote],
111
115
  :major => params[:major],
112
116
  :minor => params[:minor],
113
117
  :repos_units => params[:repos_units])
@@ -164,6 +168,14 @@ module Katello
164
168
  respond_for_async :resource => task
165
169
  end
166
170
 
171
+ api :PUT, "/content_views/:id/remove_filters", N_("Delete multiple filters from a content view")
172
+ param :id, :number, :desc => N_("content view numeric identifier"), :required => true
173
+ param :filter_ids, Array, of: :number, :desc => N_("filter identifiers"), :required => true
174
+ def remove_filters
175
+ Katello::ContentViewFilter.where(id: params[:filter_ids]).try(:destroy_all)
176
+ respond_for_show(:resource => @content_view)
177
+ end
178
+
167
179
  api :DELETE, "/content_views/:id", N_("Delete a content view")
168
180
  param :id, :number, :desc => N_("content view numeric identifier"), :required => true
169
181
  def destroy
@@ -53,7 +53,7 @@ module Katello
53
53
 
54
54
  api :PUT, "/hosts/:host_id/errata/apply", N_("Schedule errata for installation using katello-agent. %s") % katello_agent_deprecation_text, deprecated: true
55
55
  param :host_id, :number, :desc => N_("Host ID"), :required => true
56
- param :errata_ids, Array, :desc => N_("List of Errata ids to install. Will be removed in %s") % katello_agent_removal_release, required: false, deprecated: true
56
+ param :errata_ids, Array, :desc => N_("List of Errata ids to install. Will be removed in %s") % katello_agent_removal_release, required: true
57
57
 
58
58
  param_group :bulk_errata_ids
59
59
  def apply
@@ -53,8 +53,7 @@ module Katello
53
53
  param :ids, Array, :desc => N_("List of product ids"), :required => true
54
54
  def verify_checksum_products
55
55
  repairable_products = @products.syncable
56
- repairable_roots = RootRepository.where(:product_id => repairable_products).
57
- where(:content_type => ::Katello::Repository::YUM_TYPE).has_url.select { |r| r.library_instance }.uniq
56
+ repairable_roots = RootRepository.where(:product_id => repairable_products).has_url.select { |r| r.library_instance }.uniq
58
57
 
59
58
  repairable_repositories = Katello::Repository.where(:root_id => repairable_roots)
60
59
  task = async_task(::Actions::BulkAction,
@@ -150,7 +150,7 @@ module Katello
150
150
  def authorize_gpg_key
151
151
  gpg_key_id = product_params[:gpg_key_id]
152
152
  if gpg_key_id
153
- gpg_key = GpgKey.readable.where(:id => gpg_key_id, :organization_id => @organization).first
153
+ gpg_key = ContentCredential.readable.where(:id => gpg_key_id, :organization_id => @organization).first
154
154
  throw_resource_not_found(name: 'gpg key', id: gpg_key_id) if gpg_key.nil?
155
155
  end
156
156
  end
@@ -158,7 +158,7 @@ module Katello
158
158
  def authorize_ssl_ca_cert
159
159
  ssl_ca_cert_id = product_params[:ssl_ca_cert_id]
160
160
  if ssl_ca_cert_id
161
- ssl_ca_cert = GpgKey.readable.where(:id => ssl_ca_cert_id, :organization_id => @organization).first
161
+ ssl_ca_cert = ContentCredential.readable.where(:id => ssl_ca_cert_id, :organization_id => @organization).first
162
162
  throw_resource_not_found(name: 'ssl ca cert', id: ssl_ca_cert_id) if ssl_ca_cert.nil?
163
163
  end
164
164
  end
@@ -166,7 +166,7 @@ module Katello
166
166
  def authorize_ssl_client_cert
167
167
  ssl_client_cert_id = product_params[:ssl_client_cert_id]
168
168
  if ssl_client_cert_id
169
- ssl_client_cert = GpgKey.readable.where(:id => ssl_client_cert_id, :organization_id => @organization).first
169
+ ssl_client_cert = ContentCredential.readable.where(:id => ssl_client_cert_id, :organization_id => @organization).first
170
170
  throw_resource_not_found(name: 'ssl client cert', id: ssl_client_cert_id) if ssl_client_cert.nil?
171
171
  end
172
172
  end
@@ -174,7 +174,7 @@ module Katello
174
174
  def authorize_ssl_client_key
175
175
  ssl_client_key_id = product_params[:ssl_client_key_id]
176
176
  if ssl_client_key_id
177
- ssl_client_key = GpgKey.readable.where(:id => ssl_client_key_id, :organization_id => @organization).first
177
+ ssl_client_key = ContentCredential.readable.where(:id => ssl_client_key_id, :organization_id => @organization).first
178
178
  throw_resource_not_found(name: 'ssl client key', id: ssl_client_key_id) if ssl_client_key.nil?
179
179
  end
180
180
  end
@@ -7,7 +7,6 @@ module Katello
7
7
  def destroy_repositories
8
8
  deletion_authorized_repositories = @repositories.deletable
9
9
  unpromoted_repos = deletion_authorized_repositories.reject { |repo| repo.promoted? }
10
- deletable_repositories = unpromoted_repos.reject { |repo| repo.redhat? }
11
10
 
12
11
  messages1 = format_bulk_action_messages(
13
12
  :success => "",
@@ -23,18 +22,11 @@ module Katello
23
22
  :authorized => unpromoted_repos
24
23
  )
25
24
 
26
- messages3 = format_bulk_action_messages(
27
- :success => "",
28
- :error => _("Repository %s cannot be deleted since they are Red Hat repositories."),
29
- :models => unpromoted_repos,
30
- :authorized => deletable_repositories
31
- )
32
-
33
- errors = messages3[:error] + messages1[:error] + messages2[:error]
25
+ errors = messages1[:error] + messages2[:error]
34
26
 
35
27
  task = nil
36
- if deletable_repositories.count > 0
37
- task = async_task(::Actions::BulkAction, ::Actions::Katello::Repository::Destroy, deletable_repositories)
28
+ if unpromoted_repos.any?
29
+ task = async_task(::Actions::BulkAction, ::Actions::Katello::Repository::Destroy, unpromoted_repos)
38
30
  else
39
31
  status = 400
40
32
  end
@@ -2,7 +2,14 @@ module Katello
2
2
  class Api::V2::RepositoriesController < Api::V2::ApiController # rubocop:disable Metrics/ClassLength
3
3
  include Katello::Concerns::FilteredAutoCompleteSearch
4
4
 
5
- wrap_parameters :repository, :include => RootRepository.attribute_names.concat([:ignore_global_proxy])
5
+ generic_repo_wrap_params = []
6
+ RepositoryTypeManager.generic_remote_options(defined_only: true).each do |option|
7
+ generic_repo_wrap_params << option.name
8
+ end
9
+
10
+ repo_wrap_params = RootRepository.attribute_names.concat([:ignore_global_proxy]) + generic_repo_wrap_params
11
+
12
+ wrap_parameters :repository, :include => repo_wrap_params
6
13
 
7
14
  CONTENT_CREDENTIAL_GPG_KEY_TYPE = "gpg_key".freeze
8
15
  CONTENT_CREDENTIAL_SSL_CA_CERT_TYPE = "ssl_ca_cert".freeze
@@ -14,13 +21,12 @@ module Katello
14
21
  before_action :find_product_for_create, :only => [:create]
15
22
  before_action :find_organization_from_product, :only => [:create]
16
23
  before_action :find_unauthorized_katello_resource, :only => [:gpg_key_content]
17
- before_action :find_authorized_katello_resource, :only => [:show, :update, :destroy, :sync, :export,
24
+ before_action :find_authorized_katello_resource, :only => [:show, :update, :destroy, :sync,
18
25
  :remove_content, :upload_content, :republish,
19
26
  :import_uploads, :verify_checksum]
20
27
  before_action :find_content, :only => :remove_content
21
28
  before_action :find_organization_from_repo, :only => [:update]
22
29
  before_action :error_on_rh_product, :only => [:create]
23
- before_action :error_on_rh_repo, :only => [:destroy]
24
30
  before_action(:only => [:create, :update]) { find_content_credential CONTENT_CREDENTIAL_GPG_KEY_TYPE }
25
31
  before_action(:only => [:create, :update]) { find_content_credential CONTENT_CREDENTIAL_SSL_CA_CERT_TYPE }
26
32
  before_action(:only => [:create, :update]) { find_content_credential CONTENT_CREDENTIAL_SSL_CLIENT_CERT_TYPE }
@@ -62,12 +68,17 @@ module Katello
62
68
  param :http_proxy_policy, ::Katello::RootRepository::HTTP_PROXY_POLICIES, :desc => N_("policies for HTTP proxy for content sync")
63
69
  param :http_proxy_id, :number, :desc => N_("ID of a HTTP Proxy")
64
70
  param :arch, String, :desc => N_("Architecture of content in the repository")
71
+ param :retain_package_versions_count, :number, :desc => N_("The maximum number of versions of each package to keep.")
72
+
73
+ RepositoryTypeManager.generic_remote_options(defined_only: true).each do |option|
74
+ param option.name, option.type, :desc => N_(option.description)
75
+ end
65
76
  end
66
77
 
67
78
  def_param_group :repo_create do
68
79
  param :label, String, :required => false
69
80
  param :product_id, :number, :required => true, :desc => N_("Product the repository belongs to")
70
- param :content_type, RepositoryTypeManager.creatable_repository_types.keys, :required => true, :desc => N_("type of repo")
81
+ param :content_type, RepositoryTypeManager.creatable_repository_types(false).keys, :required => true, :desc => N_("type of repo")
71
82
  end
72
83
 
73
84
  api :GET, "/repositories", N_("List of enabled repositories")
@@ -89,13 +100,13 @@ module Katello
89
100
  param :ostree_branch_id, String, :desc => N_("Id of an ostree branch to find repositories that contain that branch")
90
101
  param :library, :bool, :desc => N_("show repositories in Library and the default content view")
91
102
  param :archived, :bool, :desc => N_("show archived repositories")
92
- param :content_type, RepositoryTypeManager.repository_types.keys, :desc => N_("limit to only repositories of this type")
103
+ param :content_type, RepositoryTypeManager.defined_repository_types.keys, :desc => N_("limit to only repositories of this type")
93
104
  param :name, String, :desc => N_("name of the repository"), :required => false
94
105
  param :label, String, :desc => N_("label of the repository"), :required => false
95
106
  param :description, String, :desc => N_("description of the repository")
96
107
  param :available_for, String, :desc => N_("interpret specified object to return only Repositories that can be associated with specified object. Only 'content_view' & 'content_view_version' are supported."),
97
108
  :required => false
98
- param :with_content, RepositoryTypeManager.enabled_content_types, :desc => N_("only repositories having at least one of the specified content type ex: rpm , erratum")
109
+ param :with_content, RepositoryTypeManager.enabled_content_types(false), :desc => N_("only repositories having at least one of the specified content type ex: rpm , erratum")
99
110
  param :download_policy, ::Runcible::Models::YumImporter::DOWNLOAD_POLICIES, :desc => N_("limit to only repositories with this download policy")
100
111
  param :username, String, :desc => N_("only show the repositories readable by this user with this username")
101
112
  param_group :search, Api::V2::ApiController
@@ -217,8 +228,9 @@ module Katello
217
228
  param_group :repo
218
229
  def create
219
230
  repo_params = repository_params
220
- unless RepositoryTypeManager.creatable_by_user?(repo_params[:content_type])
221
- msg = _("Invalid params provided - content_type must be one of %s") % RepositoryTypeManager.creatable_repository_types.keys.join(",")
231
+ unless RepositoryTypeManager.creatable_by_user?(repo_params[:content_type], false)
232
+ msg = _("Invalid params provided - content_type must be one of %s") %
233
+ RepositoryTypeManager.creatable_repository_types(false).keys.join(",")
222
234
  fail HttpErrors::UnprocessableEntity, msg
223
235
  end
224
236
 
@@ -246,7 +258,7 @@ module Katello
246
258
  param :creatable, :bool, :desc => N_("When set to 'True' repository types that are creatable will be returned")
247
259
  def repository_types
248
260
  creatable = ::Foreman::Cast.to_bool(params[:creatable])
249
- repo_types = creatable ? RepositoryTypeManager.creatable_repository_types : RepositoryTypeManager.repository_types
261
+ repo_types = creatable ? RepositoryTypeManager.creatable_repository_types : RepositoryTypeManager.enabled_repository_types
250
262
  render :json => repo_types.values
251
263
  end
252
264
 
@@ -301,36 +313,6 @@ module Katello
301
313
  raise HttpErrors::BadRequest, e.message
302
314
  end
303
315
 
304
- api :POST, "/repositories/:id/export", N_("Export a repository")
305
- param :id, :number, :desc => N_("Repository identifier"), :required => true
306
- param :export_to_iso, :bool, :desc => N_("Export to ISO format"), :required => false
307
- param :iso_mb_size, :number, :desc => N_("maximum size of each ISO in MB"), :required => false
308
- param :since, Date, :desc => N_("Optional date of last export (ex: 2010-01-01T12:00:00Z)"), :required => false
309
- def export
310
- if params[:export_to_iso].blank? && params[:iso_mb_size].present?
311
- fail HttpErrors::BadRequest, _("ISO export must be enabled when specifying ISO size")
312
- end
313
-
314
- if params[:since].present?
315
- begin
316
- params[:since].to_datetime
317
- rescue
318
- raise HttpErrors::BadRequest, _("Invalid date provided.")
319
- end
320
- end
321
-
322
- fail HttpErrors::BadRequest, _("Repository content type must be 'yum' to export.") unless @repository.content_type == 'yum'
323
-
324
- fail HttpErrors::BadRequest, _("On demand repositories cannot be exported.") if @repository.download_policy == ::Runcible::Models::YumImporter::DOWNLOAD_ON_DEMAND
325
-
326
- task = async_task(::Actions::Katello::Repository::Export, [@repository],
327
- ::Foreman::Cast.to_bool(params[:export_to_iso]),
328
- params[:since].try(:to_datetime),
329
- params[:iso_mb_size],
330
- @repository.pulp_id)
331
- respond_for_async :resource => task
332
- end
333
-
334
316
  api :PUT, "/repositories/:id", N_("Update a repository")
335
317
  param :id, :number, :required => true, :desc => N_("repository ID")
336
318
  param :name, String, :required => false
@@ -339,6 +321,14 @@ module Katello
339
321
  def update
340
322
  repo_params = repository_params
341
323
 
324
+ if @repository.generic?
325
+ generic_remote_options = generic_remote_options_hash(repo_params)
326
+ repo_params[:generic_remote_options] = generic_remote_options.to_json
327
+ RepositoryTypeManager.generic_remote_options.each do |option|
328
+ repo_params&.delete(option.name)
329
+ end
330
+ end
331
+
342
332
  sync_task(::Actions::Katello::Repository::Update, @repository.root, repo_params)
343
333
  respond_for_show(:resource => @repository)
344
334
  end
@@ -356,7 +346,7 @@ module Katello
356
346
  desc "Remove content from a repository"
357
347
  param :id, :number, :required => true, :desc => "repository ID"
358
348
  param 'ids', Array, :required => true, :desc => "Array of content ids to remove"
359
- param :content_type, RepositoryTypeManager.removable_content_types.map(&:label), :required => false, :desc => N_("content type ('deb', 'docker_manifest', 'file', 'ostree', 'rpm', 'srpm')")
349
+ param :content_type, RepositoryTypeManager.removable_content_types(false).map(&:label), :required => false, :desc => N_("content type ('deb', 'docker_manifest', 'file', 'ostree', 'rpm', 'srpm')")
360
350
  param 'sync_capsule', :bool, :desc => N_("Whether or not to sync an external capsule after upload. Default: true")
361
351
  def remove_content
362
352
  sync_capsule = ::Foreman::Cast.to_bool(params.fetch(:sync_capsule, true))
@@ -367,7 +357,7 @@ module Katello
367
357
  api :POST, "/repositories/:id/upload_content", N_("Upload content into the repository")
368
358
  param :id, :number, :required => true, :desc => N_("repository ID")
369
359
  param :content, File, :required => true, :desc => N_("Content files to upload. Can be a single file or array of files.")
370
- param :content_type, RepositoryTypeManager.uploadable_content_types.map(&:label), :required => false, :desc => N_("content type ('deb', 'docker_manifest', 'file', 'ostree', 'rpm', 'srpm')")
360
+ param :content_type, RepositoryTypeManager.uploadable_content_types(false).map(&:label), :required => false, :desc => N_("content type ('deb', 'docker_manifest', 'file', 'ostree', 'rpm', 'srpm')")
371
361
  def upload_content
372
362
  fail Katello::Errors::InvalidRepositoryContent, _("Cannot upload Container Image content.") if @repository.docker?
373
363
 
@@ -396,7 +386,7 @@ module Katello
396
386
  param :async, :bool, desc: N_("Do not wait for the ImportUpload action to finish. Default: false")
397
387
  param 'publish_repository', :bool, :desc => N_("Whether or not to regenerate the repository on disk. Default: true")
398
388
  param 'sync_capsule', :bool, :desc => N_("Whether or not to sync an external capsule after upload. Default: true")
399
- param :content_type, RepositoryTypeManager.uploadable_content_types.map(&:label), :required => false, :desc => N_("content type ('deb', 'docker_manifest', 'file', 'ostree', 'rpm', 'srpm')")
389
+ param :content_type, RepositoryTypeManager.uploadable_content_types(false).map(&:label), :required => false, :desc => N_("content type ('deb', 'docker_manifest', 'file', 'ostree', 'rpm', 'srpm')")
400
390
  param :uploads, Array, :desc => N_("Array of uploads to import") do
401
391
  param 'id', String, :required => true
402
392
  param 'content_unit_id', String
@@ -461,7 +451,7 @@ module Katello
461
451
  credential_var = "@#{content_type}"
462
452
 
463
453
  if params[credential_id]
464
- credential_value = GpgKey.readable.where(:id => params[credential_id], :organization_id => @organization).first
454
+ credential_value = ContentCredential.readable.where(:id => params[credential_id], :organization_id => @organization).first
465
455
  instance_variable_set(credential_var, credential_value)
466
456
  if instance_variable_get(credential_var).nil?
467
457
  fail HttpErrors::NotFound, _("Couldn't find %{content_type} with id '%{id}'") % { :content_type => content_type, :id => params[credential_id] }
@@ -469,16 +459,29 @@ module Katello
469
459
  end
470
460
  end
471
461
 
462
+ # rubocop:disable Metrics/CyclomaticComplexity
472
463
  def repository_params
473
464
  keys = [:download_policy, :mirror_on_sync, :arch, :verify_ssl_on_sync, :upstream_password, :upstream_username, :download_concurrency,
474
465
  :ostree_upstream_sync_depth, :ostree_upstream_sync_policy, {:os_versions => []},
475
- :deb_releases, :deb_components, :deb_architectures, :description, :http_proxy_policy, :http_proxy_id,
466
+ :deb_releases, :deb_components, :deb_architectures, :description, :http_proxy_policy, :http_proxy_id, :retain_package_versions_count,
476
467
  {:ignorable_content => []}
477
468
  ]
478
469
 
479
470
  keys += [{:docker_tags_whitelist => []}, :docker_upstream_name] if params[:action] == 'create' || @repository&.docker?
480
471
  keys += [:ansible_collection_requirements, :ansible_collection_auth_url, :ansible_collection_auth_token] if params[:action] == 'create' || @repository&.ansible_collection?
481
472
  keys += [:label, :content_type] if params[:action] == "create"
473
+
474
+ if params[:action] == 'create' || @repository&.generic?
475
+ RepositoryTypeManager.generic_remote_options.each do |option|
476
+ if option.type == Array
477
+ keys += [{option.name => []}]
478
+ elsif option.type == Hash
479
+ keys += [{option.name => {}}]
480
+ else
481
+ keys += [option.name]
482
+ end
483
+ end
484
+ end
482
485
  if params[:action] == 'create' || @repository.custom?
483
486
  keys += [:url, :gpg_key_id, :ssl_ca_cert_id, :ssl_client_cert_id, :ssl_client_key_id, :unprotected, :name,
484
487
  :checksum_type]
@@ -496,8 +499,8 @@ module Katello
496
499
  credential_value
497
500
  end
498
501
 
499
- # rubocop:disable Metrics/CyclomaticComplexity
500
502
  # rubocop:disable Metrics/PerceivedComplexity
503
+ # rubocop:disable Metrics/MethodLength
501
504
  def construct_repo_from_params(repo_params) # rubocop:disable Metrics/AbcSize
502
505
  root = @product.add_repo(repo_params.slice(:label, :name, :description, :url, :content_type, :arch, :unprotected,
503
506
  :gpg_key, :ssl_ca_cert, :ssl_client_cert, :ssl_client_key,
@@ -512,6 +515,12 @@ module Katello
512
515
  root.http_proxy_policy = repo_params[:http_proxy_policy] if repo_params.key?(:http_proxy_policy)
513
516
  root.http_proxy_id = repo_params[:http_proxy_id] if repo_params.key?(:http_proxy_id)
514
517
  root.os_versions = repo_params.fetch(:os_versions, []) if root.yum?
518
+ root.retain_package_versions_count = repo_params[:retain_package_versions_count] if root.yum? && repo_params.key?(:retain_package_versions_count)
519
+
520
+ if root.generic?
521
+ generic_remote_options = generic_remote_options_hash(repo_params)
522
+ root.generic_remote_options = generic_remote_options.to_json
523
+ end
515
524
 
516
525
  if root.ostree?
517
526
  root.ostree_upstream_sync_policy = repo_params[:ostree_upstream_sync_policy]
@@ -550,11 +559,15 @@ module Katello
550
559
  end
551
560
 
552
561
  def find_content
553
- if params[:content_type]
554
- @content = @repository.units_for_removal(params[:ids], params[:content_type])
562
+ content_type = params[:content_type]
563
+
564
+ if content_type
565
+ @content = @repository.units_for_removal(params[:ids], content_type)
555
566
  else
556
567
  @content = @repository.units_for_removal(params[:ids])
557
568
  end
569
+
570
+ RepositoryTypeManager.check_content_matches_repo_type!(@repository, @content.first.class::CONTENT_TYPE)
558
571
  end
559
572
 
560
573
  def filter_by_content_view(query, content_view_id, environment_id, is_available_for)
@@ -573,5 +586,13 @@ module Katello
573
586
  end
574
587
  query
575
588
  end
589
+
590
+ def generic_remote_options_hash(repo_params)
591
+ generic_remote_options = {}
592
+ RepositoryTypeManager.generic_remote_options(content_type: repo_params[:content_type]).each do |option|
593
+ generic_remote_options[option.name] = repo_params[option.name]
594
+ end
595
+ generic_remote_options
596
+ end
576
597
  end
577
598
  end
@@ -2,7 +2,6 @@ module Katello
2
2
  class Api::V2::UpstreamSubscriptionsController < Api::V2::ApiController
3
3
  before_action :find_organization
4
4
  before_action :check_upstream_connection
5
- before_action :deprecated, only: [:simple_content_access_eligible, :enable_simple_content_access, :disable_simple_content_access]
6
5
  resource_description do
7
6
  description "Red Hat subscriptions management platform."
8
7
  api_version 'v2'
@@ -77,29 +76,6 @@ module Katello
77
76
  render json: { status: 'OK' }
78
77
  end
79
78
 
80
- api :GET, "/organizations/:organization_id/upstream_subscriptions/simple_content_access/eligible",
81
- N_("Check if the specified organization is eligible for Simple Content Access"), :deprecated => true
82
- def simple_content_access_eligible
83
- eligible = @organization.upstream_consumer.simple_content_access_eligible?
84
- render json: { simple_content_access_eligible: eligible }
85
- end
86
-
87
- api :PUT, "/organizations/:organization_id/upstream_subscriptions/simple_content_access/enable",
88
- N_("Enable simple content access for a manifest"), :deprecated => true
89
- param :organization_id, :number, :desc => N_("Organization ID"), :required => true
90
- def enable_simple_content_access
91
- task = async_task(::Actions::Katello::Organization::SimpleContentAccess::Enable, params[:organization_id])
92
- respond_for_async :resource => task
93
- end
94
-
95
- api :PUT, "/organizations/:organization_id/upstream_subscriptions/simple_content_access/disable",
96
- N_("Disable simple content access for a manifest"), :deprecated => true
97
- param :organization_id, :number, :desc => N_("Organization ID"), :required => true
98
- def disable_simple_content_access
99
- task = async_task(::Actions::Katello::Organization::SimpleContentAccess::Disable, params[:organization_id])
100
- respond_for_async :resource => task
101
- end
102
-
103
79
  private
104
80
 
105
81
  def update_params
@@ -124,9 +100,5 @@ module Katello
124
100
  { "pool" => pool[:id], "quantity" => pool[:quantity] } if pool
125
101
  end
126
102
  end
127
-
128
- def deprecated
129
- ::Foreman::Deprecation.api_deprecation_warning("This will be removed in Katello 4.2, Please see /api/v2/simple_content_access")
130
- end
131
103
  end
132
104
  end
@@ -17,9 +17,8 @@ module Katello
17
17
  args
18
18
  end
19
19
 
20
- def append_array_of_ids(hash_params)
21
- return if registration_params['activation_key'].present? || registration_params['activation_keys'].present?
22
- super
20
+ def append_array_of_ids(*)
21
+ return
23
22
  end
24
23
  end
25
24
 
@@ -28,8 +27,8 @@ module Katello
28
27
 
29
28
  update_api(:create) do
30
29
  param :registration_command, Hash do
31
- param :activation_key, String, desc: N_('Activation key for subscription-manager client. Required for CentOS and Red Hat Enterprise Linux. Multiple keys add separated by comma, example: key1,key2,key3.'), deprecated: true
32
- param :activation_keys, Array, required: true, desc: N_('Activation key(s) for subscription-manager client. Required for CentOS and Red Hat Enterprise Linux. Required only if host group has no activation keys')
30
+ param :activation_key, String, desc: N_('Activation key for subscription-manager client, required for CentOS and Red Hat Enterprise Linux. For multiple keys use `activation_keys` param instead.'), deprecated: true
31
+ param :activation_keys, Array, desc: N_('Activation keys for subscription-manager client, required for CentOS and Red Hat Enterprise Linux. Required only if host group has no activation keys.')
33
32
  param :lifecycle_environment_id, :number, required: false, desc: N_('Lifecycle environment for the host.')
34
33
  param :force, :bool, required: false, desc: N_('Clear any previous registration and run subscription-manager with --force.')
35
34
  param :ignore_subman_errors, :bool, required: false, desc: N_('Ignore subscription-manager errors for `subscription-manager register` command')
@@ -40,6 +39,28 @@ module Katello
40
39
  included do
41
40
  prepend Overrides
42
41
  include ApiPieExtensions
42
+
43
+ before_action :check_activation_keys, only: [:create]
44
+ end
45
+
46
+ private
47
+
48
+ def check_activation_keys
49
+ return if params['registration_command']['activation_key'].present? ||
50
+ params['registration_command']['activation_keys'].present? ||
51
+ hostgroup_have_acks?
52
+
53
+ render_error 'custom_error', status: :unprocessable_entity,
54
+ locals: { message: N_('Missing activation key!') }
55
+ end
56
+
57
+ def hostgroup_have_acks?
58
+ return unless params['registration_command']['hostgroup_id']
59
+
60
+ ::Hostgroup.authorized(:view_hostgroups)
61
+ .find(params['registration_command']['hostgroup_id'])
62
+ .params['kt_activation_keys']
63
+ .present?
43
64
  end
44
65
  end
45
66
  end
@@ -7,7 +7,7 @@ module Katello
7
7
  if params['uuid']
8
8
  @host = Katello::Host::SubscriptionFacet.find_by(uuid: params['uuid'])&.host
9
9
  if @host.nil?
10
- msg = N_("Host was not found by the subscription UUID: '%s', this can happen if the host is registered already, but not to this Foreman") % params['uuid']
10
+ msg = _("Host was not found by the subscription UUID: '%s', this can happen if the host is registered already, but not to this instance") % params['uuid']
11
11
  fail ActiveRecord::RecordNotFound, msg
12
12
  end
13
13
  @host.assign_attributes(host_params('host'))
@@ -26,6 +26,31 @@ module Katello
26
26
 
27
27
  super
28
28
  end
29
+
30
+ def context_urls
31
+ super.merge(rhsm_url: rhsm_url, pulp_content_url: pulp_content_url)
32
+ end
33
+
34
+ private
35
+
36
+ def smart_proxy
37
+ @smart_proxy ||= begin
38
+ proxy = params[:url] ? SmartProxy.find_by(url: params[:url]) : SmartProxy.pulp_primary
39
+
40
+ fail Foreman::Exception, _('Smart proxy content source not found!') unless proxy
41
+ fail Foreman::Exception, _('Pulp 3 is not enabled on Smart proxy!') unless proxy.pulp3_enabled?
42
+
43
+ proxy
44
+ end
45
+ end
46
+
47
+ def rhsm_url
48
+ URI(smart_proxy.rhsm_url)
49
+ end
50
+
51
+ def pulp_content_url
52
+ smart_proxy.setting(SmartProxy::PULP3_FEATURE, 'content_app_url')
53
+ end
29
54
  end
30
55
  end
31
56
  end