foreman_discovery 25.1.0 → 25.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/foreman_discovery/locale/ca/foreman_discovery.js +13 -4
  3. data/app/assets/javascripts/foreman_discovery/locale/cs_CZ/foreman_discovery.js +13 -4
  4. data/app/assets/javascripts/foreman_discovery/locale/de/foreman_discovery.js +13 -4
  5. data/app/assets/javascripts/foreman_discovery/locale/es/foreman_discovery.js +14 -5
  6. data/app/assets/javascripts/foreman_discovery/locale/fr/foreman_discovery.js +17 -8
  7. data/app/assets/javascripts/foreman_discovery/locale/gl/foreman_discovery.js +13 -4
  8. data/app/assets/javascripts/foreman_discovery/locale/it/foreman_discovery.js +13 -4
  9. data/app/assets/javascripts/foreman_discovery/locale/ja/foreman_discovery.js +17 -8
  10. data/app/assets/javascripts/foreman_discovery/locale/ka/foreman_discovery.js +13 -4
  11. data/app/assets/javascripts/foreman_discovery/locale/ko/foreman_discovery.js +136 -130
  12. data/app/assets/javascripts/foreman_discovery/locale/pt_BR/foreman_discovery.js +13 -4
  13. data/app/assets/javascripts/foreman_discovery/locale/ru/foreman_discovery.js +13 -4
  14. data/app/assets/javascripts/foreman_discovery/locale/sv_SE/foreman_discovery.js +13 -4
  15. data/app/assets/javascripts/foreman_discovery/locale/zh_CN/foreman_discovery.js +18 -9
  16. data/app/assets/javascripts/foreman_discovery/locale/zh_TW/foreman_discovery.js +13 -4
  17. data/lib/foreman_discovery/version.rb +1 -1
  18. data/locale/ca/LC_MESSAGES/foreman_discovery.mo +0 -0
  19. data/locale/ca/foreman_discovery.po +13 -4
  20. data/locale/cs_CZ/LC_MESSAGES/foreman_discovery.mo +0 -0
  21. data/locale/cs_CZ/foreman_discovery.po +13 -4
  22. data/locale/de/LC_MESSAGES/foreman_discovery.mo +0 -0
  23. data/locale/de/foreman_discovery.po +13 -4
  24. data/locale/es/LC_MESSAGES/foreman_discovery.mo +0 -0
  25. data/locale/es/foreman_discovery.po +17 -8
  26. data/locale/foreman_discovery.pot +136 -137
  27. data/locale/fr/LC_MESSAGES/foreman_discovery.mo +0 -0
  28. data/locale/fr/foreman_discovery.po +17 -8
  29. data/locale/gl/LC_MESSAGES/foreman_discovery.mo +0 -0
  30. data/locale/gl/foreman_discovery.po +13 -4
  31. data/locale/it/LC_MESSAGES/foreman_discovery.mo +0 -0
  32. data/locale/it/foreman_discovery.po +13 -4
  33. data/locale/ja/LC_MESSAGES/foreman_discovery.mo +0 -0
  34. data/locale/ja/foreman_discovery.po +17 -8
  35. data/locale/ka/LC_MESSAGES/foreman_discovery.mo +0 -0
  36. data/locale/ka/foreman_discovery.po +13 -4
  37. data/locale/ko/LC_MESSAGES/foreman_discovery.mo +0 -0
  38. data/locale/ko/foreman_discovery.po +136 -130
  39. data/locale/pt_BR/LC_MESSAGES/foreman_discovery.mo +0 -0
  40. data/locale/pt_BR/foreman_discovery.po +13 -4
  41. data/locale/ru/LC_MESSAGES/foreman_discovery.mo +0 -0
  42. data/locale/ru/foreman_discovery.po +13 -4
  43. data/locale/sv_SE/LC_MESSAGES/foreman_discovery.mo +0 -0
  44. data/locale/sv_SE/foreman_discovery.po +13 -4
  45. data/locale/zh_CN/LC_MESSAGES/foreman_discovery.mo +0 -0
  46. data/locale/zh_CN/foreman_discovery.po +20 -9
  47. data/locale/zh_TW/LC_MESSAGES/foreman_discovery.mo +0 -0
  48. data/locale/zh_TW/foreman_discovery.po +13 -4
  49. metadata +3 -27
  50. data/app/assets/javascripts/foreman_discovery/locale/en/foreman_discovery.js +0 -835
  51. data/app/assets/javascripts/foreman_discovery/locale/en_GB/foreman_discovery.js +0 -835
  52. data/app/controllers/discovered_hosts_controller.rb.orig +0 -354
  53. data/locale/ca/foreman_discovery.edit.po +0 -1122
  54. data/locale/cs_CZ/foreman_discovery.edit.po +0 -1120
  55. data/locale/de/foreman_discovery.edit.po +0 -1129
  56. data/locale/en/LC_MESSAGES/foreman_discovery.mo +0 -0
  57. data/locale/en/foreman_discovery.edit.po +0 -1115
  58. data/locale/en/foreman_discovery.po +0 -834
  59. data/locale/en_GB/LC_MESSAGES/foreman_discovery.mo +0 -0
  60. data/locale/en_GB/foreman_discovery.edit.po +0 -1125
  61. data/locale/en_GB/foreman_discovery.po +0 -839
  62. data/locale/es/foreman_discovery.edit.po +0 -1130
  63. data/locale/fr/foreman_discovery.edit.po +0 -1126
  64. data/locale/gl/foreman_discovery.edit.po +0 -1120
  65. data/locale/it/foreman_discovery.edit.po +0 -1123
  66. data/locale/ja/foreman_discovery.edit.po +0 -1119
  67. data/locale/ka/foreman_discovery.edit.po +0 -1120
  68. data/locale/ko/foreman_discovery.edit.po +0 -1119
  69. data/locale/pt_BR/foreman_discovery.edit.po +0 -1132
  70. data/locale/ru/foreman_discovery.edit.po +0 -1131
  71. data/locale/sv_SE/foreman_discovery.edit.po +0 -1123
  72. data/locale/zh_CN/foreman_discovery.edit.po +0 -1117
  73. data/locale/zh_TW/foreman_discovery.edit.po +0 -1120
@@ -1,354 +0,0 @@
1
- class DiscoveredHostsController < ::ApplicationController
2
- include Foreman::Controller::Parameters::DiscoveredHost
3
- include Foreman::Controller::AutoCompleteSearch
4
- include Foreman::Controller::TaxonomyMultiple
5
- include Foreman::Controller::DiscoveredExtensions
6
- include ActionView::Helpers::NumberHelper
7
-
8
- before_action :find_by_name, :only => %w[edit update destroy refresh_facts convert reboot auto_provision]
9
- before_action :find_by_name_incl_subnet, :only => [:show]
10
- before_action :find_multiple, :only => [:multiple_destroy, :submit_multiple_destroy, :multiple_reboot, :submit_multiple_reboot, :multiple_auto_provision, :submit_multiple_auto_provision]
11
- before_action :taxonomy_scope, :only => [:edit]
12
- before_action :check_for_subnet, :only => [:reboot, :auto_provision, :submit_multiple_reboot, :submit_multiple_auto_provision]
13
-
14
- around_action :skip_bullet, :only => [:edit]
15
-
16
- helper :hosts
17
- if defined?(ForemanPuppet)
18
- helper ForemanPuppet::HostsHelper
19
- helper ForemanPuppet::HostsAndHostgroupsHelper
20
- helper ForemanPuppet::PuppetclassesHelper
21
- helper ForemanPuppet::PuppetclassLookupKeysHelper
22
- end
23
-
24
- layout 'layouts/application'
25
-
26
- def model_of_controller
27
- Host::Discovered
28
- end
29
-
30
- def index
31
- @hosts = resource_base_search_and_page.includes([
32
- :location,
33
- :organization,
34
- :model,
35
- :discovery_attribute_set
36
- ], {:interfaces => :subnet})
37
- fact_array = @hosts.collect do |host|
38
- [host.id, Hash[host.fact_values.joins(:fact_name).where('fact_names.name' => Setting['discovery_fact_column']).pluck(:name, :value)]]
39
- end
40
- @host_facts = Hash[fact_array]
41
- end
42
-
43
- def show
44
- # filter graph time range
45
- @range = nil
46
- # summary report text
47
- @report_summary = nil
48
- resolver = ForemanDiscovery::FactToCategoryResolver.new(@host)
49
- @categories_names = ForemanDiscovery::FactToCategoryResolver::CATEGORIES_NAMES
50
- @categories = resolver.categories
51
- @interfaces = resolver.interfaces
52
- end
53
-
54
- def destroy
55
- @host.destroy
56
- redirect_to :action => 'index'
57
- end
58
-
59
- def edit
60
- quick = params.delete(:quick_submit)
61
- @host = ::ForemanDiscovery::HostConverter.to_managed(@host, true, false, discovered_host_params_host) unless @host.nil?
62
- setup_host_class_variables
63
- @override_taxonomy = true
64
- # need to permit this one but don't know how
65
- if quick
66
- perform_update(@host, _('Successfully provisioned %s') % @host.name)
67
- else
68
- @host.build = true
69
- render :template => 'discovered_hosts/edit'
70
- end
71
- end
72
-
73
- def update
74
- @host = ::ForemanDiscovery::HostConverter.to_managed(@host, true, true, managed_host_params_host)
75
- forward_url_options
76
-
77
- @override_taxonomy = true
78
- perform_update(@host)
79
- end
80
-
81
- def perform_update(host, success_message = nil)
82
- Taxonomy.no_taxonomy_scope do
83
- ::ForemanDiscovery::HostConverter.set_build_clean_facts(host)
84
- ::ForemanDiscovery::HostConverter.unused_ip_for_host(host)
85
- if host.save
86
- host_path = Setting['host_details_ui'] ? host_details_page_path(host) : host_path(host)
87
- success_options = { :success_redirect => host_path, :redirect_xhr => request.xhr? }
88
- success_options[:success_msg] = success_message if success_message
89
- process_success success_options
90
- else
91
- taxonomy_scope
92
- load_vars_for_ajax
93
- offer_to_overwrite_conflicts
94
- process_error :object => host, :render => 'discovered_hosts/edit'
95
- end
96
- end
97
- end
98
-
99
- def refresh_facts
100
- if @host.is_a?(::Host::Discovered) && @host.refresh_facts
101
- process_success :success_msg => _("Facts refreshed for %s") % @host.name, :success_redirect => :back
102
- else
103
- process_error :error_msg => _("Failed to refresh facts for %s") % @host.name, :redirect => :back
104
- end
105
- rescue => e
106
- exception = Foreman::WrappedException.new(e, N_("Failed to refresh facts for %{hostname} with error %{error_message}"), :hostname => @host.name, :error_message => e.message)
107
- Foreman::Logging.exception exception.message, e
108
- process_error :error_msg => exception.message, :redirect => :back
109
- end
110
-
111
- def reboot
112
- unless @host.is_a?(::Host::Discovered)
113
- process_error :error_msg => _("Host of type %s can not be rebooted") % @host.type, :redirect => :back
114
- end
115
-
116
- if @host.reboot
117
- process_success :success_msg => _("Rebooting host %s") % @host.name, :success_redirect => :back
118
- else
119
- process_error :error_msg => _("Failed to reboot host %s") % @host.name, :redirect => :back
120
- end
121
- rescue => e
122
- exception = Foreman::WrappedException.new(e, N_("Failed to reboot host %{hostname} with error %{error_message}"), :hostname => @host.name, :error_message => e.message)
123
- Foreman::Logging.exception exception.message, e
124
- process_error :error_msg => exception.message, :redirect => :back
125
- end
126
-
127
- def submit_multiple_reboot
128
- error_message = perform_reboot_all(@hosts)
129
-
130
- if error_message
131
- process_error :error_msg => error_message, :redirect => :back
132
- else
133
- process_success :success_msg => _("Discovered hosts are rebooting now"), :success_redirect => :back
134
- end
135
- rescue => e
136
- exception = Foreman::WrappedException.new(e, N_("Failed to reboot hosts with error %s"), e.message)
137
- Foreman::Logging.exception exception.message, e
138
- process_error :error_msg => exception.message, :redirect => :back
139
- end
140
-
141
- def multiple_destroy
142
- end
143
-
144
- def multiple_reboot
145
- end
146
-
147
- def multiple_auto_provision
148
- end
149
-
150
- def submit_multiple_destroy
151
- # keep all the ones that were not deleted for notification.
152
- missed_hosts = @hosts.select {|host| !host.destroy }
153
- if missed_hosts
154
- success _("Destroyed selected hosts")
155
- else
156
- error _("The following hosts were not deleted: %s") % missed_hosts
157
- end
158
- redirect_to(discovered_hosts_path)
159
- end
160
-
161
- def auto_provision
162
- if rule = find_discovery_rule(@host)
163
- if perform_auto_provision(@host, rule)
164
- process_success :success_msg => _("Host %{host} was provisioned with rule %{rule}") % {:host => @host.name, :rule => rule.name}, :success_redirect => discovered_hosts_path
165
- else
166
- errors = @host.errors.full_messages.join(' ')
167
- logger.warn "Failed to auto provision host %s: %s" % [@host.name, errors]
168
- process_error :error_msg => _("Failed to auto provision host %s: %s") % [@host.name, errors], :redirect => :back
169
- end
170
- else
171
- process_success :success_msg => _("No rule found for host %s") % @host.name, :success_redirect => :back
172
- end
173
- end
174
-
175
- def submit_multiple_auto_provision
176
- result = true
177
- error_message = _("Errors during auto provisioning: %s")
178
-
179
- if Host::Discovered.count == 0
180
- error_message = _("No discovered hosts to provision")
181
- result = false
182
- end
183
-
184
- overall_errors = ""
185
- @hosts.each do |discovered_host|
186
- if rule = find_discovery_rule(discovered_host)
187
- result &= perform_auto_provision(discovered_host, rule)
188
- unless discovered_host.errors.empty?
189
- errors = discovered_host.errors.full_messages.join(' ')
190
- logger.warn "Failed to auto provision host %s: %s" % [discovered_host.name, errors]
191
- overall_errors << "#{discovered_host.name}: #{errors} "
192
- end
193
- end
194
- end
195
- if result
196
- process_success :success_msg => _("Discovered hosts are provisioning now"), :success_redirect => :back
197
- else
198
- process_error :error_msg => error_message % overall_errors, :redirect => :back
199
- end
200
- end
201
-
202
- def resource_class
203
- Host::Discovered
204
- end
205
-
206
- private
207
-
208
- def setup_host_class_variables
209
- if @host.hostgroup
210
- subnet = @host.hostgroup.subnet || @host.subnet
211
- subnet6 = @host.hostgroup.subnet6 || @host.subnet6
212
- @architecture = @host.hostgroup.architecture
213
- @operatingsystem = @host.hostgroup.operatingsystem
214
- if defined?(ForemanPuppet)
215
- @environment = @host.hostgroup.environment
216
- @host.environment = @environment
217
- end
218
- @domain = @host.hostgroup.domain
219
- @subnet = subnet
220
- @subnet6 = subnet6
221
- @compute_profile = @host.hostgroup.compute_profile
222
- @realm = @host.hostgroup.realm
223
- @host.interfaces.first.assign_attributes(subnet: subnet, subnet6: subnet6, domain: @domain)
224
- end
225
- end
226
-
227
- def resource_base
228
- @resource_base ||= ::Host::Discovered.authorized(current_permission, ::Host::Discovered)
229
- end
230
-
231
- def load_vars_for_ajax
232
- return unless @host
233
- if defined?(ForemanPuppet)
234
- @environment = @host.environment
235
- end
236
- @architecture = @host.architecture
237
- @domain = @host.domain
238
- @operatingsystem = @host.operatingsystem
239
- @medium = @host.medium
240
- end
241
-
242
- # this is required for template generation (such as pxelinux) which is not done via a web request
243
- def forward_url_options(host = @host)
244
- host.url_options = url_options if @host.respond_to?(:url_options)
245
- end
246
-
247
- # if a save failed and the only reason was network conflicts then flag this so that the view
248
- # is rendered differently and the next save operation will be forced
249
- def offer_to_overwrite_conflicts
250
- @host.overwrite = "true" if @host.errors.any? and @host.errors.are_all_conflicts?
251
- end
252
-
253
- def controller_permission
254
- 'discovered_hosts'
255
- end
256
-
257
- def action_permission
258
- case params[:action]
259
- when 'refresh_facts', 'reboot', 'multiple_reboot', 'update_multiple_location',
260
- 'select_multiple_organization', 'update_multiple_organization', 'select_multiple_location', 'submit_multiple_reboot'
261
- :edit
262
- when 'submit_multiple_destroy', 'multiple_destroy'
263
- :destroy
264
- when 'auto_provision', 'multiple_auto_provision', 'submit_multiple_auto_provision'
265
- :auto_provision
266
- else
267
- super
268
- end
269
- end
270
-
271
- def find_by_name(*includes)
272
- not_found and return false if (id = params[:id]).blank?
273
- id.downcase!
274
- @host = includes.empty? ? resource_base.find_by_id(id) : resource_base.includes(includes).find_by_id(id)
275
- @host ||= includes.empty? ? resource_base.find_by_name(id) : resource_base.includes(includes).find_by_name(id)
276
- not_found and return(false) unless @host
277
- @host
278
- end
279
-
280
- def check_for_subnet
281
- hosts_without_subnet = []
282
- case params[:action]
283
- when 'reboot', 'auto_provision'
284
- if @host.subnet.nil?
285
- process_warning :warning_msg => _("Discovered host reported from unknown subnet, communication will not be proxied.")
286
- end
287
- when 'submit_multiple_reboot', 'submit_multiple_auto_provision'
288
- hosts_without_subnet = @hosts.limit(3).select { |host| host.subnet.nil? }.pluck(:name)
289
- if hosts_without_subnet.present?
290
- process_warning :warning_msg => _("Discovered hosts reported from unknown subnet are %s, communication will not be proxied.") % hosts_without_subnet.join(', ')
291
- end
292
- end
293
- end
294
-
295
- def find_by_name_incl_subnet
296
- find_by_name({:interfaces => :subnet})
297
- end
298
-
299
- def find_multiple
300
- # Lets search by name or id and make sure one of them exists first
301
- if params[:host_names].present? or params[:host_ids].present?
302
- @hosts = Host::Discovered.includes(:model, :fact_values, :interfaces, :location, :organization).where("id IN (?) or name IN (?)", params[:host_ids], params[:host_names] )
303
- if @hosts.empty?
304
- error _('No hosts were found with that id or name')
305
- redirect_to(discovered_hosts_path) and return false
306
- end
307
- else
308
- error _('No hosts selected')
309
- redirect_to(discovered_hosts_path) and return false
310
- end
311
-
312
- return @hosts
313
- rescue => e
314
- error _("Something went wrong while selecting hosts - %s") % e
315
- redirect_to discovered_hosts_path
316
- end
317
-
318
- def taxonomy_scope
319
- if @host
320
- @organization = @host.organization
321
- @location = @host.location
322
- end
323
-
324
- @organization ||= Organization.current
325
- @organization ||= Organization.my_organizations.first
326
- @location ||= Location.current
327
- @location ||= Location.my_locations.first
328
- end
329
-
330
- # particular actions will always raise N+1 queries
331
- def skip_bullet
332
- Bullet.enable = false if defined? Bullet
333
- yield
334
- ensure
335
- Bullet.enable = true if defined? Bullet
336
- end
337
-
338
- <<<<<<< HEAD
339
- def add_custom_facts
340
- unless @host.primary_interface.subnet.nil?
341
- discovery_subnet = "#{@host.primary_interface.subnet.name} (#{@host.primary_interface.subnet.network})"
342
- assign_fact_to_category("discovery_subnet", discovery_subnet)
343
- =======
344
- def get_interfaces
345
- @host.interfaces.each do |interface|
346
- @interfaces << {:identifier => interface["identifier"], :type => interface["type"], :mac => interface["mac"], :ip => interface["ip"]? interface["ip"] : "N/A", :primary => interface["primary"], :provision => interface["provision"]}
347
- >>>>>>> 58baad5 (Support subnet6 facts in FactToCategoryResolver)
348
- end
349
- end
350
-
351
- def process_warning(hash = {})
352
- warning hash[:warning_msg]
353
- end
354
- end