Class: Katello::Api::V2::RepositoriesBulkActionsController
- Inherits:
-
ApiController
- Object
- Api::V2::BaseController
- ApiController
- Katello::Api::V2::RepositoriesBulkActionsController
show all
- Defined in:
- app/controllers/katello/api/v2/repositories_bulk_actions_controller.rb
Instance Method Summary
collapse
#empty_search_query?, #full_result_response, #resource_class, #scoped_search, #skip_session
Methods included from Rendering
#respond_for_async, #respond_for_bulk_async, #respond_for_create, #respond_for_destroy, #respond_for_index, #respond_for_show, #respond_for_status, #respond_for_update, #respond_with_template, #respond_with_template_collection, #respond_with_template_resource, #try_specific_collection_template, #try_specific_resource_template
#api_version
Instance Method Details
#destroy_repositories ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'app/controllers/katello/api/v2/repositories_bulk_actions_controller.rb', line 7
def destroy_repositories
deletion_authorized_repositories = @repositories.deletable
unpromoted_repos = Setting[:delete_repo_across_cv] ? deletion_authorized_repositories : deletion_authorized_repositories.reject { |repo| repo.promoted? && repo.content_views.generated_for_none.exists? }
unpromoted_repos_non_last_affected_repo = unpromoted_repos.reject { |repo| repo.filters.any? { |filter| filter.repositories.size == 1 } }
messages1 = format_bulk_action_messages(
:success => "",
:error => _("You do not have permissions to delete %s"),
:models => @repositories,
:authorized => deletion_authorized_repositories
)
messages2 = format_bulk_action_messages(
:success => "",
:error => _("Repository %s cannot be deleted since it has already been included in a published Content View. Use repository details page to delete"),
:models => deletion_authorized_repositories,
:authorized => unpromoted_repos
)
messages3 = format_bulk_action_messages(
:success => "",
:error => _("Repository %s cannot be deleted since it is the last affected repository in a filter. Use repository details page to delete."),
:models => unpromoted_repos,
:authorized => unpromoted_repos_non_last_affected_repo
)
errors = messages1[:error] + messages2[:error] + messages3[:error]
task = nil
if unpromoted_repos_non_last_affected_repo.any?
task = async_task(::Actions::BulkAction,
::Actions::Katello::Repository::Destroy,
unpromoted_repos_non_last_affected_repo,
remove_from_content_view_versions: Setting[:delete_repo_across_cv]
)
else
status = 400
end
respond_for_bulk_async :resource => OpenStruct.new(:task => task, :errors => errors), :status => status
end
|
#reclaim_space_from_repositories ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'app/controllers/katello/api/v2/repositories_bulk_actions_controller.rb', line 66
def reclaim_space_from_repositories
if @repositories.empty?
fail _("No repositories selected.")
end
repositories = @repositories.select { |repo| repo.download_policy == ::Katello::RootRepository::DOWNLOAD_ON_DEMAND }
if repositories.empty?
fail _("Only On Demand repositories may have space reclaimed.")
end
task = async_task(::Actions::BulkAction,
::Actions::Pulp3::Repository::ReclaimSpace,
repositories)
respond_for_async :resource => task
end
|
#sync_repositories ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'app/controllers/katello/api/v2/repositories_bulk_actions_controller.rb', line 49
def sync_repositories
syncable_repositories = @repositories.syncable.has_url
if syncable_repositories.empty?
msg = _("Unable to synchronize any repository. You either do not have the permission to"\
" synchronize or the selected repositories do not have a feed url.")
fail HttpErrors::UnprocessableEntity, msg
else
task = async_task(::Actions::BulkAction,
::Actions::Katello::Repository::Sync,
syncable_repositories)
respond_for_async :resource => task
end
end
|