katello 3.18.0.rc2.1 → 3.18.0

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 (97) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/katello/api/v2/capsule_content_controller.rb +2 -2
  3. data/app/controllers/katello/api/v2/content_export_incrementals_controller.rb +98 -0
  4. data/app/controllers/katello/api/v2/content_exports_controller.rb +84 -0
  5. data/app/controllers/katello/api/v2/content_imports_controller.rb +59 -0
  6. data/app/controllers/katello/api/v2/content_view_versions_controller.rb +56 -94
  7. data/app/controllers/katello/api/v2/repositories_controller.rb +2 -0
  8. data/app/lib/actions/katello/applicability/hosts/bulk_generate.rb +6 -2
  9. data/app/lib/actions/katello/capsule_content/sync.rb +1 -1
  10. data/app/lib/actions/katello/content_view/promote_to_environment.rb +1 -1
  11. data/app/lib/actions/katello/content_view/publish.rb +1 -1
  12. data/app/lib/actions/katello/content_view_version/import.rb +2 -1
  13. data/app/lib/actions/katello/content_view_version/import_library.rb +17 -0
  14. data/app/lib/actions/pulp3/content_migration.rb +10 -0
  15. data/app/lib/actions/pulp3/content_migration_presenter.rb +59 -0
  16. data/app/lib/actions/pulp3/content_view/delete_repository_references.rb +1 -1
  17. data/app/lib/actions/pulp3/content_view_version/export.rb +3 -2
  18. data/app/lib/actions/pulp3/import_migration.rb +6 -1
  19. data/app/lib/actions/pulp3/orchestration/content_view_version/copy_version_units_to_library.rb +2 -1
  20. data/app/lib/actions/pulp3/orchestration/content_view_version/export.rb +13 -11
  21. data/app/lib/actions/pulp3/orchestration/content_view_version/export_library.rb +60 -0
  22. data/app/lib/actions/pulp3/orchestration/repository/import_upload.rb +16 -3
  23. data/app/lib/actions/pulp3/repository/copy_content.rb +1 -1
  24. data/app/lib/actions/pulp3/repository/delete.rb +1 -1
  25. data/app/lib/actions/pulp3/repository/save_version.rb +1 -1
  26. data/app/lib/actions/pulp3/repository/upload_tag.rb +18 -0
  27. data/app/models/katello/authorization/content_view_version.rb +25 -2
  28. data/app/models/katello/authorization/content_view_version_export_history.rb +1 -1
  29. data/app/models/katello/authorization/organization.rb +8 -0
  30. data/app/models/katello/concerns/operatingsystem_extensions.rb +2 -0
  31. data/app/models/katello/concerns/smart_proxy_extensions.rb +4 -4
  32. data/app/models/katello/content_migration_progress.rb +4 -0
  33. data/app/models/katello/content_view.rb +5 -0
  34. data/app/models/katello/content_view_history.rb +2 -1
  35. data/app/models/katello/content_view_package_filter.rb +1 -1
  36. data/app/models/katello/content_view_version_export_history.rb +6 -1
  37. data/app/models/katello/repository.rb +7 -0
  38. data/app/services/katello/pulp3/api/docker.rb +4 -0
  39. data/app/services/katello/pulp3/content_view_version/export.rb +63 -5
  40. data/app/services/katello/pulp3/content_view_version/import.rb +40 -0
  41. data/app/services/katello/pulp3/content_view_version/import_export_common.rb +0 -16
  42. data/app/services/katello/pulp3/content_view_version/import_validator.rb +26 -19
  43. data/app/services/katello/pulp3/docker_manifest.rb +1 -0
  44. data/app/services/katello/pulp3/docker_tag.rb +1 -0
  45. data/app/services/katello/pulp3/migration.rb +44 -9
  46. data/app/services/katello/pulp3/repository.rb +3 -3
  47. data/app/services/katello/pulp3/repository/docker.rb +5 -0
  48. data/app/services/katello/pulp3/repository/yum.rb +14 -8
  49. data/app/services/katello/pulp3/task.rb +4 -0
  50. data/app/services/katello/pulp3/task_group.rb +4 -0
  51. data/app/views/katello/layouts/react.html.erb +3 -2
  52. data/app/views/overrides/activation_keys/_host_tab_pane.html.erb +1 -5
  53. data/config/routes/api/v2.rb +23 -3
  54. data/db/migrate/20201119211133_pulp3_migration_progress.rb +9 -0
  55. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/bastion_katello.pot +77 -6
  56. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/de.po +17 -20
  57. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/es.po +17 -24
  58. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/fr.po +1292 -1170
  59. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/it.po +17 -20
  60. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/ja.po +858 -807
  61. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/ko.po +18 -19
  62. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/pt_BR.po +17 -24
  63. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/ru.po +17 -18
  64. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/zh_CN.po +986 -971
  65. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/zh_TW.po +19 -20
  66. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/translations.js +9 -9
  67. data/lib/katello/permission_creator.rb +23 -3
  68. data/lib/katello/tasks/pulp3_migration.rake +17 -3
  69. data/lib/katello/tasks/pulp3_migration_abort.rake +6 -1
  70. data/lib/katello/tasks/pulp3_migration_stats.rake +27 -7
  71. data/lib/katello/tasks/receptor/extract_orgs.rake +1 -1
  72. data/lib/katello/version.rb +1 -1
  73. data/locale/action_names.rb +51 -51
  74. data/locale/bn/katello.po +136 -51
  75. data/locale/cs/katello.po +136 -49
  76. data/locale/de/katello.po +136 -48
  77. data/locale/en/katello.po +136 -48
  78. data/locale/es/katello.po +136 -48
  79. data/locale/fr/katello.po +136 -48
  80. data/locale/gu/katello.po +136 -51
  81. data/locale/hi/katello.po +136 -51
  82. data/locale/it/katello.po +136 -48
  83. data/locale/ja/katello.po +136 -48
  84. data/locale/katello.pot +941 -767
  85. data/locale/kn/katello.po +136 -51
  86. data/locale/ko/katello.po +136 -48
  87. data/locale/mr/katello.po +136 -51
  88. data/locale/or/katello.po +136 -51
  89. data/locale/pa/katello.po +136 -51
  90. data/locale/pt/katello.po +136 -51
  91. data/locale/pt_BR/katello.po +136 -48
  92. data/locale/ru/katello.po +136 -48
  93. data/locale/ta/katello.po +136 -51
  94. data/locale/te/katello.po +136 -51
  95. data/locale/zh_CN/katello.po +136 -48
  96. data/locale/zh_TW/katello.po +136 -48
  97. metadata +13 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c2182a0ddbcf1ed53431397c9729009032f564090946f26a9c6bd96f12868463
4
- data.tar.gz: 835ca2d71f939a363bdae02f2fb96d873d605d066ca79ed9a2c0fe05fab35614
3
+ metadata.gz: dbd0716cd63dcfb9f135e084f2dcd07401019b45f4a0c6c4f61ddf0953fbb00b
4
+ data.tar.gz: d7ae76869fc68b2046637b8eb116f9f23048b0f5dce7042b3c65d77556d9d7c4
5
5
  SHA512:
6
- metadata.gz: bf9f57c0b833cab0e045286423e25971c652495317aa5acce6e13e99778e802dfac5504928eafda49f58d264b6410738f7c06032323e99a751b0b1c386d55725
7
- data.tar.gz: c87c2c678c0c5167b9e743b4b83c1bbdbf89d6649c4635a93e923f37ca2b516afd60839389e52a9164e395cf98d3dfc358b144ac72f20aca74f667f6f40da0ef
6
+ metadata.gz: b86b93fe297e88ea9c5bac35ae1dbc746ffd2ddcbfdd06046552cef774153182ab5938483ff6663d6d382613603066ede7a0cccc99386d3def6c63db46194f2b
7
+ data.tar.gz: 3813c0ec50e517fbe18575d033322e0ee7df5f63b5aad7abe514e62eda523339e6f3d9a54c1734e5fdc07031217fff59ece0dc17b4d02f1e28b86db93dbb13dd
@@ -93,14 +93,14 @@ module Katello
93
93
 
94
94
  def find_editable_capsule
95
95
  @capsule = SmartProxy.unscoped.authorized(:manage_capsule_content).find(params[:id])
96
- unless @capsule&.has_feature?(SmartProxy::PULP_NODE_FEATURE)
96
+ unless @capsule&.pulp_mirror?
97
97
  fail _("This request may only be performed on a Smart proxy that has the Pulp Node feature.")
98
98
  end
99
99
  end
100
100
 
101
101
  def find_capsule
102
102
  @capsule = SmartProxy.unscoped.authorized(:view_capsule_content).find(params[:id])
103
- unless @capsule&.has_feature?(SmartProxy::PULP_NODE_FEATURE)
103
+ unless @capsule&.pulp_mirror?
104
104
  fail _("This request may only be performed on a Smart proxy that has the Pulp Node feature.")
105
105
  end
106
106
  end
@@ -0,0 +1,98 @@
1
+ module Katello
2
+ class Api::V2::ContentExportIncrementalsController < Api::V2::ApiController
3
+ before_action :fail_if_not_pulp3, :only => [:version, :library]
4
+ before_action :find_exportable_organization, :only => [:library]
5
+ before_action :find_exportable_content_view_version, :only => [:version]
6
+ before_action :find_library_export_view, :only => [:library]
7
+ before_action :find_history, :only => [:version, :library]
8
+
9
+ api :POST, "/content_export_incrementals/version", N_("Performs an incremental-export of a content view version.")
10
+ param :id, :number, :desc => N_("Content view version identifier"), :required => true
11
+ param :destination_server, String, :desc => N_("Destination Server name"), :required => false
12
+ param :chunk_size_mb, :number, :desc => N_("Split the exported content into archives "\
13
+ "no greater than the specified size in megabytes."), :required => false
14
+ param :from_history_id, :number, :desc => N_("Export history identifier used for incremental export. "\
15
+ "If not provided the most recent export history will be used."), :required => false
16
+ param :fail_on_missing_content, :bool, :desc => N_("Fails if any of the repositories belonging to this version"\
17
+ " are unexportable. False by default."), :required => false
18
+ def version
19
+ tasks = async_task(::Actions::Pulp3::Orchestration::ContentViewVersion::Export,
20
+ content_view_version: @version,
21
+ destination_server: params[:destination_server],
22
+ chunk_size: params[:chunk_size_mb],
23
+ from_history: @history,
24
+ fail_on_missing_content: ::Foreman::Cast.to_bool(params[:fail_on_missing_content]))
25
+
26
+ respond_for_async :resource => tasks
27
+ end
28
+
29
+ api :POST, "/content_export_incrementals/library", N_("Performs an incremental-export of the repositories in library.")
30
+ param :organization_id, :number, :desc => N_("Organization identifier"), :required => true
31
+ param :destination_server, String, :desc => N_("Destination Server name"), :required => false
32
+ param :chunk_size_mb, :number, :desc => N_("Split the exported content into archives "\
33
+ "no greater than the specified size in megabytes."), :required => false
34
+ param :from_history_id, :number, :desc => N_("Export history identifier used for incremental export. "\
35
+ "If not provided the most recent export history will be used."), :required => false
36
+ param :fail_on_missing_content, :bool, :desc => N_("Fails if any of the repositories belonging to this organization"\
37
+ " are unexportable. False by default."), :required => false
38
+ def library
39
+ tasks = async_task(::Actions::Pulp3::Orchestration::ContentViewVersion::ExportLibrary,
40
+ @organization,
41
+ destination_server: params[:destination_server],
42
+ chunk_size: params[:chunk_size_mb],
43
+ from_history: @history,
44
+ fail_on_missing_content: ::Foreman::Cast.to_bool(params[:fail_on_missing_content]))
45
+ respond_for_async :resource => tasks
46
+ end
47
+
48
+ private
49
+
50
+ def find_exportable_content_view_version
51
+ @version = ContentViewVersion.exportable.find_by_id(params[:id])
52
+ throw_resource_not_found(name: 'content view version', id: params[:id]) if @version.blank?
53
+ @view = @version.content_view
54
+ end
55
+
56
+ def find_library_export_view
57
+ @view = ::Katello::Pulp3::ContentViewVersion::Export.find_library_export_view(destination_server: params[:destination_server],
58
+ organization: @organization,
59
+ create_by_default: false)
60
+ if @view.blank?
61
+ msg = _("Unable to incrementally export. Do a Full Export the library content "\
62
+ "before updating from the latest increment.")
63
+ fail HttpErrors::BadRequest, msg
64
+ end
65
+ end
66
+
67
+ def find_history
68
+ if params[:from_history_id].present?
69
+ @history = ::Katello::ContentViewVersionExportHistory.find(params[:from_history_id])
70
+ if @history.blank?
71
+ throw_resource_not_found(name: 'export history',
72
+ id: params[:from_history_id])
73
+ end
74
+ else
75
+ @history = ::Katello::ContentViewVersionExportHistory.
76
+ latest(@view,
77
+ destination_server: params[:destination_server])
78
+ if @history.blank?
79
+ msg = _("No existing export history was found to perform an incremental export. A full export must be performed")
80
+ fail HttpErrors::NotFound, msg
81
+ end
82
+ end
83
+ end
84
+
85
+ def find_exportable_organization
86
+ find_organization
87
+ unless @organization.can_export_library_content?
88
+ throw_resource_not_found(name: 'organization', id: params[:organization_id])
89
+ end
90
+ end
91
+
92
+ def fail_if_not_pulp3
93
+ unless SmartProxy.pulp_primary.pulp3_repository_type_support?(Katello::Repository::YUM_TYPE)
94
+ fail HttpErrors::BadRequest, _("Invalid usage for Pulp 2 repositories. Use export for Yum repositories")
95
+ end
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,84 @@
1
+ module Katello
2
+ class Api::V2::ContentExportsController < Api::V2::ApiController
3
+ before_action :fail_if_not_pulp3, :only => [:version, :library]
4
+ before_action :find_exportable_organization, :only => [:library]
5
+ before_action :find_exportable_content_view_version, :only => [:version]
6
+
7
+ api :GET, "/content_exports", N_("List export histories")
8
+ param :content_view_version_id, :number, :desc => N_("Content view version identifier"), :required => false
9
+ param :content_view_id, :number, :desc => N_("Content view identifier"), :required => false
10
+ param :destination_server, String, :desc => N_("Destination Server name"), :required => false
11
+ param :organization_id, :number, :desc => N_("Organization identifier"), :required => false
12
+ param :id, :number, :desc => N_("Content view version export history identifier"), :required => false
13
+ param_group :search, Api::V2::ApiController
14
+ add_scoped_search_description_for(ContentViewVersionExportHistory)
15
+ def index
16
+ history = ContentViewVersionExportHistory.readable
17
+ history = history.where(:id => params[:id]) unless params[:id].blank?
18
+ history = history.where(:content_view_version_id => params[:content_view_version_id]) unless params[:content_view_version_id].blank?
19
+ history = history.where(:destination_server => params[:destination_server]) unless params[:destination_server].blank?
20
+ history = history.with_organization_id(params[:organization_id]) unless params[:organization_id].blank?
21
+ history = history.with_content_view_id(params[:content_view_id]) unless params[:content_view_id].blank?
22
+ respond_with_template_collection("index", 'content_view_version_export_histories',
23
+ :collection => scoped_search(history, 'id', 'asc', resource_class: ContentViewVersionExportHistory))
24
+ end
25
+
26
+ api :GET, "/content_exports/api_status", N_("true if the export api is pulp3 ready and usable. This API is intended for use by hammer-cli only.")
27
+ def api_status
28
+ ::Foreman::Deprecation.api_deprecation_warning("/content_exports/api_status is being deprecated and will be removed in a future version of Katello.")
29
+ render json: { api_usable: SmartProxy.pulp_primary.pulp3_repository_type_support?(Katello::Repository::YUM_TYPE) }, status: :ok
30
+ end
31
+
32
+ api :POST, "/content_exports/version", N_("Performs a full-export of a content view version.")
33
+ param :id, :number, :desc => N_("Content view version identifier"), :required => true
34
+ param :destination_server, String, :desc => N_("Destination Server name"), :required => false
35
+ param :chunk_size_mb, :number, :desc => N_("Split the exported content into archives "\
36
+ "no greater than the specified size in megabytes."), :required => false
37
+ param :fail_on_missing_content, :bool, :desc => N_("Fails if any of the repositories belonging to this version"\
38
+ " are unexportable. False by default."), :required => false
39
+ def version
40
+ tasks = async_task(::Actions::Pulp3::Orchestration::ContentViewVersion::Export,
41
+ content_view_version: @version,
42
+ destination_server: params[:destination_server],
43
+ chunk_size: params[:chunk_size_mb],
44
+ fail_on_missing_content: ::Foreman::Cast.to_bool(params[:fail_on_missing_content]))
45
+ respond_for_async :resource => tasks
46
+ end
47
+
48
+ api :POST, "/content_exports/library", N_("Performs a full-export of the repositories in library.")
49
+ param :organization_id, :number, :desc => N_("Organization identifier"), :required => true
50
+ param :destination_server, String, :desc => N_("Destination Server name"), :required => false
51
+ param :chunk_size_mb, :number, :desc => N_("Split the exported content into archives "\
52
+ "no greater than the specified size in megabytes."), :required => false
53
+ param :fail_on_missing_content, :bool, :desc => N_("Fails if any of the repositories belonging to this organization"\
54
+ " are unexportable. False by default."), :required => false
55
+ def library
56
+ tasks = async_task(::Actions::Pulp3::Orchestration::ContentViewVersion::ExportLibrary,
57
+ @organization,
58
+ destination_server: params[:destination_server],
59
+ chunk_size: params[:chunk_size_mb],
60
+ fail_on_missing_content: ::Foreman::Cast.to_bool(params[:fail_on_missing_content]))
61
+ respond_for_async :resource => tasks
62
+ end
63
+
64
+ private
65
+
66
+ def find_exportable_content_view_version
67
+ @version = ContentViewVersion.exportable.find_by_id(params[:id])
68
+ throw_resource_not_found(name: 'content view version', id: params[:id]) if @version.blank?
69
+ end
70
+
71
+ def find_exportable_organization
72
+ find_organization
73
+ unless @organization.can_export_library_content?
74
+ throw_resource_not_found(name: 'organization', id: params[:organization_id])
75
+ end
76
+ end
77
+
78
+ def fail_if_not_pulp3
79
+ unless SmartProxy.pulp_primary.pulp3_repository_type_support?(Katello::Repository::YUM_TYPE)
80
+ fail HttpErrors::BadRequest, _("Invalid usage for Pulp 2 repositories. Use export for Yum repositories")
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,59 @@
1
+ module Katello
2
+ class Api::V2::ContentImportsController < Api::V2::ApiController
3
+ before_action :find_publishable_content_view, :only => [:version]
4
+ before_action :find_importable_organization, :only => [:library]
5
+ before_action :find_default_content_view, :only => [:library]
6
+
7
+ api :POST, "/content_imports/version", N_("Import a content view version")
8
+ param :content_view_id, :number, :desc => N_("Content view identifier"), :required => true
9
+ param :path, String, :desc => N_("Directory containing the exported Content View Version"), :required => true
10
+ param :metadata, Hash, :desc => N_("Metadata taken from the upstream export history for this Content View Version"), :required => true
11
+ def version
12
+ if @view.default?
13
+ fail HttpErrors::BadRequest, _("Cannot use this end point for importing to library. "\
14
+ "If you intented to upload to library, use the library endpoint.")
15
+ end
16
+
17
+ task = async_task(::Actions::Katello::ContentViewVersion::Import, @view, path: params[:path], metadata: metadata_params.to_h)
18
+ respond_for_async :resource => task
19
+ end
20
+
21
+ api :POST, "/content_imports/library", N_("Import a content view version to the library")
22
+ param :organization_id, :number, :desc => N_("Organization identifier"), :required => true
23
+ param :path, String, :desc => N_("Directory containing the exported Content View Version"), :required => true
24
+ param :metadata, Hash, :desc => N_("Metadata taken from the upstream export history for this Content View Version"), :required => true
25
+ def library
26
+ task = async_task(::Actions::Katello::ContentViewVersion::ImportLibrary, @organization, path: params[:path], metadata: metadata_params.to_h)
27
+ respond_for_async :resource => task
28
+ end
29
+
30
+ private
31
+
32
+ def find_publishable_content_view
33
+ @view = ContentView.publishable.find(params[:content_view_id])
34
+ throw_resource_not_found(name: 'content_view', id: params[:content_view_id]) if @view.blank?
35
+ end
36
+
37
+ def find_default_content_view
38
+ @view = @organization&.default_content_view
39
+ throw_resource_not_found(name: 'organization', id: params[:organization_id]) if @view.blank?
40
+ end
41
+
42
+ def find_importable_organization
43
+ find_organization
44
+ throw_resource_not_found(name: 'organization', id: params[:organization_id]) unless @organization.can_import_library_content?
45
+ end
46
+
47
+ def metadata_params
48
+ params.require(:metadata).permit(
49
+ :organization,
50
+ :content_view,
51
+ :repository_mapping,
52
+ :toc,
53
+ content_view_version: [:major, :minor]
54
+ ).tap do |nested|
55
+ nested[:repository_mapping] = params[:metadata].require(:repository_mapping).permit!
56
+ end
57
+ end
58
+ end
59
+ end
@@ -1,11 +1,13 @@
1
1
  module Katello
2
- # rubocop:disable Metrics/ClassLength
3
2
  class Api::V2::ContentViewVersionsController < Api::V2::ApiController
4
3
  include Concerns::Api::V2::BulkHostsExtensions
5
4
  include Katello::Concerns::FilteredAutoCompleteSearch
6
5
 
7
- before_action :find_content_view_version, :only => [:show, :update, :promote, :destroy, :export, :republish_repositories]
8
- before_action :find_content_view, :except => [:incremental_update]
6
+ before_action :find_authorized_katello_resource, :only => [:show, :update, :promote, :destroy, :export, :republish_repositories]
7
+ before_action :find_content_view_from_version, :only => [:show, :update, :promote, :destroy, :export, :republish_repositories]
8
+ before_action :find_optional_readable_content_view, :only => [:index]
9
+ before_action :find_publishable_content_view, :only => [:import]
10
+
9
11
  before_action :find_environment, :only => [:index]
10
12
  before_action :find_environments, :only => [:promote]
11
13
  before_action :validate_promotable, :only => [:promote]
@@ -47,7 +49,7 @@ module Katello
47
49
  api :GET, "/content_view_versions/:id", N_("Show content view version")
48
50
  param :id, :number, :desc => N_("Content view version identifier"), :required => true
49
51
  def show
50
- respond :resource => @version
52
+ respond :resource => @content_view_version
51
53
  end
52
54
 
53
55
  api :POST, "/content_view_versions/:id/promote", N_("Promote a content view version")
@@ -58,7 +60,7 @@ module Katello
58
60
  def promote
59
61
  is_force = ::Foreman::Cast.to_bool(params[:force])
60
62
  task = async_task(::Actions::Katello::ContentView::Promote,
61
- @version, @environments, is_force, params[:description])
63
+ @content_view_version, @environments, is_force, params[:description])
62
64
  respond_for_async :resource => task
63
65
  end
64
66
 
@@ -66,59 +68,54 @@ module Katello
66
68
  param :id, :number, :desc => N_("Content view version identifier"), :required => true
67
69
  param :description, String, :desc => N_("The description for the content view version"), :required => true
68
70
  def update
69
- history = @version.history.publish.successful.first
71
+ history = @content_view_version.history.publish.successful.first
70
72
  if history.blank?
71
73
  fail HttpErrors::BadRequest, _("This content view version doesn't have a history.")
72
74
  else
73
75
  history.notes = params[:description]
74
76
  history.save!
75
- respond_for_show(:resource => @version)
77
+ respond_for_show(:resource => @content_view_version)
76
78
  end
77
79
  end
78
80
 
79
81
  api :PUT, "/content_view_versions/:id/republish_repositories", N_("Forces a republish of the version's repositories' metadata")
80
82
  param :id, :number, :desc => N_("Content view version identifier"), :required => true
81
83
  def republish_repositories
82
- task = async_task(::Actions::Katello::ContentViewVersion::RepublishRepositories, @version)
84
+ task = async_task(::Actions::Katello::ContentViewVersion::RepublishRepositories, @content_view_version)
83
85
  respond_for_async :resource => task
84
86
  end
85
87
 
86
- api :GET, "/content_view_versions/export_histories", N_("Show the export history for a content view version")
87
- param :content_view_version_id, :number, :desc => N_("Content view version identifier"), :required => false
88
- param :content_view_id, :number, :desc => N_("Content view identifier"), :required => false
89
- param :destination_server, String, :desc => N_("Destination Server name"), :required => false
90
- param :organization_id, :number, :desc => N_("Organization identifier"), :required => false
91
- param_group :search, Api::V2::ApiController
92
- add_scoped_search_description_for(ContentViewVersionExportHistory)
93
- def export_histories
94
- history = ContentViewVersionExportHistory.readable
95
- history = history.where(:content_view_version_id => params[:content_view_version_id]) unless params[:content_view_version_id].blank?
96
- history = history.where(:destination_server => params[:destination_server]) unless params[:destination_server].blank?
97
- history = history.with_organization_id(params[:organization_id]) unless params[:organization_id].blank?
98
- history = history.with_content_view_id(params[:content_view_id]) unless params[:content_view_id].blank?
99
- respond_for_index(:collection => scoped_search(history, 'id', 'asc', resource_class: ContentViewVersionExportHistory),
100
- :template => '../../../api/v2/content_view_version_export_histories/index')
101
- end
102
-
103
- api :GET, "/content_view_versions/export_api_status", N_("true if the export api is pulp3 ready and usable. This API is intended for use by hammer-cli only.")
104
- def export_api_status
105
- ::Foreman::Deprecation.api_deprecation_warning("export_api_status is being deprecated and will be removed in a future version of Katello.")
106
- render json: { api_usable: SmartProxy.pulp_primary.pulp3_repository_type_support?(Katello::Repository::YUM_TYPE) }, status: :ok
107
- end
108
-
109
- api :POST, "/content_view_versions/:id/export", N_("Export a content view version")
88
+ api :POST, "/content_view_versions/:id/export", N_("Export a content view version. Relevant only for Pulp 2 repositories.")
110
89
  param :id, :number, :desc => N_("Content view version identifier"), :required => true
111
- param :destination_server, String, :desc => N_("Destination Server name, required for Pulp3")
112
- param :chunk_size_mb, :number, :desc => N_("Chunk export-tarfile into pieces of chunk_size mega bytes. Relevant only for Pulp 3 repositories"), :required => false
113
- param :export_to_iso, :bool, :desc => N_("Export to ISO format. Relevant only for Pulp 2 repositories"), :required => false
90
+ param :export_to_iso, :bool, :desc => N_("Export to ISO format."), :required => false
114
91
  param :iso_mb_size, :number, :desc => N_("maximum size of each ISO in MB. Relevant only for Pulp 2 repositories"), :required => false
115
92
  param :since, Date, :desc => N_("Optional date of last export (ex: 2010-01-01T12:00:00Z). Relevant only for Pulp 2 repositories"), :required => false
116
93
  def export
117
- task = if SmartProxy.pulp_primary.pulp3_repository_type_support?(Katello::Repository::YUM_TYPE)
118
- export_pulp_v3
119
- else
120
- export_pulp_v2
121
- end
94
+ if SmartProxy.pulp_primary.pulp3_repository_type_support?(Katello::Repository::YUM_TYPE)
95
+ fail HttpErrors::BadRequest, _("Invalid usage for Pulp 3 repositories. "\
96
+ "Use hammer content-export for Yum repositories")
97
+ end
98
+ ::Foreman::Deprecation.api_deprecation_warning("Export is being deprecated and will be removed in a future version of Katello. Use hammer content-view version export instead.")
99
+ if params[:export_to_iso].blank? && params[:iso_mb_size].present?
100
+ fail HttpErrors::BadRequest, _("ISO export must be enabled when specifying ISO size")
101
+ end
102
+
103
+ if (repos = @content_view_version.content_view.on_demand_repositories).any?
104
+ fail HttpErrors::BadRequest, _("This content view has on demand repositories that cannot be exported: %{repos}" % {repos: repos.pluck(:label).join(", ")})
105
+ end
106
+
107
+ if params[:since].present?
108
+ begin
109
+ params[:since].to_datetime
110
+ rescue
111
+ raise HttpErrors::BadRequest, _("Invalid date provided.")
112
+ end
113
+ end
114
+ task = async_task(::Actions::Katello::ContentViewVersion::Export, @content_view_version,
115
+ ::Foreman::Cast.to_bool(params[:export_to_iso]),
116
+ params[:since].try(:to_datetime),
117
+ params[:iso_mb_size])
118
+
122
119
  respond_for_async :resource => task
123
120
  end
124
121
 
@@ -134,7 +131,7 @@ module Katello
134
131
  api :DELETE, "/content_view_versions/:id", N_("Remove content view version")
135
132
  param :id, :number, :desc => N_("Content view version identifier"), :required => true
136
133
  def destroy
137
- task = async_task(::Actions::Katello::ContentViewVersion::Destroy, @version)
134
+ task = async_task(::Actions::Katello::ContentViewVersion::Destroy, @content_view_version)
138
135
  respond_for_async :resource => task
139
136
  end
140
137
 
@@ -174,7 +171,7 @@ module Katello
174
171
 
175
172
  validate_content(params[:add_content])
176
173
  resolve_dependencies = params.fetch(:resolve_dependencies, true)
177
- task = async_task(::Actions::Katello::ContentView::IncrementalUpdates, @version_environments, @composite_version_environments,
174
+ task = async_task(::Actions::Katello::ContentView::IncrementalUpdates, @content_view_version_environments, @composite_version_environments,
178
175
  params[:add_content], resolve_dependencies, hosts, params[:description])
179
176
  respond_for_async :resource => task
180
177
  end
@@ -200,17 +197,22 @@ module Katello
200
197
  find_bulk_hosts(:edit_hosts, params[:update_hosts], restrict_hosts)
201
198
  end
202
199
 
203
- def find_content_view_version
204
- @version = ContentViewVersion.find(params[:id])
205
- end
206
-
207
- def find_content_view
208
- @view = @version ? @version.content_view : ContentView.where(:id => params[:content_view_id]).first
200
+ def find_content_view_from_version
201
+ @view = @content_view_version.content_view
209
202
  if @view&.default? && params[:action] == "promote"
210
203
  fail HttpErrors::BadRequest, _("The default content view cannot be promoted")
211
204
  end
212
205
  end
213
206
 
207
+ def find_optional_readable_content_view
208
+ @view = ContentView.readable.find_by(:id => params[:content_view_id])
209
+ end
210
+
211
+ def find_publishable_content_view
212
+ @view = ContentView.publishable.find_by(:id => params[:content_view_id])
213
+ throw_resource_not_found(name: 'product', id: params[:product_id]) if @view.nil?
214
+ end
215
+
214
216
  def find_version_environments
215
217
  #Generates a data structure for incremental update:
216
218
  # [{:content_view_version => ContentViewVersion, :environments => [KTEnvironment]}]
@@ -218,7 +220,7 @@ module Katello
218
220
  list = params[:content_view_version_environments]
219
221
  fail _("At least one Content View Version must be specified") if list.empty?
220
222
 
221
- @version_environments = []
223
+ @content_view_version_environments = []
222
224
  @composite_version_environments = []
223
225
  list.each do |combination|
224
226
  version_environment = {
@@ -242,7 +244,7 @@ module Katello
242
244
  if view.composite?
243
245
  @composite_version_environments << version_environment
244
246
  else
245
- @version_environments << version_environment
247
+ @content_view_version_environments << version_environment
246
248
  @composite_version_environments += lookup_all_composites(version_environment[:content_view_version]) if params[:propagate_all_composites]
247
249
  end
248
250
  end
@@ -261,7 +263,7 @@ module Katello
261
263
  def find_version_environments_for_hosts(include_composites)
262
264
  if include_composites
263
265
  version_environments_for_systems_map = {}
264
- @version_environments.each do |version_environment|
266
+ @content_view_version_environments.each do |version_environment|
265
267
  version_environment[:content_view_version].composites.each do |composite_version|
266
268
  version_environments_for_systems_map[composite_version.id] ||= {:content_view_version => composite_version,
267
269
  :environments => composite_version.environments}
@@ -270,7 +272,7 @@ module Katello
270
272
 
271
273
  version_environments_for_systems_map.values
272
274
  else
273
- @version_environments.select { |ve| !ve[:environments].blank? }
275
+ @content_view_version_environments.select { |ve| !ve[:environments].blank? }
274
276
  end
275
277
  end
276
278
 
@@ -313,55 +315,15 @@ module Katello
313
315
 
314
316
  def validate_promotable
315
317
  fail HttpErrors::BadRequest, _("Could not find environments for promotion") if @environments.blank?
316
- return deny_access unless @environments.all?(&:promotable_or_removable?) && @version.content_view.promotable_or_removable?
318
+ return deny_access unless @environments.all?(&:promotable_or_removable?) && @content_view_version.content_view.promotable_or_removable?
317
319
  true
318
320
  end
319
321
 
320
322
  def authorize_destroy
321
- return deny_access unless @version.content_view.deletable?
323
+ return deny_access unless @content_view_version.content_view.deletable?
322
324
  true
323
325
  end
324
326
 
325
- def export_pulp_v2
326
- ::Foreman::Deprecation.api_deprecation_warning("Export is being deprecated and will be removed in a future version of Katello. Use hammer content-view version export instead.")
327
- if params[:export_to_iso].blank? && params[:iso_mb_size].present?
328
- fail HttpErrors::BadRequest, _("ISO export must be enabled when specifying ISO size")
329
- end
330
-
331
- if (repos = @version.content_view.on_demand_repositories).any?
332
- fail HttpErrors::BadRequest, _("This content view has on demand repositories that cannot be exported: %{repos}" % {repos: repos.pluck(:label).join(", ")})
333
- end
334
-
335
- if params[:since].present?
336
- begin
337
- params[:since].to_datetime
338
- rescue
339
- raise HttpErrors::BadRequest, _("Invalid date provided.")
340
- end
341
- end
342
- async_task(::Actions::Katello::ContentViewVersion::Export, @version,
343
- ::Foreman::Cast.to_bool(params[:export_to_iso]),
344
- params[:since].try(:to_datetime),
345
- params[:iso_mb_size])
346
- end
347
-
348
- def export_pulp_v3
349
- invalid_params = [:export_to_iso, :iso_mb_size, :since].reject { |param| params[param].blank? }
350
- unless invalid_params.empty?
351
- fail HttpErrors::BadRequest, _("Invalid parameters provided - %{params}. These are only relevant for Pulp 2 repositories" % { params: invalid_params.join(', ')})
352
- end
353
-
354
- if params[:destination_server].blank?
355
- fail HttpErrors::BadRequest, _("Destination Server Name required for Pulp3 repositories")
356
- end
357
-
358
- history = ::Katello::ContentViewVersionExportHistory.find(params[:from_history_id]) unless params[:from_history_id].blank?
359
-
360
- async_task(::Actions::Pulp3::Orchestration::ContentViewVersion::Export, @version, destination_server: params[:destination_server],
361
- chunk_size: params[:chunk_size_mb],
362
- from_history: history)
363
- end
364
-
365
327
  def metadata_params
366
328
  params.require(:metadata).permit(
367
329
  :organization,