Class: ForemanPuppet::Api::V2::HostsBulkActionsController

Inherits:
PuppetBaseController
  • Object
show all
Includes:
Api::V2::BulkHostsExtension
Defined in:
app/controllers/foreman_puppet/api/v2/hosts_bulk_actions_controller.rb

Instance Method Summary collapse

Instance Method Details

#change_puppet_environment ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/foreman_puppet/api/v2/hosts_bulk_actions_controller.rb', line 25

def change_puppet_environment
  error_hosts = ::BulkHostsManager.new(hosts: @hosts).change_puppet_environment(resolved_environment)

  process_bulk_response(
    error_hosts,
    success_message: format(n_(
      'Updated host: changed environment',
      'Updated hosts: changed environment',
      @hosts.count
    )),
    error_message: format(n_(
      'Failed to change environment for %{count} host',
      'Failed to change environment for %{count} hosts',
      error_hosts.count
    ), count: error_hosts.count)
  )
end

#change_puppet_proxy ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'app/controllers/foreman_puppet/api/v2/hosts_bulk_actions_controller.rb', line 47

def change_puppet_proxy
  error_hosts = ::BulkHostsManager.new(hosts: @hosts).change_puppet_proxy(@proxy, ca_proxy?)
  process_bulk_puppet_proxy_response(
    error_hosts,
    success_message: format(n_(
      'Updated host: changed %{proxy_type}',
      'Updated hosts: changed %{proxy_type}',
      @hosts.count
    ), proxy_type: proxy_type),
    error_message: format(n_(
      'Failed to change %{proxy_type} for %{count} host',
      'Failed to change %{proxy_type} for %{count} hosts',
      error_hosts.count
    ), proxy_type: proxy_type, count: error_hosts.count)
  )
end

#remove_puppet_proxy ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'app/controllers/foreman_puppet/api/v2/hosts_bulk_actions_controller.rb', line 67

def remove_puppet_proxy
  error_hosts = ::BulkHostsManager.new(hosts: @hosts).change_puppet_proxy(nil, ca_proxy?)
  process_bulk_puppet_proxy_response(
    error_hosts,
    success_message: format(n_(
      'Updated host: removed %{proxy_type}',
      'Updated hosts: removed %{proxy_type}',
      @hosts.count
    ), proxy_type: proxy_type),
    error_message: format(n_(
      'Failed to remove %{proxy_type} for %{count} host',
      'Failed to remove %{proxy_type} for %{count} hosts',
      error_hosts.count
    ), proxy_type: proxy_type, count: error_hosts.count)
  )
end