Class: Katello::Api::V2::ProductsBulkActionsController
- Inherits:
-
ApiController
- Object
- Api::V2::BaseController
- ApiController
- Katello::Api::V2::ProductsBulkActionsController
show all
- Defined in:
- app/controllers/katello/api/v2/products_bulk_actions_controller.rb
Instance Method Summary
collapse
#check_katello_agent_not_disabled, #deprecate_katello_agent, #empty_search_query?, #full_result_response, #katello_agent_removal_release, #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_products ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'app/controllers/katello/api/v2/products_bulk_actions_controller.rb', line 8
def destroy_products
deletable_products = @products.deletable
deletable_products.each do |prod|
async_task(::Actions::Katello::Product::Destroy, prod)
end
messages = format_bulk_action_messages(
:success => _("Successfully initiated removal of %s product(s)"),
:error => _("You were not allowed to delete %s"),
:models => @products,
:authorized => deletable_products
)
respond_for_show :template => 'bulk_action', :resource_name => 'common',
:resource => { 'displayMessages' => messages }
end
|
#sync_products ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'app/controllers/katello/api/v2/products_bulk_actions_controller.rb', line 30
def sync_products
skip_metadata_check = ::Foreman::Cast.to_bool(params[:skip_metadata_check])
validate_contents = ::Foreman::Cast.to_bool(params[:validate_contents])
syncable_products = @products.syncable
syncable_roots = RootRepository.where(:product_id => syncable_products).has_url
syncable_roots = syncable_roots.skipable_metadata_check if skip_metadata_check || validate_contents
syncable_roots = syncable_roots.where.not(:download_policy => ::Katello::RootRepository::DOWNLOAD_ON_DEMAND) if validate_contents
syncable_repositories = Katello::Repository.where(:root_id => syncable_roots).in_default_view
fail _("No syncable repositories found for selected products and options.") if syncable_roots.empty?
task = async_task(::Actions::BulkAction,
::Actions::Katello::Repository::Sync,
syncable_repositories,
:skip_metadata_check => skip_metadata_check,
:validate_contents => validate_contents)
respond_for_async :resource => task
end
|
#update_http_proxy ⇒ Object
70
71
72
73
74
75
76
77
|
# File 'app/controllers/katello/api/v2/products_bulk_actions_controller.rb', line 70
def update_http_proxy
task = async_task(::Actions::Katello::Product::UpdateHttpProxy,
@products.editable,
params[:http_proxy_policy],
@http_proxy)
respond_for_async :resource => task
end
|
#update_sync_plans ⇒ Object
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
# File 'app/controllers/katello/api/v2/products_bulk_actions_controller.rb', line 82
def update_sync_plans
editable_products = @products.editable
editable_products.each do |product|
product.sync_plan_id = params[:plan_id]
product.save!
end
messages = format_bulk_action_messages(
:success => _("Successfully changed sync plan for %s product(s)"),
:error => _("You were not allowed to change sync plan for %s"),
:models => @products,
:authorized => editable_products
)
respond_for_show :template => 'bulk_action', :resource_name => 'common',
:resource => { 'displayMessages' => messages }
end
|
#verify_checksum_products ⇒ Object
54
55
56
57
58
59
60
61
62
63
64
|
# File 'app/controllers/katello/api/v2/products_bulk_actions_controller.rb', line 54
def verify_checksum_products
repairable_products = @products.syncable
repairable_roots = RootRepository.where(:product_id => repairable_products).has_url.select { |r| r.library_instance }.uniq
repairable_repositories = Katello::Repository.where(:root_id => repairable_roots)
task = async_task(::Actions::BulkAction,
::Actions::Katello::Repository::VerifyChecksum,
repairable_repositories)
respond_for_async :resource => task
end
|