katello 3.17.0 → 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.
- checksums.yaml +4 -4
- data/app/controllers/katello/api/registry/registry_proxies_controller.rb +38 -21
- data/app/controllers/katello/api/rhsm/candlepin_proxies_controller.rb +3 -1
- data/app/controllers/katello/api/v2/activation_keys_controller.rb +10 -15
- data/app/controllers/katello/api/v2/capsule_content_controller.rb +2 -2
- data/app/controllers/katello/api/v2/content_credentials_controller.rb +1 -8
- data/app/controllers/katello/api/v2/content_export_incrementals_controller.rb +98 -0
- data/app/controllers/katello/api/v2/content_exports_controller.rb +84 -0
- data/app/controllers/katello/api/v2/content_imports_controller.rb +59 -0
- data/app/controllers/katello/api/v2/content_view_components_controller.rb +31 -14
- data/app/controllers/katello/api/v2/content_view_filters_controller.rb +17 -8
- data/app/controllers/katello/api/v2/content_view_repositories_controller.rb +1 -0
- data/app/controllers/katello/api/v2/content_view_versions_controller.rb +65 -71
- data/app/controllers/katello/api/v2/content_views_controller.rb +37 -26
- data/app/controllers/katello/api/v2/environments_controller.rb +8 -8
- data/app/controllers/katello/api/v2/gpg_keys_controller.rb +5 -5
- data/app/controllers/katello/api/v2/host_collections_controller.rb +19 -16
- data/app/controllers/katello/api/v2/host_debs_controller.rb +1 -0
- data/app/controllers/katello/api/v2/host_errata_controller.rb +2 -2
- data/app/controllers/katello/api/v2/hosts_bulk_actions_controller.rb +35 -6
- data/app/controllers/katello/api/v2/products_bulk_actions_controller.rb +1 -1
- data/app/controllers/katello/api/v2/products_controller.rb +9 -9
- data/app/controllers/katello/api/v2/repositories_bulk_actions_controller.rb +1 -1
- data/app/controllers/katello/api/v2/repositories_controller.rb +10 -5
- data/app/controllers/katello/api/v2/repository_sets_controller.rb +24 -14
- data/app/controllers/katello/api/v2/subscriptions_controller.rb +1 -1
- data/app/controllers/katello/api/v2/sync_plans_controller.rb +8 -9
- data/app/controllers/katello/api/v2/upstream_subscriptions_controller.rb +9 -2
- data/app/controllers/katello/concerns/api/v2/authorization.rb +19 -5
- data/app/controllers/katello/concerns/api/v2/bulk_hosts_extensions.rb +22 -18
- data/app/controllers/katello/concerns/api/v2/registration_controller_extensions.rb +21 -0
- data/app/controllers/katello/concerns/api/v2/repository_content_controller.rb +1 -1
- data/app/controllers/katello/concerns/organizations_controller_extensions.rb +2 -1
- data/app/controllers/katello/concerns/registration_controller_extensions.rb +16 -0
- data/app/helpers/katello/katello_urls_helper.rb +5 -2
- data/app/lib/actions/candlepin/product/content_create.rb +2 -0
- data/app/lib/actions/candlepin/product/content_update.rb +2 -0
- data/app/lib/actions/helpers/smart_proxy_sync_history_helper.rb +24 -0
- data/app/lib/actions/katello/applicability/hosts/bulk_generate.rb +6 -2
- data/app/lib/actions/katello/capsule_content/sync.rb +1 -1
- data/app/lib/actions/katello/capsule_content/sync_capsule.rb +16 -7
- data/app/lib/actions/katello/content_view/promote_to_environment.rb +1 -1
- data/app/lib/actions/katello/content_view/publish.rb +9 -9
- data/app/lib/actions/katello/content_view_version/import.rb +8 -13
- data/app/lib/actions/katello/content_view_version/import_library.rb +17 -0
- data/app/lib/actions/katello/content_view_version/incremental_update.rb +18 -3
- data/app/lib/actions/katello/host/hypervisors_update.rb +18 -0
- data/app/lib/actions/katello/host/update_system_purpose.rb +31 -0
- data/app/lib/actions/katello/host/upload_package_profile.rb +3 -1
- data/app/lib/actions/katello/host/upload_profiles.rb +8 -6
- data/app/lib/actions/katello/organization/manifest_delete.rb +0 -1
- data/app/lib/actions/katello/organization/manifest_import.rb +0 -1
- data/app/lib/actions/katello/organization/manifest_refresh.rb +0 -1
- data/app/lib/actions/katello/product/content_create.rb +7 -6
- data/app/lib/actions/katello/repository/filtered_index_content.rb +10 -1
- data/app/lib/actions/katello/repository/import_upload.rb +4 -1
- data/app/lib/actions/katello/repository/remove_content.rb +1 -1
- data/app/lib/actions/katello/repository/sync.rb +3 -1
- data/app/lib/actions/katello/repository/update.rb +5 -1
- data/app/lib/actions/katello/repository/upload_files.rb +1 -0
- data/app/lib/actions/middleware/record_smart_proxy_sync_history.rb +15 -0
- data/app/lib/actions/pulp/consumer/sync_capsule.rb +4 -2
- data/app/lib/actions/pulp/repository/distributor_publish.rb +1 -1
- data/app/lib/actions/pulp3/capsule_content/sync.rb +1 -0
- data/app/lib/actions/pulp3/content_migration.rb +10 -0
- data/app/lib/actions/pulp3/content_migration_presenter.rb +59 -0
- data/app/lib/actions/pulp3/content_view/delete_repository_references.rb +1 -1
- data/app/lib/actions/pulp3/content_view_version/create_importer.rb +7 -3
- data/app/lib/actions/pulp3/content_view_version/export.rb +7 -1
- data/app/lib/actions/pulp3/content_view_version/import.rb +7 -3
- data/app/lib/actions/pulp3/import_migration.rb +6 -1
- data/app/lib/actions/pulp3/orchestration/content_view_version/copy_version_units_to_library.rb +2 -1
- data/app/lib/actions/pulp3/orchestration/content_view_version/export.rb +38 -14
- data/app/lib/actions/pulp3/orchestration/content_view_version/export_library.rb +60 -0
- data/app/lib/actions/pulp3/orchestration/content_view_version/import.rb +16 -10
- data/app/lib/actions/pulp3/orchestration/repository/generate_metadata.rb +4 -1
- data/app/lib/actions/pulp3/orchestration/repository/import_upload.rb +16 -3
- data/app/lib/actions/pulp3/repository/commit_upload.rb +2 -1
- data/app/lib/actions/pulp3/repository/copy_content.rb +1 -1
- data/app/lib/actions/pulp3/repository/delete.rb +1 -1
- data/app/lib/actions/pulp3/repository/save_artifact.rb +1 -1
- data/app/lib/actions/pulp3/repository/save_version.rb +1 -1
- data/app/lib/actions/pulp3/repository/upload_tag.rb +18 -0
- data/app/lib/katello/resources/candlepin/consumer.rb +2 -2
- data/app/lib/katello/resources/candlepin/owner.rb +5 -0
- data/app/lib/katello/resources/candlepin/upstream_consumer.rb +6 -0
- data/app/lib/katello/resources/registry.rb +3 -3
- data/app/models/katello/authorization/activation_key.rb +4 -0
- data/app/models/katello/authorization/content_view.rb +13 -0
- data/app/models/katello/authorization/content_view_component.rb +15 -0
- data/app/models/katello/authorization/content_view_filter.rb +15 -0
- data/app/models/katello/authorization/content_view_version.rb +25 -2
- data/app/models/katello/authorization/content_view_version_export_history.rb +1 -1
- data/app/models/katello/authorization/gpg_key.rb +12 -4
- data/app/models/katello/authorization/lifecycle_environment.rb +8 -0
- data/app/models/katello/authorization/organization.rb +8 -0
- data/app/models/katello/authorization/sync_plan.rb +16 -0
- data/app/models/katello/concerns/operatingsystem_extensions.rb +2 -0
- data/app/models/katello/concerns/organization_extensions.rb +4 -5
- data/app/models/katello/concerns/smart_proxy_extensions.rb +6 -4
- data/app/models/katello/content_migration_progress.rb +4 -0
- data/app/models/katello/content_view.rb +30 -4
- data/app/models/katello/content_view_component.rb +2 -0
- data/app/models/katello/content_view_filter.rb +5 -0
- data/app/models/katello/content_view_history.rb +2 -1
- data/app/models/katello/content_view_package_filter.rb +1 -1
- data/app/models/katello/content_view_puppet_module.rb +8 -0
- data/app/models/katello/content_view_repository.rb +13 -1
- data/app/models/katello/content_view_version_export_history.rb +8 -1
- data/app/models/katello/glue/candlepin/pool.rb +9 -14
- data/app/models/katello/glue/pulp/repo.rb +8 -0
- data/app/models/katello/gpg_key.rb +1 -1
- data/app/models/katello/ping.rb +8 -3
- data/app/models/katello/repository.rb +33 -0
- data/app/models/katello/root_repository.rb +26 -1
- data/app/models/katello/smart_proxy_sync_history.rb +8 -0
- data/app/services/katello/candlepin/event_handler.rb +2 -0
- data/app/services/katello/candlepin/message_handler.rb +34 -0
- data/app/services/katello/candlepin/upstream_consumer.rb +28 -0
- data/app/services/katello/host_status_manager.rb +9 -0
- data/app/services/katello/pulp3/api/apt.rb +57 -0
- data/app/services/katello/pulp3/api/core.rb +8 -0
- data/app/services/katello/pulp3/api/docker.rb +4 -0
- data/app/services/katello/pulp3/content_view_version/export.rb +125 -8
- data/app/services/katello/pulp3/content_view_version/import.rb +39 -34
- data/app/services/katello/pulp3/content_view_version/import_export_common.rb +6 -16
- data/app/services/katello/pulp3/content_view_version/import_validator.rb +114 -0
- data/app/services/katello/pulp3/deb.rb +38 -0
- data/app/services/katello/pulp3/docker_manifest.rb +1 -0
- data/app/services/katello/pulp3/docker_tag.rb +1 -0
- data/app/services/katello/pulp3/migration.rb +51 -10
- data/app/services/katello/pulp3/pulp_content_unit.rb +5 -0
- data/app/services/katello/pulp3/repository.rb +10 -4
- data/app/services/katello/pulp3/repository/ansible_collection.rb +9 -0
- data/app/services/katello/pulp3/repository/apt.rb +63 -0
- data/app/services/katello/pulp3/repository/docker.rb +9 -0
- data/app/services/katello/pulp3/repository/yum.rb +14 -9
- data/app/services/katello/pulp3/repository_mirror.rb +9 -4
- data/app/services/katello/pulp3/task.rb +4 -0
- data/app/services/katello/pulp3/task_group.rb +4 -0
- data/app/services/katello/repository_type.rb +2 -1
- data/app/services/katello/smart_proxy_helper.rb +9 -0
- data/app/views/dashboard/_subscription_widget.html.erb +0 -5
- data/app/views/foreman/hosts/_registration.html.erb +12 -0
- data/app/views/katello/api/v2/content_view_version_export_histories/show.json.rabl +1 -1
- data/app/views/katello/api/v2/content_views/base.json.rabl +1 -0
- data/app/views/katello/api/v2/repositories/base.json.rabl +1 -1
- data/app/views/katello/layouts/react.html.erb +3 -2
- data/app/views/overrides/activation_keys/_host_tab_pane.html.erb +1 -5
- data/app/views/overrides/organizations/_index_row_override.html.erb +1 -1
- data/config/routes/api/v2.rb +24 -2
- data/config/routes/overrides.rb +1 -0
- data/db/migrate/20200929200357_create_katello_smart_proxy_sync_history.rb +13 -0
- data/db/migrate/20201008204114_add_os_versions_to_katello_root_repositories.rb +5 -0
- data/db/migrate/20201012172713_remove_gpg_key_perms.rb +23 -0
- data/db/migrate/20201012192035_add_metadata_to_katello_content_view_version_export_history.rb +5 -0
- data/db/migrate/20201021150008_add_import_only_to_katello_content_view.rb +5 -0
- data/db/migrate/20201119211133_pulp3_migration_progress.rb +9 -0
- data/db/seeds.d/111-upgrade_tasks.rb +2 -1
- data/engines/bastion/app/assets/javascripts/bastion/components/notification.service.js +1 -1
- data/engines/bastion/app/assets/javascripts/bastion/components/nutupane.factory.js +8 -13
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/bulk/content-hosts-bulk-system-purpose-modal.controller.js +112 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/bulk/views/content-hosts-bulk-system-purpose-modal.html +78 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content-host-modal-helper.service.js +11 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content-hosts.controller.js +5 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content/content-host-debs-installed.controller.js +2 -42
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/views/content-hosts.html +4 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/content-views.controller.js +6 -2
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/content-view-details.controller.js +12 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/views/content-view-details.html +7 -7
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/views/content-view-info.html +7 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/new/content-view-new.controller.js +17 -3
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/new/views/content-view-new.html +16 -2
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/views/content-views.html +5 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/host-collections/details/host-collection-details.controller.js +4 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/host-collections/details/views/host-collection-info.html +6 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/hosts/host-bulk-action.factory.js +2 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/bastion_katello.pot +92 -19
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/de.po +17 -20
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/es.po +17 -24
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/fr.po +1292 -1170
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/it.po +17 -20
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/ja.po +858 -807
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/ko.po +18 -19
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/pt_BR.po +17 -24
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/ru.po +17 -18
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/zh_CN.po +986 -971
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/zh_TW.po +19 -20
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/translations.js +9 -9
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/bulk/products-bulk-advanced-sync-modal.controller.js +6 -7
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/repository-details-info.controller.js +168 -155
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-info.html +17 -2
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/new/new-repository.controller.js +125 -113
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/new/views/new-repository.html +15 -3
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/os-versions.service.js +46 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/repository-types.service.js +8 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/views/content-access-mode-banner.html +1 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/sync-plans/details/views/sync-plan-details.html +1 -1
- data/lib/katello/engine.rb +2 -0
- data/lib/katello/permission_creator.rb +98 -69
- data/lib/katello/permissions/host_permissions.rb +1 -0
- data/lib/katello/plugin.rb +10 -2
- data/lib/katello/repository_types/deb.rb +9 -1
- data/lib/katello/tasks/pulp3_migration.rake +17 -3
- data/lib/katello/tasks/pulp3_migration_abort.rake +22 -0
- data/lib/katello/tasks/pulp3_migration_stats.rake +41 -0
- data/lib/katello/tasks/receptor/extract_orgs.rake +1 -1
- data/lib/katello/tasks/reset.rake +2 -1
- data/lib/katello/tasks/upgrades/3.18/add_cvv_export_history_metadata.rb +18 -0
- data/lib/katello/version.rb +1 -1
- data/locale/action_names.rb +51 -44
- data/locale/bn/katello.po +279 -55
- data/locale/cs/katello.po +278 -51
- data/locale/de/katello.po +279 -52
- data/locale/en/katello.po +278 -49
- data/locale/es/katello.po +279 -51
- data/locale/fr/katello.po +279 -51
- data/locale/gu/katello.po +279 -55
- data/locale/hi/katello.po +279 -55
- data/locale/it/katello.po +279 -51
- data/locale/ja/katello.po +279 -52
- data/locale/katello.pot +1379 -971
- data/locale/kn/katello.po +279 -55
- data/locale/ko/katello.po +279 -51
- data/locale/mr/katello.po +279 -55
- data/locale/or/katello.po +279 -55
- data/locale/pa/katello.po +279 -55
- data/locale/pt/katello.po +278 -52
- data/locale/pt_BR/katello.po +279 -51
- data/locale/ru/katello.po +279 -51
- data/locale/ta/katello.po +279 -55
- data/locale/te/katello.po +279 -55
- data/locale/zh_CN/katello.po +279 -51
- data/locale/zh_TW/katello.po +279 -52
- data/webpack/components/ActionableDetail.js +2 -1
- data/webpack/components/Search/Search.js +1 -1
- data/webpack/components/Table/MainTable.js +6 -2
- data/webpack/components/Table/TableWrapper.js +46 -9
- data/webpack/scenes/ContentViews/ContentViewSelectors.js +7 -3
- data/webpack/scenes/ContentViews/ContentViewsConstants.js +8 -0
- data/webpack/scenes/ContentViews/ContentViewsPage.js +2 -9
- data/webpack/scenes/ContentViews/Details/ContentViewDetailActions.js +25 -3
- data/webpack/scenes/ContentViews/Details/ContentViewDetailSelectors.js +14 -4
- data/webpack/scenes/ContentViews/Details/ContentViewDetails.js +2 -1
- data/webpack/scenes/ContentViews/Details/Repositories/ContentCounts.js +56 -0
- data/webpack/scenes/ContentViews/Details/Repositories/ContentViewRepositories.js +169 -0
- data/webpack/scenes/ContentViews/Details/Repositories/LastSync.js +47 -0
- data/webpack/scenes/ContentViews/Details/Repositories/RepoAddedStatus.js +17 -0
- data/webpack/scenes/ContentViews/Details/Repositories/RepoIcon.js +23 -0
- data/webpack/scenes/ContentViews/Details/Repositories/SelectableDropdown.js +49 -0
- data/webpack/scenes/ContentViews/Details/Repositories/__tests__/contentViewDetailRepos.fixtures.json +154 -0
- data/webpack/scenes/ContentViews/Details/Repositories/__tests__/contentViewDetailRepos.test.js +131 -0
- data/webpack/scenes/ContentViews/Details/__tests__/contentViewDetail.test.js +3 -0
- data/webpack/scenes/ContentViews/Table/ContentViewsTable.js +4 -1
- data/webpack/scenes/ContentViews/__tests__/contentViewPage.test.js +2 -2
- data/webpack/scenes/Subscriptions/Manifest/ManageManifestModal.js +29 -19
- data/webpack/scenes/Subscriptions/Manifest/ManifestActions.js +17 -0
- data/webpack/scenes/Subscriptions/Manifest/ManifestConstants.js +4 -0
- data/webpack/scenes/Subscriptions/Manifest/SimpleContentAccess.js +19 -2
- data/webpack/scenes/Subscriptions/Manifest/__tests__/SimpleContentAccess.test.js +9 -1
- data/webpack/scenes/Subscriptions/Manifest/index.js +2 -1
- data/webpack/scenes/Subscriptions/SubscriptionConstants.js +1 -1
- data/webpack/scenes/Subscriptions/SubscriptionReducer.js +3 -0
- data/webpack/scenes/Subscriptions/SubscriptionsPage.js +8 -2
- data/webpack/scenes/Subscriptions/SubscriptionsSelectors.js +3 -0
- data/webpack/scenes/Subscriptions/__tests__/SubscriptionsPage.test.js +3 -0
- data/webpack/scenes/Subscriptions/__tests__/SubscriptionsSelectors.test.js +6 -0
- data/webpack/scenes/Subscriptions/__tests__/__snapshots__/SubscriptionsSelectors.test.js.snap +6 -0
- data/webpack/scenes/Subscriptions/components/SubscriptionsToolbar/SubscriptionsToolbar.js +1 -13
- data/webpack/test-utils/react-testing-lib-wrapper.js +3 -0
- metadata +74 -13
- data/webpack/__mocks__/foremanReact/components/common/Fill/GlobalFill.js +0 -3
@@ -1,7 +1,8 @@
|
|
1
1
|
module Katello
|
2
2
|
class Api::V2::ContentViewComponentsController < Api::V2::ApiController
|
3
|
-
before_action :find_composite_content_view
|
4
|
-
before_action :
|
3
|
+
before_action :find_composite_content_view, :only => [:show, :index]
|
4
|
+
before_action :find_composite_content_view_for_edit, :only => [:add_components, :remove_components, :update]
|
5
|
+
before_action :find_authorized_katello_resource, :only => [:show, :update]
|
5
6
|
|
6
7
|
wrap_parameters :include => %w(composite_content_view_id content_view_version_id content_view_id latest)
|
7
8
|
|
@@ -13,7 +14,7 @@ module Katello
|
|
13
14
|
end
|
14
15
|
|
15
16
|
def index_response
|
16
|
-
results = @view.content_view_components
|
17
|
+
results = @view.content_view_components.readable
|
17
18
|
{
|
18
19
|
:results => results.uniq,
|
19
20
|
:subtotal => results.count,
|
@@ -31,15 +32,26 @@ module Katello
|
|
31
32
|
param :latest, :bool, :desc => N_("true if the latest version of the component's content view is desired")
|
32
33
|
end
|
33
34
|
def add_components
|
35
|
+
@view.add_components(authorized_components)
|
36
|
+
@view.save!
|
37
|
+
respond_for_index(:collection => index_response, :template => "index")
|
38
|
+
end
|
39
|
+
|
40
|
+
private def authorized_components
|
34
41
|
components = params.require(:components).map do |component|
|
35
42
|
component = component.permit([:latest, :content_view_version_id, :content_view_id])
|
36
43
|
options = {}
|
37
44
|
options[:latest] = ::Foreman::Cast.to_bool(component[:latest]) if component.key?(:latest)
|
38
|
-
options.merge(component.slice(:content_view_version_id, :content_view_id))
|
45
|
+
options.merge(component.slice(:content_view_version_id, :content_view_id)).with_indifferent_access
|
46
|
+
end
|
47
|
+
|
48
|
+
components.each do |component|
|
49
|
+
if component[:content_view_version_id] && Katello::ContentViewVersion.readable.find_by(id: component[:content_view_version_id]).nil?
|
50
|
+
throw_resource_not_found(name: 'content_view_version', id: component[:content_view_version_id])
|
51
|
+
elsif component[:content_view_id] && Katello::ContentView.readable.find_by(id: component[:content_view_id]).nil?
|
52
|
+
throw_resource_not_found(name: 'content_view', id: component[:content_view_id])
|
53
|
+
end
|
39
54
|
end
|
40
|
-
@view.add_components(components)
|
41
|
-
@view.save!
|
42
|
-
respond_for_index(:collection => index_response, :template => "index")
|
43
55
|
end
|
44
56
|
|
45
57
|
api :PUT, "/content_views/:composite_content_view_id/content_view_components/remove",
|
@@ -56,7 +68,7 @@ module Katello
|
|
56
68
|
param :composite_content_view_id, :number, :desc => N_("composite content view numeric identifier"), :required => true
|
57
69
|
param :id, :number, :desc => N_("content view component ID. Identifier of the component association"), :required => true
|
58
70
|
def show
|
59
|
-
respond :resource => @
|
71
|
+
respond :resource => @content_view_component
|
60
72
|
end
|
61
73
|
|
62
74
|
api :PUT, "/content_views/:composite_content_view_id/content_view_components/:id",
|
@@ -67,6 +79,9 @@ module Katello
|
|
67
79
|
param :latest, :bool, :desc => N_("true if the latest version of the components content view is desired")
|
68
80
|
def update
|
69
81
|
cvv_id = component_params[:content_view_version_id]
|
82
|
+
if cvv_id && Katello::ContentViewVersion.readable.find_by(id: cvv_id).nil?
|
83
|
+
throw_resource_not_found(name: 'content view version', id: cvv_id)
|
84
|
+
end
|
70
85
|
if component_params.key?(:latest) && component_params.key?(:content_view_version_id)
|
71
86
|
latest = ::Foreman::Cast.to_bool(component_params[:latest])
|
72
87
|
if latest && cvv_id.present?
|
@@ -75,22 +90,24 @@ module Katello
|
|
75
90
|
end
|
76
91
|
end
|
77
92
|
if cvv_id.present?
|
78
|
-
@
|
93
|
+
@content_view_component.update!(:content_view_version_id => cvv_id, :latest => false)
|
79
94
|
elsif component_params.key?(:latest)
|
80
95
|
latest = ::Foreman::Cast.to_bool(component_params[:latest])
|
81
|
-
@
|
96
|
+
@content_view_component.update!(:content_view_version_id => nil, :latest => latest)
|
82
97
|
end
|
83
|
-
respond :resource => @
|
98
|
+
respond :resource => @content_view_component
|
84
99
|
end
|
85
100
|
|
86
101
|
private
|
87
102
|
|
88
103
|
def find_composite_content_view
|
89
|
-
@view = ContentView.composite.non_default.
|
104
|
+
@view = ContentView.composite.non_default.readable.find_by(id: params[:composite_content_view_id])
|
105
|
+
throw_resource_not_found(name: 'composite content view', id: params[:composite_content_view_id]) if @view.nil?
|
90
106
|
end
|
91
107
|
|
92
|
-
def
|
93
|
-
@
|
108
|
+
def find_composite_content_view_for_edit
|
109
|
+
@view = ContentView.composite.non_default.editable.find_by(id: params[:composite_content_view_id])
|
110
|
+
throw_resource_not_found(name: 'composite content view', id: params[:composite_content_view_id]) if @view.nil?
|
94
111
|
end
|
95
112
|
|
96
113
|
def component_params
|
@@ -2,9 +2,9 @@ module Katello
|
|
2
2
|
class Api::V2::ContentViewFiltersController < Api::V2::ApiController
|
3
3
|
include Katello::Concerns::FilteredAutoCompleteSearch
|
4
4
|
|
5
|
-
before_action :
|
5
|
+
before_action :find_editable_content_view, :only => [:create, :update, :destroy]
|
6
|
+
before_action :find_readable_content_view, :only => [:show, :index, :auto_complete_search]
|
6
7
|
before_action :find_filter, :except => [:index, :create, :auto_complete_search]
|
7
|
-
|
8
8
|
wrap_parameters :include => (ContentViewFilter.attribute_names + %w(repository_ids))
|
9
9
|
|
10
10
|
api :get, "/content_views/:content_view_id/filters", N_("list filters")
|
@@ -73,7 +73,7 @@ module Katello
|
|
73
73
|
respond :resource => @filter
|
74
74
|
end
|
75
75
|
|
76
|
-
api :
|
76
|
+
api :delefind_filterte, "/content_views/:content_view_id/filters/:id", N_("delete a filter")
|
77
77
|
api :delete, "/content_view_filters/:id", N_("delete a filter")
|
78
78
|
param :content_view_id, :number, :desc => N_("content view identifier")
|
79
79
|
param :id, :number, :desc => N_("filter identifier"), :required => true
|
@@ -84,18 +84,27 @@ module Katello
|
|
84
84
|
|
85
85
|
private
|
86
86
|
|
87
|
-
def
|
88
|
-
@view = ContentView.
|
87
|
+
def find_readable_content_view
|
88
|
+
@view = ContentView.readable.find_by(id: params[:content_view_id]) if params[:content_view_id]
|
89
|
+
throw_resource_not_found(name: 'content view', id: params[:content_view_id]) if params[:content_view_id] && @view.nil?
|
90
|
+
end
|
91
|
+
|
92
|
+
def find_editable_content_view
|
93
|
+
@view = ContentView.editable.find_by(id: params[:content_view_id]) if params[:content_view_id]
|
94
|
+
throw_resource_not_found(name: 'content view', id: params[:content_view_id]) if params[:content_view_id] && @view.nil?
|
89
95
|
end
|
90
96
|
|
91
97
|
def find_filter
|
92
98
|
if @view
|
93
99
|
@filter = @view.filters.find_by(:id => params[:id])
|
94
|
-
|
100
|
+
elsif params[:action] == 'show'
|
101
|
+
@filter = ContentViewFilter.readable.find_by(id: params[:id])
|
102
|
+
@view = @filter&.content_view
|
95
103
|
else
|
96
|
-
@filter = ContentViewFilter.
|
97
|
-
@view = @filter
|
104
|
+
@filter = ContentViewFilter.editable.find_by(id: params[:id])
|
105
|
+
@view = @filter&.content_view
|
98
106
|
end
|
107
|
+
fail HttpErrors::NotFound, _("Couldn't find ContentViewFilter with id=%s") % params[:id] unless @filter
|
99
108
|
end
|
100
109
|
|
101
110
|
def filter_params
|
@@ -25,6 +25,7 @@ module Katello
|
|
25
25
|
SQL
|
26
26
|
|
27
27
|
query = Katello::Repository.readable.in_default_view.in_organization(@organization)
|
28
|
+
query = query.with_type(params[:content_type]) if params[:content_type]
|
28
29
|
# Use custom sort to perform the join and order since we need to order by specific content_view
|
29
30
|
# and the ORDER BY query needs access to the katello_content_view_repositories table
|
30
31
|
custom_sort = ->(sort_query) { sort_query.joins(:root).joins(join_query).order(order_query) }
|
@@ -3,8 +3,11 @@ module Katello
|
|
3
3
|
include Concerns::Api::V2::BulkHostsExtensions
|
4
4
|
include Katello::Concerns::FilteredAutoCompleteSearch
|
5
5
|
|
6
|
-
before_action :
|
7
|
-
before_action :
|
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
|
+
|
8
11
|
before_action :find_environment, :only => [:index]
|
9
12
|
before_action :find_environments, :only => [:promote]
|
10
13
|
before_action :validate_promotable, :only => [:promote]
|
@@ -46,7 +49,7 @@ module Katello
|
|
46
49
|
api :GET, "/content_view_versions/:id", N_("Show content view version")
|
47
50
|
param :id, :number, :desc => N_("Content view version identifier"), :required => true
|
48
51
|
def show
|
49
|
-
respond :resource => @
|
52
|
+
respond :resource => @content_view_version
|
50
53
|
end
|
51
54
|
|
52
55
|
api :POST, "/content_view_versions/:id/promote", N_("Promote a content view version")
|
@@ -57,7 +60,7 @@ module Katello
|
|
57
60
|
def promote
|
58
61
|
is_force = ::Foreman::Cast.to_bool(params[:force])
|
59
62
|
task = async_task(::Actions::Katello::ContentView::Promote,
|
60
|
-
@
|
63
|
+
@content_view_version, @environments, is_force, params[:description])
|
61
64
|
respond_for_async :resource => task
|
62
65
|
end
|
63
66
|
|
@@ -65,96 +68,70 @@ module Katello
|
|
65
68
|
param :id, :number, :desc => N_("Content view version identifier"), :required => true
|
66
69
|
param :description, String, :desc => N_("The description for the content view version"), :required => true
|
67
70
|
def update
|
68
|
-
history = @
|
71
|
+
history = @content_view_version.history.publish.successful.first
|
69
72
|
if history.blank?
|
70
73
|
fail HttpErrors::BadRequest, _("This content view version doesn't have a history.")
|
71
74
|
else
|
72
75
|
history.notes = params[:description]
|
73
76
|
history.save!
|
74
|
-
respond_for_show(:resource => @
|
77
|
+
respond_for_show(:resource => @content_view_version)
|
75
78
|
end
|
76
79
|
end
|
77
80
|
|
78
81
|
api :PUT, "/content_view_versions/:id/republish_repositories", N_("Forces a republish of the version's repositories' metadata")
|
79
82
|
param :id, :number, :desc => N_("Content view version identifier"), :required => true
|
80
83
|
def republish_repositories
|
81
|
-
task = async_task(::Actions::Katello::ContentViewVersion::RepublishRepositories, @
|
84
|
+
task = async_task(::Actions::Katello::ContentViewVersion::RepublishRepositories, @content_view_version)
|
82
85
|
respond_for_async :resource => task
|
83
86
|
end
|
84
87
|
|
85
|
-
api :
|
86
|
-
param :content_view_version_id, :number, :desc => N_("Content view version identifier"), :required => false
|
87
|
-
param :content_view_id, :number, :desc => N_("Content view identifier"), :required => false
|
88
|
-
param :destination_server, String, :desc => N_("Destination Server name"), :required => false
|
89
|
-
param :organization_id, :number, :desc => N_("Organization identifier"), :required => false
|
90
|
-
param_group :search, Api::V2::ApiController
|
91
|
-
add_scoped_search_description_for(ContentViewVersionExportHistory)
|
92
|
-
def export_histories
|
93
|
-
history = ContentViewVersionExportHistory.readable
|
94
|
-
history = history.where(:content_view_version_id => params[:content_view_version_id]) unless params[:content_view_version_id].blank?
|
95
|
-
history = history.where(:destination_server => params[:destination_server]) unless params[:destination_server].blank?
|
96
|
-
history = history.with_organization_id(params[:organization_id]) unless params[:organization_id].blank?
|
97
|
-
history = history.with_content_view_id(params[:content_view_id]) unless params[:content_view_id].blank?
|
98
|
-
respond_for_index(:collection => scoped_search(history, 'id', 'asc', resource_class: ContentViewVersionExportHistory),
|
99
|
-
:template => '../../../api/v2/content_view_version_export_histories/index')
|
100
|
-
end
|
101
|
-
|
102
|
-
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.")
|
103
89
|
param :id, :number, :desc => N_("Content view version identifier"), :required => true
|
104
|
-
param :
|
105
|
-
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
|
106
91
|
param :iso_mb_size, :number, :desc => N_("maximum size of each ISO in MB. Relevant only for Pulp 2 repositories"), :required => false
|
107
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
|
108
93
|
def export
|
109
94
|
if SmartProxy.pulp_primary.pulp3_repository_type_support?(Katello::Repository::YUM_TYPE)
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
end
|
118
|
-
|
119
|
-
task = async_task(::Actions::Pulp3::Orchestration::ContentViewVersion::Export, @version, destination_server: params[:destination_server])
|
120
|
-
else
|
121
|
-
::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.")
|
122
|
-
if params[:export_to_iso].blank? && params[:iso_mb_size].present?
|
123
|
-
fail HttpErrors::BadRequest, _("ISO export must be enabled when specifying ISO size")
|
124
|
-
end
|
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
|
125
102
|
|
126
|
-
|
127
|
-
|
128
|
-
|
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
|
129
106
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
end
|
107
|
+
if params[:since].present?
|
108
|
+
begin
|
109
|
+
params[:since].to_datetime
|
110
|
+
rescue
|
111
|
+
raise HttpErrors::BadRequest, _("Invalid date provided.")
|
136
112
|
end
|
137
|
-
task = async_task(::Actions::Katello::ContentViewVersion::Export, @version,
|
138
|
-
::Foreman::Cast.to_bool(params[:export_to_iso]),
|
139
|
-
params[:since].try(:to_datetime),
|
140
|
-
params[:iso_mb_size])
|
141
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])
|
142
118
|
|
143
119
|
respond_for_async :resource => task
|
144
120
|
end
|
145
121
|
|
146
122
|
api :POST, "/content_view_versions/import", N_("Import a content view version")
|
147
123
|
param :content_view_id, :number, :desc => N_("Content view identifier"), :required => true
|
148
|
-
param :path, String, :desc => N_("
|
124
|
+
param :path, String, :desc => N_("Directory containing the exported Content View Version"), :required => true
|
125
|
+
param :metadata, Hash, :desc => N_("Metadata taken from the upstream export history for this Content View Version"), :required => true
|
149
126
|
def import
|
150
|
-
task = async_task(::Actions::Katello::ContentViewVersion::Import, @view, path: params[:path])
|
127
|
+
task = async_task(::Actions::Katello::ContentViewVersion::Import, @view, path: params[:path], metadata: metadata_params&.to_h)
|
151
128
|
respond_for_async :resource => task
|
152
129
|
end
|
153
130
|
|
154
131
|
api :DELETE, "/content_view_versions/:id", N_("Remove content view version")
|
155
132
|
param :id, :number, :desc => N_("Content view version identifier"), :required => true
|
156
133
|
def destroy
|
157
|
-
task = async_task(::Actions::Katello::ContentViewVersion::Destroy, @
|
134
|
+
task = async_task(::Actions::Katello::ContentViewVersion::Destroy, @content_view_version)
|
158
135
|
respond_for_async :resource => task
|
159
136
|
end
|
160
137
|
|
@@ -194,7 +171,7 @@ module Katello
|
|
194
171
|
|
195
172
|
validate_content(params[:add_content])
|
196
173
|
resolve_dependencies = params.fetch(:resolve_dependencies, true)
|
197
|
-
task = async_task(::Actions::Katello::ContentView::IncrementalUpdates, @
|
174
|
+
task = async_task(::Actions::Katello::ContentView::IncrementalUpdates, @content_view_version_environments, @composite_version_environments,
|
198
175
|
params[:add_content], resolve_dependencies, hosts, params[:description])
|
199
176
|
respond_for_async :resource => task
|
200
177
|
end
|
@@ -220,17 +197,22 @@ module Katello
|
|
220
197
|
find_bulk_hosts(:edit_hosts, params[:update_hosts], restrict_hosts)
|
221
198
|
end
|
222
199
|
|
223
|
-
def
|
224
|
-
@
|
225
|
-
end
|
226
|
-
|
227
|
-
def find_content_view
|
228
|
-
@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
|
229
202
|
if @view&.default? && params[:action] == "promote"
|
230
203
|
fail HttpErrors::BadRequest, _("The default content view cannot be promoted")
|
231
204
|
end
|
232
205
|
end
|
233
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
|
+
|
234
216
|
def find_version_environments
|
235
217
|
#Generates a data structure for incremental update:
|
236
218
|
# [{:content_view_version => ContentViewVersion, :environments => [KTEnvironment]}]
|
@@ -238,7 +220,7 @@ module Katello
|
|
238
220
|
list = params[:content_view_version_environments]
|
239
221
|
fail _("At least one Content View Version must be specified") if list.empty?
|
240
222
|
|
241
|
-
@
|
223
|
+
@content_view_version_environments = []
|
242
224
|
@composite_version_environments = []
|
243
225
|
list.each do |combination|
|
244
226
|
version_environment = {
|
@@ -262,7 +244,7 @@ module Katello
|
|
262
244
|
if view.composite?
|
263
245
|
@composite_version_environments << version_environment
|
264
246
|
else
|
265
|
-
@
|
247
|
+
@content_view_version_environments << version_environment
|
266
248
|
@composite_version_environments += lookup_all_composites(version_environment[:content_view_version]) if params[:propagate_all_composites]
|
267
249
|
end
|
268
250
|
end
|
@@ -281,7 +263,7 @@ module Katello
|
|
281
263
|
def find_version_environments_for_hosts(include_composites)
|
282
264
|
if include_composites
|
283
265
|
version_environments_for_systems_map = {}
|
284
|
-
@
|
266
|
+
@content_view_version_environments.each do |version_environment|
|
285
267
|
version_environment[:content_view_version].composites.each do |composite_version|
|
286
268
|
version_environments_for_systems_map[composite_version.id] ||= {:content_view_version => composite_version,
|
287
269
|
:environments => composite_version.environments}
|
@@ -290,7 +272,7 @@ module Katello
|
|
290
272
|
|
291
273
|
version_environments_for_systems_map.values
|
292
274
|
else
|
293
|
-
@
|
275
|
+
@content_view_version_environments.select { |ve| !ve[:environments].blank? }
|
294
276
|
end
|
295
277
|
end
|
296
278
|
|
@@ -333,13 +315,25 @@ module Katello
|
|
333
315
|
|
334
316
|
def validate_promotable
|
335
317
|
fail HttpErrors::BadRequest, _("Could not find environments for promotion") if @environments.blank?
|
336
|
-
return deny_access unless @environments.all?(&:promotable_or_removable?) && @
|
318
|
+
return deny_access unless @environments.all?(&:promotable_or_removable?) && @content_view_version.content_view.promotable_or_removable?
|
337
319
|
true
|
338
320
|
end
|
339
321
|
|
340
322
|
def authorize_destroy
|
341
|
-
return deny_access unless @
|
323
|
+
return deny_access unless @content_view_version.content_view.deletable?
|
342
324
|
true
|
343
325
|
end
|
326
|
+
|
327
|
+
def metadata_params
|
328
|
+
params.require(:metadata).permit(
|
329
|
+
:organization,
|
330
|
+
:content_view,
|
331
|
+
:repository_mapping,
|
332
|
+
:toc,
|
333
|
+
content_view_version: [:major, :minor]
|
334
|
+
).tap do |nested|
|
335
|
+
nested[:repository_mapping] = params[:metadata].require(:repository_mapping).permit!
|
336
|
+
end
|
337
|
+
end
|
344
338
|
end
|
345
339
|
end
|
@@ -3,7 +3,8 @@ module Katello
|
|
3
3
|
include Concerns::Authorization::Api::V2::ContentViewsController
|
4
4
|
include Katello::Concerns::FilteredAutoCompleteSearch
|
5
5
|
|
6
|
-
before_action :
|
6
|
+
before_action :find_authorized_katello_resource, :except => [:index, :create, :copy, :auto_complete_search]
|
7
|
+
before_action :ensure_non_default, :except => [:index, :create, :copy, :auto_complete_search]
|
7
8
|
before_action :find_organization, :only => [:create]
|
8
9
|
before_action :find_optional_organization, :only => [:index, :auto_complete_search]
|
9
10
|
before_action :find_environment, :only => [:index, :remove_from_environment]
|
@@ -20,6 +21,7 @@ module Katello
|
|
20
21
|
param :component_ids, Array, :desc => N_("List of component content view version ids for composite views")
|
21
22
|
param :auto_publish, :bool, :desc => N_("Enable/Disable auto publish of composite view")
|
22
23
|
param :solve_dependencies, :bool, :desc => N_("Solve RPM dependencies by default on Content View publish, defaults to false")
|
24
|
+
param :import_only, :bool, :desc => N_("Designate this Content View for importing from upstream servers only. Defaults to false") if pulp3_yum?
|
23
25
|
end
|
24
26
|
|
25
27
|
def filtered_associations
|
@@ -29,6 +31,10 @@ module Katello
|
|
29
31
|
}
|
30
32
|
end
|
31
33
|
|
34
|
+
def self.pulp3_yum?
|
35
|
+
SmartProxy.pulp_primary&.pulp3_repository_type_support?(Katello::Repository::YUM_TYPE)
|
36
|
+
end
|
37
|
+
|
32
38
|
api :GET, "/organizations/:organization_id/content_views", N_("List content views")
|
33
39
|
api :GET, "/content_views", N_("List content views")
|
34
40
|
param :organization_id, :number, :desc => N_("organization identifier")
|
@@ -66,12 +72,16 @@ module Katello
|
|
66
72
|
param :composite, :bool, :desc => N_("Composite content view")
|
67
73
|
param_group :content_view
|
68
74
|
def create
|
69
|
-
|
75
|
+
if ::Foreman::Cast.to_bool(params[:content_view][:import_only])
|
76
|
+
fail HttpErrors::BadRequest, _("Import-only content views will be available in a future version.") unless self.class.pulp3_yum?
|
77
|
+
end
|
78
|
+
|
79
|
+
@content_view = ContentView.create!(view_params) do |view|
|
70
80
|
view.organization = @organization
|
71
81
|
view.label ||= labelize_params(params[:content_view])
|
72
82
|
end
|
73
83
|
|
74
|
-
respond :resource => @
|
84
|
+
respond :resource => @content_view
|
75
85
|
end
|
76
86
|
|
77
87
|
api :PUT, "/content_views/:id", N_("Update a content view")
|
@@ -79,8 +89,8 @@ module Katello
|
|
79
89
|
param :name, String, :desc => N_("New name for the content view")
|
80
90
|
param_group :content_view
|
81
91
|
def update
|
82
|
-
sync_task(::Actions::Katello::ContentView::Update, @
|
83
|
-
respond :resource => @
|
92
|
+
sync_task(::Actions::Katello::ContentView::Update, @content_view, view_params)
|
93
|
+
respond :resource => @content_view.reload
|
84
94
|
end
|
85
95
|
|
86
96
|
api :POST, "/content_views/:id/publish", N_("Publish a content view")
|
@@ -93,7 +103,7 @@ module Katello
|
|
93
103
|
param :rpm_filenames, Array, of: String, :desc => N_("list of rpm filename strings to include in published version"), :required => true
|
94
104
|
end
|
95
105
|
def publish
|
96
|
-
if params[:repos_units].present? && @
|
106
|
+
if params[:repos_units].present? && @content_view.composite?
|
97
107
|
fail HttpErrors::BadRequest, _("Directly setting package lists on composite content views is not allowed. Please " \
|
98
108
|
"update the components, then re-publish the composite.")
|
99
109
|
end
|
@@ -105,7 +115,7 @@ module Katello
|
|
105
115
|
fail HttpErrors::BadRequest, _("Both major and minor parameters have to be used to override a CV version")
|
106
116
|
end
|
107
117
|
|
108
|
-
task = async_task(::Actions::Katello::ContentView::Publish, @
|
118
|
+
task = async_task(::Actions::Katello::ContentView::Publish, @content_view, params[:description],
|
109
119
|
:major => params[:major],
|
110
120
|
:minor => params[:minor],
|
111
121
|
:repos_units => params[:repos_units])
|
@@ -115,7 +125,7 @@ module Katello
|
|
115
125
|
api :GET, "/content_views/:id", N_("Show a content view")
|
116
126
|
param :id, :number, :desc => N_("content view numeric identifier"), :required => true
|
117
127
|
def show
|
118
|
-
respond :resource => @
|
128
|
+
respond :resource => @content_view
|
119
129
|
end
|
120
130
|
|
121
131
|
api :GET, "/content_views/:id/available_puppet_modules",
|
@@ -123,9 +133,9 @@ module Katello
|
|
123
133
|
param :id, :number, :desc => N_("content view numeric identifier"), :required => true
|
124
134
|
param :name, String, :desc => N_("module name to restrict modules for"), :required => false
|
125
135
|
def available_puppet_modules
|
126
|
-
current_cv_puppet_modules = @
|
136
|
+
current_cv_puppet_modules = @content_view.content_view_puppet_modules.where("uuid is NOT NULL")
|
127
137
|
current_uuids = current_cv_puppet_modules.pluck(:uuid)
|
128
|
-
repositories = @
|
138
|
+
repositories = @content_view.organization.library.puppet_repositories
|
129
139
|
query = PuppetModule.in_repositories(repositories)
|
130
140
|
selected_latest_versions = []
|
131
141
|
if params[:name]
|
@@ -154,9 +164,9 @@ module Katello
|
|
154
164
|
N_("Get puppet modules names that are available to be added to the content view")
|
155
165
|
param :id, :number, :desc => N_("content view numeric identifier"), :required => true
|
156
166
|
def available_puppet_module_names
|
157
|
-
current_names = @
|
167
|
+
current_names = @content_view.content_view_puppet_modules.where("name is NOT NULL").pluck(:name)
|
158
168
|
|
159
|
-
repos = @
|
169
|
+
repos = @content_view.organization.library.puppet_repositories
|
160
170
|
|
161
171
|
modules = PuppetModule.in_repositories(repos)
|
162
172
|
modules = modules.where('name NOT in (?)', current_names) if current_names.present?
|
@@ -169,12 +179,12 @@ module Katello
|
|
169
179
|
param :id, :number, :desc => N_("content view numeric identifier"), :required => true
|
170
180
|
param :environment_id, :number, :desc => N_("environment numeric identifier"), :required => true
|
171
181
|
def remove_from_environment
|
172
|
-
unless @
|
182
|
+
unless @content_view.environments.include?(@environment)
|
173
183
|
fail HttpErrors::BadRequest, _("Content view '%{view}' is not in lifecycle environment '%{env}'.") %
|
174
|
-
{view: @
|
184
|
+
{view: @content_view.name, env: @environment.name}
|
175
185
|
end
|
176
186
|
|
177
|
-
task = async_task(::Actions::Katello::ContentView::RemoveFromEnvironment, @
|
187
|
+
task = async_task(::Actions::Katello::ContentView::RemoveFromEnvironment, @content_view, @environment)
|
178
188
|
respond_for_async :resource => task
|
179
189
|
end
|
180
190
|
|
@@ -190,7 +200,7 @@ module Katello
|
|
190
200
|
cv_envs = ContentViewEnvironment.where(:environment_id => params[:environment_ids],
|
191
201
|
:content_view_id => params[:id]
|
192
202
|
)
|
193
|
-
versions = @
|
203
|
+
versions = @content_view.versions.where(:id => params[:content_view_version_ids])
|
194
204
|
|
195
205
|
if cv_envs.empty? && versions.empty?
|
196
206
|
fail _("There either were no environments nor versions specified or there were invalid environments/versions specified. "\
|
@@ -205,14 +215,14 @@ module Katello
|
|
205
215
|
options[:content_view_versions] = versions
|
206
216
|
options[:content_view_environments] = cv_envs
|
207
217
|
|
208
|
-
task = async_task(::Actions::Katello::ContentView::Remove, @
|
218
|
+
task = async_task(::Actions::Katello::ContentView::Remove, @content_view, options)
|
209
219
|
respond_for_async :resource => task
|
210
220
|
end
|
211
221
|
|
212
222
|
api :DELETE, "/content_views/:id", N_("Delete a content view")
|
213
223
|
param :id, :number, :desc => N_("content view numeric identifier"), :required => true
|
214
224
|
def destroy
|
215
|
-
task = async_task(::Actions::Katello::ContentView::Destroy, @
|
225
|
+
task = async_task(::Actions::Katello::ContentView::Destroy, @content_view)
|
216
226
|
respond_for_async :resource => task
|
217
227
|
end
|
218
228
|
|
@@ -220,25 +230,26 @@ module Katello
|
|
220
230
|
param :id, :number, :desc => N_("Content view numeric identifier"), :required => true
|
221
231
|
param :name, String, :required => true, :desc => N_("New content view name")
|
222
232
|
def copy
|
223
|
-
|
233
|
+
@content_view = Katello::ContentView.readable.find_by(:id => params[:id])
|
234
|
+
throw_resource_not_found(name: 'content_view', id: params[:id]) if @content_view.blank?
|
235
|
+
ensure_non_default
|
236
|
+
new_content_view = @content_view.copy(params[:content_view][:name])
|
224
237
|
respond_for_create :resource => new_content_view
|
225
238
|
end
|
226
239
|
|
227
240
|
private
|
228
241
|
|
229
|
-
def
|
230
|
-
@
|
231
|
-
|
232
|
-
if @view.default? && !%w(show history).include?(params[:action])
|
242
|
+
def ensure_non_default
|
243
|
+
if @content_view.default? && !%w(show history).include?(params[:action])
|
233
244
|
fail HttpErrors::BadRequest, _("The default content view cannot be edited, published, or deleted.")
|
234
245
|
end
|
235
246
|
end
|
236
247
|
|
237
248
|
def view_params
|
238
|
-
attrs = [:name, :description, :force_puppet_environment, :auto_publish, :solve_dependencies,
|
249
|
+
attrs = [:name, :description, :force_puppet_environment, :auto_publish, :solve_dependencies, :import_only,
|
239
250
|
:default, :created_at, :updated_at, :next_version, {:component_ids => []}]
|
240
251
|
attrs.push(:label, :composite) if action_name == "create"
|
241
|
-
if (!@
|
252
|
+
if (!@content_view || !@content_view.composite?)
|
242
253
|
attrs.push({:repository_ids => []}, :repository_ids)
|
243
254
|
end
|
244
255
|
params.require(:content_view).permit(*attrs).to_h
|
@@ -246,7 +257,7 @@ module Katello
|
|
246
257
|
|
247
258
|
def find_environment
|
248
259
|
return if !params.key?(:environment_id) && params[:action] == "index"
|
249
|
-
@environment = KTEnvironment.find(params[:environment_id])
|
260
|
+
@environment = KTEnvironment.readable.find(params[:environment_id])
|
250
261
|
end
|
251
262
|
|
252
263
|
def add_use_latest_records(module_records, selected_latest_versions)
|