foreman_discovery 14.0.1 → 15.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +8 -4
  3. data/app/controllers/api/v2/discovery_rules_controller.rb +2 -2
  4. data/app/controllers/concerns/foreman/controller/discovered_extensions.rb +2 -6
  5. data/app/controllers/discovered_hosts_controller.rb +4 -8
  6. data/app/helpers/discovered_hosts_helper.rb +3 -3
  7. data/app/helpers/discovery_rules_helper.rb +3 -3
  8. data/app/models/discovery_rule.rb +9 -13
  9. data/app/models/host/discovered.rb +6 -10
  10. data/app/models/host/managed_extensions.rb +6 -6
  11. data/app/models/setting/discovered.rb +2 -16
  12. data/app/services/foreman_discovery/import_hooks/subnet_and_taxonomy.rb +4 -4
  13. data/app/views/api/v2/discovered_hosts/main.json.rabl +2 -7
  14. data/app/views/api/v2/discovery_rules/main.json.rabl +4 -8
  15. data/app/views/discovered_hosts/_discovered_hosts_list.html.erb +8 -17
  16. data/app/views/discovered_hosts/_selected_hosts.html.erb +2 -10
  17. data/app/views/discovered_hosts/multiple_destroy.html.erb +1 -1
  18. data/app/views/discovered_hosts/select_multiple_location.html.erb +1 -1
  19. data/app/views/discovered_hosts/select_multiple_organization.html.erb +1 -1
  20. data/app/views/foreman_discovery/debian_kexec.erb +1 -1
  21. data/app/views/foreman_discovery/redhat_kexec.erb +5 -2
  22. data/db/seeds.d/50_discovery_templates.rb +2 -2
  23. data/lib/foreman_discovery/engine.rb +3 -3
  24. data/lib/foreman_discovery/version.rb +1 -1
  25. data/locale/ca/LC_MESSAGES/foreman_discovery.mo +0 -0
  26. data/locale/ca/foreman_discovery.edit.po +92 -98
  27. data/locale/ca/foreman_discovery.po +2 -8
  28. data/locale/de/LC_MESSAGES/foreman_discovery.mo +0 -0
  29. data/locale/de/foreman_discovery.edit.po +111 -116
  30. data/locale/de/foreman_discovery.po +21 -26
  31. data/locale/en/foreman_discovery.edit.po +92 -100
  32. data/locale/en/foreman_discovery.po +0 -6
  33. data/locale/en_GB/LC_MESSAGES/foreman_discovery.mo +0 -0
  34. data/locale/en_GB/foreman_discovery.edit.po +92 -98
  35. data/locale/en_GB/foreman_discovery.po +2 -8
  36. data/locale/es/LC_MESSAGES/foreman_discovery.mo +0 -0
  37. data/locale/es/foreman_discovery.edit.po +106 -112
  38. data/locale/es/foreman_discovery.po +16 -22
  39. data/locale/foreman_discovery.pot +103 -109
  40. data/locale/fr/LC_MESSAGES/foreman_discovery.mo +0 -0
  41. data/locale/fr/foreman_discovery.edit.po +107 -113
  42. data/locale/fr/foreman_discovery.po +17 -23
  43. data/locale/gl/LC_MESSAGES/foreman_discovery.mo +0 -0
  44. data/locale/gl/foreman_discovery.edit.po +92 -98
  45. data/locale/gl/foreman_discovery.po +2 -8
  46. data/locale/it/LC_MESSAGES/foreman_discovery.mo +0 -0
  47. data/locale/it/foreman_discovery.edit.po +92 -98
  48. data/locale/it/foreman_discovery.po +2 -8
  49. data/locale/ja/LC_MESSAGES/foreman_discovery.mo +0 -0
  50. data/locale/ja/foreman_discovery.edit.po +106 -112
  51. data/locale/ja/foreman_discovery.po +16 -22
  52. data/locale/ko/LC_MESSAGES/foreman_discovery.mo +0 -0
  53. data/locale/ko/foreman_discovery.edit.po +92 -98
  54. data/locale/ko/foreman_discovery.po +2 -8
  55. data/locale/pt_BR/LC_MESSAGES/foreman_discovery.mo +0 -0
  56. data/locale/pt_BR/foreman_discovery.edit.po +106 -112
  57. data/locale/pt_BR/foreman_discovery.po +16 -22
  58. data/locale/ru/LC_MESSAGES/foreman_discovery.mo +0 -0
  59. data/locale/ru/foreman_discovery.edit.po +92 -98
  60. data/locale/ru/foreman_discovery.po +2 -8
  61. data/locale/sv_SE/LC_MESSAGES/foreman_discovery.mo +0 -0
  62. data/locale/sv_SE/foreman_discovery.edit.po +92 -98
  63. data/locale/sv_SE/foreman_discovery.po +2 -8
  64. data/locale/zh_CN/LC_MESSAGES/foreman_discovery.mo +0 -0
  65. data/locale/zh_CN/foreman_discovery.edit.po +106 -112
  66. data/locale/zh_CN/foreman_discovery.po +16 -22
  67. data/locale/zh_TW/LC_MESSAGES/foreman_discovery.mo +0 -0
  68. data/locale/zh_TW/foreman_discovery.edit.po +92 -98
  69. data/locale/zh_TW/foreman_discovery.po +2 -8
  70. data/test/factories/discovery_rule_related.rb +2 -2
  71. data/test/facts/asswweb061.json +2967 -0
  72. data/test/facts/qemu_noip.json +2 -0
  73. data/test/functional/api/v2/discovered_hosts_controller_test.rb +0 -16
  74. data/test/functional/discovered_hosts_controller_test.rb +19 -21
  75. data/test/test_helper_discovery.rb +1 -1
  76. data/test/unit/discovery_rule_test.rb +0 -2
  77. data/test/unit/host_discovered_test.rb +72 -16
  78. data/test/unit/managed_extensions_test.rb +2 -2
  79. data/test/unit/ui_notifications/destroy_host_test.rb +9 -0
  80. metadata +7 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6db307d435a16f1400f797101433c496b54191570025be1c57dd99b17f6de642
4
- data.tar.gz: 3448174f47cda0c77c34f10224f7331f3f4abc472bcf0bda4648477ebff4e373
3
+ metadata.gz: 305477b201b75199eef688c2bea65f1a514d556b106315c2fd0f654584e70a29
4
+ data.tar.gz: c5326ee72b7fea7a727eae0307b9c10242b0ff9f9cc24ff75dfc4ca7fd914a89
5
5
  SHA512:
6
- metadata.gz: 1cb57bb7847aba12ba8210621b6300768780e917c30d36c9fa0d20e5c4f5f2047d4e2c3fe55548c576447e66057def3c258adc5755c373d4a644f23313bb1add
7
- data.tar.gz: 2a24c9feea20b333a350fab9ef535e0adc83d5e9d499198298ca44d6417a312c280e53cad885c986cc9aab5917246bce1815f65bef94deeb3fdf91f2734554dd
6
+ metadata.gz: 806df7387b0d27b0ff717a9e882f8ab235585bce379b8fbe1e009936b9663b87e4a19d9211c5cc8beea1ddce5f97469ab6ebaeac81d6886a6479a92e31454dfc
7
+ data.tar.gz: 88b1b13517df83ce74a27d07a38e946db6330182f37a4e4ab98dec82afcd34a3704ffa1c4868e8d87c07b601232dd3ebc950ab3098d9c589ee0080e3e867abfa
data/README.md CHANGED
@@ -22,11 +22,15 @@ see the [API README](README.api.md)
22
22
  We use [RedMine instance](http://projects.theforeman.org/projects/discovery/issues)
23
23
  instead of github.com issues. Please report issues there.
24
24
 
25
- ## Grace Note: Testing
25
+ ## Testing
26
26
 
27
- If you only wish to test the plugin code itself, you don't need to create the PXE boot
28
- image above, or have a TFTP server to run it from. Simply POST a hash of Host Facts to
29
- `/api/v2/discovered_hosts/facts` to create a Discovered Host in the UI.
27
+ There are unit and integration tests in the repository, to run them execute the following in the *Foreman core* directory:
28
+
29
+ bundle exec rake test:discovery
30
+
31
+ It is possible to execute a single test, however the path must be *absolute* (e.g. use `$HOME` variable):
32
+
33
+ bundle exec rake test:discovery TEST=~/work/foreman_discovery/test/unit/host_discovered_test.rb
30
34
 
31
35
  # Copyright
32
36
 
@@ -36,8 +36,8 @@ module Api
36
36
  param :max_count, Integer, :desc => N_("enables to limit maximum amount of provisioned hosts per rule")
37
37
  param :priority, Integer, :desc => N_("puts the rules in order, low numbers go first. Must be greater then zero")
38
38
  param :enabled, :bool, :desc => N_("flag is used for temporary shutdown of rules")
39
- param :location_ids, Array, :required => true, :desc => N_("location ID for provisioned hosts") if SETTINGS[:locations_enabled]
40
- param :organization_ids, Array, :required => true, :desc => N_("organization ID for provisioned hosts") if SETTINGS[:organizations_enabled]
39
+ param :location_ids, Array, :required => true, :desc => N_("location ID for provisioned hosts")
40
+ param :organization_ids, Array, :required => true, :desc => N_("organization ID for provisioned hosts")
41
41
  end
42
42
  end
43
43
 
@@ -33,12 +33,8 @@ module Foreman::Controller::DiscoveredExtensions
33
33
  end
34
34
 
35
35
  def validate_rule_by_taxonomy rule, host
36
- if SETTINGS[:organizations_enabled]
37
- return false unless rule.organizations.include?(host.organization)
38
- end
39
- if SETTINGS[:locations_enabled]
40
- return false unless rule.locations.include?(host.location)
41
- end
36
+ return false unless rule.organizations.include?(host.organization)
37
+ return false unless rule.locations.include?(host.location)
42
38
  true
43
39
  end
44
40
 
@@ -318,14 +318,10 @@ class DiscoveredHostsController < ::ApplicationController
318
318
  @location = @host.location
319
319
  end
320
320
 
321
- if SETTINGS[:organizations_enabled]
322
- @organization ||= Organization.current
323
- @organization ||= Organization.my_organizations.first
324
- end
325
- if SETTINGS[:locations_enabled]
326
- @location ||= Location.current
327
- @location ||= Location.my_locations.first
328
- end
321
+ @organization ||= Organization.current
322
+ @organization ||= Organization.my_organizations.first
323
+ @location ||= Location.current
324
+ @location ||= Location.my_locations.first
329
325
  end
330
326
 
331
327
  # particular actions will always raise N+1 queries
@@ -28,13 +28,13 @@ module DiscoveredHostsHelper
28
28
  def multiple_discovered_hosts_actions_select
29
29
  actions = [[_('Auto Provision'), multiple_auto_provision_discovered_hosts_path, hash_for_multiple_auto_provision_discovered_hosts_path]]
30
30
  actions << [_('Reboot'), multiple_reboot_discovered_hosts_path, hash_for_multiple_reboot_discovered_hosts_path]
31
- actions << [_('Assign Organization'), select_multiple_organization_discovered_hosts_path, hash_for_select_multiple_organization_discovered_hosts_path] if SETTINGS[:organizations_enabled]
32
- actions << [_('Assign Location'), select_multiple_location_discovered_hosts_path, hash_for_select_multiple_location_discovered_hosts_path] if SETTINGS[:locations_enabled]
31
+ actions << [_('Assign Organization'), select_multiple_organization_discovered_hosts_path, hash_for_select_multiple_organization_discovered_hosts_path]
32
+ actions << [_('Assign Location'), select_multiple_location_discovered_hosts_path, hash_for_select_multiple_location_discovered_hosts_path]
33
33
  actions << [_('Delete'), multiple_destroy_discovered_hosts_path, hash_for_multiple_destroy_discovered_hosts_path]
34
34
 
35
35
  select_action_button( _("Select Action"), {:id => 'submit_multiple'},
36
36
  actions.map do |action|
37
- link_to_function(action[0], "build_modal(this, '#{action[1]}')", :'data-dialog-title' => _("%s - The following hosts are about to be changed") % action[0]) if authorized_for(action[2])
37
+ link_to_function(action[0], "tfm.hosts.table.buildModal(this, '#{action[1]}')", :'data-dialog-title' => _("%s - The following hosts are about to be changed") % action[0]) if authorized_for(action[2])
38
38
  end.flatten
39
39
  )
40
40
  end
@@ -26,10 +26,10 @@ module DiscoveryRulesHelper
26
26
  actions = [display_link_if_authorized(_('Discovered Hosts'), hash_for_discovered_hosts_path.merge(:search => rule.search))]
27
27
  actions << display_link_if_authorized(_('Associated Hosts'), hash_for_hosts_path.merge(:search => "discovery_rule = \"#{rule.name}\""))
28
28
  if rule.enabled?
29
- actions << display_link_if_authorized(_('Disable'), hash_for_disable_discovery_rule_path(:id => rule).merge(:auth_object => rule, :authorizer => authorizer), :confirm => _("Disable rule '%s'?") % rule)
29
+ actions << display_link_if_authorized(_('Disable'), hash_for_disable_discovery_rule_path(:id => rule).merge(:auth_object => rule, :authorizer => authorizer), :data => { :confirm => _("Disable rule '%s'?") % rule })
30
30
  else
31
- actions << display_link_if_authorized(_('Enable'), hash_for_enable_discovery_rule_path(:id => rule).merge(:auth_object => rule, :authorizer => authorizer), :confirm => _("Enable rule '%s'?") % rule)
31
+ actions << display_link_if_authorized(_('Enable'), hash_for_enable_discovery_rule_path(:id => rule).merge(:auth_object => rule, :authorizer => authorizer), :data => { :confirm => _("Enable rule '%s'?") % rule })
32
32
  end
33
- actions << display_delete_if_authorized(hash_for_discovery_rule_path(:id => rule).merge(:auth_object => rule, :authorizer => authorizer), :confirm => _("Delete rule '%s'?") % rule)
33
+ actions << display_delete_if_authorized(hash_for_discovery_rule_path(:id => rule).merge(:auth_object => rule, :authorizer => authorizer), :data => { :confirm => _("Delete rule '%s'?") % rule })
34
34
  end
35
35
  end
@@ -25,10 +25,10 @@ class DiscoveryRule < ApplicationRecord
25
25
  has_many :hosts, :dependent => :nullify
26
26
 
27
27
  scoped_search :on => :name, :complete_value => :true
28
- scoped_search :on => :priority
29
- scoped_search :on => :search
28
+ scoped_search :on => :priority, :only_explicit => true
29
+ scoped_search :on => :search, :only_explicit => true
30
30
  scoped_search :on => :enabled
31
- scoped_search :relation => :hostgroup, :on => :name, :complete_value => true, :rename => :hostgroup
31
+ scoped_search :relation => :hostgroup, :on => :name, :complete_value => true, :rename => :hostgroup, :only_explicit => true
32
32
 
33
33
  default_scope lambda {
34
34
  with_taxonomy_scope do
@@ -47,17 +47,13 @@ class DiscoveryRule < ApplicationRecord
47
47
 
48
48
  def enforce_taxonomy
49
49
  return if hostgroup.nil?
50
- if SETTINGS[:organizations_enabled]
51
- unless (ms = hostgroup.organizations - organizations).empty?
52
- names = ms.collect(&:name).to_sentence
53
- errors.add(:organizations, n_("Host group organization %s must also be associated to the discovery rule", "Host group organizations %s must also be associated to the discovery rule", ms.size) % names)
54
- end
50
+ unless (ms = hostgroup.organizations - organizations).empty?
51
+ names = ms.collect(&:name).to_sentence
52
+ errors.add(:organizations, n_("Host group organization %s must also be associated to the discovery rule", "Host group organizations %s must also be associated to the discovery rule", ms.size) % names)
55
53
  end
56
- if SETTINGS[:locations_enabled]
57
- unless (ms = hostgroup.locations - locations).empty?
58
- names = ms.collect(&:name).to_sentence
59
- errors.add(:locations, n_("Host group location %s must also be associated to the discovery rule", "Host group locations %s must also be associated to the discovery rule", ms.size) % names)
60
- end
54
+ unless (ms = hostgroup.locations - locations).empty?
55
+ names = ms.collect(&:name).to_sentence
56
+ errors.add(:locations, n_("Host group location %s must also be associated to the discovery rule", "Host group locations %s must also be associated to the discovery rule", ms.size) % names)
61
57
  end
62
58
  end
63
59
  end
@@ -20,16 +20,12 @@ class Host::Discovered < ::Host::Base
20
20
  scoped_search :on => :last_report, :complete_value => true, :only_explicit => true
21
21
  scoped_search :relation => :primary_interface, :on => :ip, :complete_value => true
22
22
  scoped_search :relation => :primary_interface, :on => :mac, :complete_value => true
23
- scoped_search :relation => :model, :on => :name, :complete_value => true, :rename => :model
23
+ scoped_search :relation => :model, :on => :name, :complete_value => true, :rename => :model, :only_explicit => true
24
24
  scoped_search :relation => :fact_values, :on => :value, :in_key => :fact_names, :on_key => :name, :rename => :facts, :complete_value => true, :only_explicit => true
25
- if SETTINGS[:locations_enabled]
26
- scoped_search :relation => :location, :on => :name, :rename => :location, :complete_value => true, :only_explicit => true
27
- scoped_search :on => :location_id, :complete_value => false, :only_explicit => true, :validator => ScopedSearch::Validators::INTEGER
28
- end
29
- if SETTINGS[:organizations_enabled]
30
- scoped_search :relation => :organization, :on => :name, :rename => :organization, :complete_value => true, :only_explicit => true
31
- scoped_search :on => :organization_id, :complete_value => false, :only_explicit => true, :validator => ScopedSearch::Validators::INTEGER
32
- end
25
+ scoped_search :relation => :location, :on => :name, :rename => :location, :complete_value => true, :only_explicit => true
26
+ scoped_search :on => :location_id, :complete_value => false, :only_explicit => true, :validator => ScopedSearch::Validators::INTEGER
27
+ scoped_search :relation => :organization, :on => :name, :rename => :organization, :complete_value => true, :only_explicit => true
28
+ scoped_search :on => :organization_id, :complete_value => false, :only_explicit => true, :validator => ScopedSearch::Validators::INTEGER
33
29
  scoped_search :relation => :subnet, :on => :network, :complete_value => true, :rename => :subnet
34
30
  scoped_search :relation => :subnet, :on => :name, :complete_value => true, :rename => 'subnet.name'
35
31
  scoped_search :relation => :discovery_attribute_set, :on => :cpu_count, :rename => :cpu_count, :complete_value => true, :only_explicit => true
@@ -208,7 +204,7 @@ class Host::Discovered < ::Host::Base
208
204
  end
209
205
 
210
206
  def notification_recipients_ids
211
- org_recipients = find_organization_users if Taxonomy.organizations_enabled
207
+ org_recipients = find_organization_users
212
208
  org_recipients ||= []
213
209
 
214
210
  admins = User.unscoped.only_admin.except_hidden.
@@ -8,7 +8,7 @@ module Host::ManagedExtensions
8
8
 
9
9
  belongs_to :discovery_rule
10
10
 
11
- scoped_search :relation => :discovery_rule, :on => :name, :rename => :discovery_rule, :complete_value => true
11
+ scoped_search :relation => :discovery_rule, :on => :name, :rename => :discovery_rule, :complete_value => true, :only_explicit => true
12
12
  end
13
13
 
14
14
  def queue_reboot
@@ -45,9 +45,7 @@ module Host::ManagedExtensions
45
45
  template = provisioning_template(:kind => 'kexec')
46
46
  raise ::Foreman::Exception.new(N_("Kexec template not associated with operating system")) unless template
47
47
 
48
- source = Foreman::Renderer::Source::String.new(name: template.name, content: template.template)
49
- scope = Foreman::Renderer.get_scope(host: self, source: source)
50
- json = JSON.parse(Foreman::Renderer.render(source, scope))
48
+ json = JSON.parse(render_template(template: template))
51
49
  ::Foreman::Exception.new(N_("Kernel kexec URL is invalid: '%s'"), json['kernel']) unless json['kernel'] =~ /\Ahttp.+\Z/
52
50
  ::Foreman::Exception.new(N_("Init RAM kexec URL is invalid: '%s'"), json['initrd']) unless json['initrd'] =~ /\Ahttp.+\Z/
53
51
  json
@@ -70,12 +68,14 @@ module Host::ManagedExtensions
70
68
 
71
69
  def delete_discovery_attribute_set
72
70
  return if new_record?
73
- DiscoveryAttributeSet.where(:host_id => self.id).destroy_all if saved_change_to_attribute?(:type)
71
+
72
+ DiscoveryAttributeSet.where(:host_id => self.id).destroy_all if saved_change_to_attribute?(:type) && type_previously_changed?
74
73
  end
75
74
 
76
75
  def update_notifications
77
76
  return if new_record?
78
- return unless saved_change_to_attribute?(:type)
77
+ return unless saved_change_to_attribute?(:type) || type_previously_changed?
78
+
79
79
  ForemanDiscovery::UINotifications::DestroyHost.deliver!(self)
80
80
  end
81
81
  end
@@ -16,6 +16,8 @@ class Setting::Discovered < ::Setting
16
16
 
17
17
  Setting.transaction do
18
18
  [
19
+ self.set('discovery_location', N_("The default location to place discovered hosts in"), "", N_("Discovery location"), nil, { :collection => Proc.new {Hash[Location.all.map{|loc| [loc[:title], loc[:title]]}]} }),
20
+ self.set('discovery_organization', N_("The default organization to place discovered hosts in"), "", N_("Discovery organization"), nil, { :collection => Proc.new {Hash[Organization.all.map{|org| [org[:title], org[:title]]}]} }),
19
21
  self.set('discovery_fact', N_("Fact name to use for primary interface detection"), "discovery_bootif", N_("Interface fact")),
20
22
  self.set('discovery_auto_bond', N_("Automatic bond interface (if another interface is detected on the same VLAN via LLDP)"), false, N_("Create bond interfaces")),
21
23
  self.set('discovery_clean_facts', N_("Clean all reported facts during provisioning (except discovery facts)"), false, N_("Clean all facts")),
@@ -40,22 +42,6 @@ class Setting::Discovered < ::Setting
40
42
  ].compact.each { |s| self.create s.update(:category => "Setting::Discovered")}
41
43
  end
42
44
 
43
- if SETTINGS[:locations_enabled]
44
- Setting.transaction do
45
- [
46
- self.set('discovery_location', N_("The default location to place discovered hosts in"), "", N_("Discovery location"), nil, { :collection => Proc.new {Hash[Location.all.map{|loc| [loc[:title], loc[:title]]}]} }),
47
- ].compact.each { |s| self.create s.update(:category => "Setting::Discovered")}
48
- end
49
- end
50
-
51
- if SETTINGS[:organizations_enabled]
52
- Setting.transaction do
53
- [
54
- self.set('discovery_organization', N_("The default organization to place discovered hosts in"), "", N_("Discovery organization"), nil, { :collection => Proc.new {Hash[Organization.all.map{|org| [org[:title], org[:title]]}]} }),
55
- ].compact.each { |s| self.create s.update(:category => "Setting::Discovered")}
56
- end
57
- end
58
-
59
45
  true
60
46
  end
61
47
 
@@ -34,26 +34,26 @@ module ForemanDiscovery
34
34
  end
35
35
 
36
36
  def set_location
37
- return unless SETTINGS[:locations_enabled]
38
37
  host.location = suggested_location
39
38
  logger.info "Assigned location: #{host.location}"
40
39
  end
41
40
 
42
41
  def suggested_location
43
- Location.find_by_title(facts["foreman_location"] || facts["discovery_location"]) ||
42
+ logger.warn("Do not use 'foreman_location' fact for discovery and use 'discovery_location' instead") if facts["foreman_location"]
43
+ Location.find_by_title(facts["discovery_location"]) ||
44
44
  Location.find_by_title(Setting[:discovery_location]) ||
45
45
  host.subnet.try(:locations).try(:first) ||
46
46
  Location.first
47
47
  end
48
48
 
49
49
  def set_organization
50
- return unless SETTINGS[:organizations_enabled]
51
50
  host.organization = suggested_organization
52
51
  logger.info "Assigned organization: #{host.organization}"
53
52
  end
54
53
 
55
54
  def suggested_organization
56
- Organization.find_by_title(facts["foreman_organization"] || facts["discovery_organization"]) ||
55
+ logger.warn("Do not use 'foreman_organization' fact for discovery and use 'discovery_organization' instead") if facts["foreman_organization"]
56
+ Organization.find_by_title(facts["discovery_organization"]) ||
57
57
  Organization.find_by_title(Setting[:discovery_organization]) ||
58
58
  host.subnet.try(:organizations).try(:first) ||
59
59
  Organization.first
@@ -9,10 +9,5 @@ node :subnet_name do |host|
9
9
  host.subnet.to_label if host.subnet.present?
10
10
  end
11
11
 
12
- if SETTINGS[:organizations_enabled]
13
- attributes :organization_id, :organization_name
14
- end
15
-
16
- if SETTINGS[:locations_enabled]
17
- attributes :location_id, :location_name
18
- end
12
+ attributes :organization_id, :organization_name
13
+ attributes :location_id, :location_name
@@ -9,14 +9,10 @@ child :hosts do
9
9
  extends "api/v2/discovered_hosts/base"
10
10
  end
11
11
 
12
- if SETTINGS[:organizations_enabled]
13
- child :organizations => :organizations do
14
- attributes :id, :name
15
- end
12
+ child :organizations => :organizations do
13
+ attributes :id, :name
16
14
  end
17
15
 
18
- if SETTINGS[:locations_enabled]
19
- child :locations => :locations do
20
- attributes :id, :name
21
- end
16
+ child :locations => :locations do
17
+ attributes :id, :name
22
18
  end
@@ -1,8 +1,7 @@
1
- <%= javascript "host_checkbox" %>
2
1
  <% title _('Discovered Hosts') %>
3
2
  <table class="<%= table_css_classes('table-condensed') %>" >
4
3
  <tr>
5
- <th class="ca"><%= check_box_tag "check_all", "", false, { :onclick => "toggleCheck()", :'check-title' => _("Select all items in this page"), :'uncheck-title'=> _("items selected. Uncheck to Clear") } %></th>
4
+ <th class="ca"><%= check_box_tag "check_all", "", false, { :onclick => "tfm.hosts.table.toggleCheck()", :'check-title' => _("Select all items in this page"), :'uncheck-title'=> _("items selected. Uncheck to Clear") } %></th>
6
5
  <th class=''><%= sort :name, :as => _('Name') %></th>
7
6
  <th class="hidden-tablet hidden-xs"><%= sort :model, :as => _('Model') %></th>
8
7
  <th class="hidden-tablet hidden-xs"><%= sort :ip, :as => _('IP Address') %></th>
@@ -13,12 +12,8 @@
13
12
  <% Setting::Discovered.discovery_fact_column_array.each do |fact_column| %>
14
13
  <th class="hidden-tablet hidden-xs"><%= fact_column.capitalize %></th>
15
14
  <% end %>
16
- <% if SETTINGS[:locations_enabled] -%>
17
- <th class="hidden-tablet hidden-xs"><%= sort :location, :as => _('Location') %></th>
18
- <% end -%>
19
- <% if SETTINGS[:organizations_enabled] -%>
20
- <th class="hidden-tablet hidden-xs"><%= sort :organization, :as => _('Organization') %></th>
21
- <% end -%>
15
+ <th class="hidden-tablet hidden-xs"><%= sort :location, :as => _('Location') %></th>
16
+ <th class="hidden-tablet hidden-xs"><%= sort :organization, :as => _('Organization') %></th>
22
17
  <th class="hidden-tablet hidden-xs"><%= sort :subnet, :as => _("Subnet") %></th>
23
18
  <th class="hidden-tablet hidden-xs"><%= sort :last_report, :as => _("Last Facts Upload") %></th>
24
19
  <th class="hidden-tablet hidden-xs"><%= _("Actions") %></th>
@@ -26,15 +21,11 @@
26
21
  <% @hosts.each do |host| -%>
27
22
  <tr>
28
23
  <td class="ca">
29
- <%= check_box_tag "host_ids[]", nil, false, :id => "host_ids_#{host.id}", :disabled => !authorized_for_edit_destroy?, :class => 'host_select_boxes', :onclick => 'hostChecked(this)' -%>
24
+ <%= check_box_tag "host_ids[]", nil, false, :id => "host_ids_#{host.id}", :disabled => !authorized_for_edit_destroy?, :class => 'host_select_boxes', :onclick => 'tfm.hosts.table.hostChecked(this)' -%>
30
25
  </td>
31
26
  <%= render :partial => "discovered_host", :locals => {:host => host} %>
32
- <% if SETTINGS[:locations_enabled] -%>
33
- <td class="hidden-tablet hidden-xs"><%= host.location.try(:title) %></td>
34
- <% end -%>
35
- <% if SETTINGS[:organizations_enabled] -%>
36
- <td class="hidden-tablet hidden-xs"><%= host.organization.try(:title) %></td>
37
- <% end -%>
27
+ <td class="hidden-tablet hidden-xs"><%= host.location.try(:title) %></td>
28
+ <td class="hidden-tablet hidden-xs"><%= host.organization.try(:title) %></td>
38
29
  <td class="hidden-tablet hidden-xs"><%= host.primary_interface.try(:subnet).try(:to_label) %></td>
39
30
  <td class="hidden-tablet hidden-xs"><%= disc_report_column(host) %></td>
40
31
  <td>
@@ -46,7 +37,7 @@
46
37
  display_link_if_authorized(_("Auto Provision"), hash_for_auto_provision_discovered_host_path(:id => host), :method => :post),
47
38
  display_link_if_authorized(_("Refresh facts"), hash_for_refresh_facts_discovered_host_path(:id => host)),
48
39
  display_link_if_authorized(_("Reboot"), hash_for_reboot_discovered_host_path(:id => host), :method => :put),
49
- display_delete_if_authorized(hash_for_discovered_host_path(:id => host), :confirm => _("Delete %s?") % host.name, :action => :destroy))%>
40
+ display_delete_if_authorized(hash_for_discovered_host_path(:id => host), :data => { :confirm => _("Delete %s?") % host.name }, :action => :destroy)) %>
50
41
  </td>
51
42
  </tr>
52
43
  <% end -%>
@@ -64,7 +55,7 @@
64
55
  </div>
65
56
  <div class="modal-footer">
66
57
  <button type="button" class="btn btn-default" data-dismiss="modal"><%= _('Cancel') %></button>
67
- <button type="button" class="btn btn-primary" onclick="submit_modal_form()"><%= _('Submit') %></button>
58
+ <button type="button" class="btn btn-primary" onclick="tfm.hosts.table.submitModalForm()"><%= _('Submit') %></button>
68
59
  </div>
69
60
  </div><!-- /.modal-content -->
70
61
  </div><!-- /.modal-dialog -->
@@ -6,12 +6,8 @@
6
6
  <tr>
7
7
  <th><%= _('Name') %></th>
8
8
  <th><%= _('Model') %></th>
9
- <% if SETTINGS[:locations_enabled] %>
10
- <th><%= _('Location') %></th>
11
- <% end %>
12
- <% if SETTINGS[:organizations_enabled] %>
13
- <th><%= _('Organization') %></th>
14
- <% end %>
9
+ <th><%= _('Location') %></th>
10
+ <th><%= _('Organization') %></th>
15
11
  </tr>
16
12
  </thead>
17
13
  <tbody>
@@ -19,12 +15,8 @@
19
15
  <tr>
20
16
  <td><%=h host %> </td>
21
17
  <td><%=h host.model %> </td>
22
- <% if SETTINGS[:locations_enabled]%>
23
18
  <td><%=h host.try(:location) %></td>
24
- <% end %>
25
- <% if SETTINGS[:organizations_enabled]%>
26
19
  <td><%=h host.try(:organization) %></td>
27
- <% end %>
28
20
  </tr>
29
21
  <% end -%>
30
22
  </tbody>
@@ -1,4 +1,4 @@
1
- <%= form_tag submit_multiple_destroy_discovered_hosts_path(:host_ids => params[:host_ids]), :onsubmit => "resetSelection()" do -%>
1
+ <%= form_tag submit_multiple_destroy_discovered_hosts_path(:host_ids => params[:host_ids]), :onsubmit => "tfm.hosts.table.resetSelection()" do -%>
2
2
  <%= alert :class => 'alert-warning',
3
3
  :text => _("This might take a while, as all hosts, facts and reports will be destroyed as well"),
4
4
  :header => '' %>
@@ -3,7 +3,7 @@
3
3
  <div class="col-md-8">
4
4
  <%= form_for :location, :url => update_multiple_location_discovered_hosts_path(:host_ids => params[:host_ids]) do |f| %>
5
5
  <%= f.select :id, Location.all.map{|e| [e.name, e.id]},{:include_blank => _("Select location")},
6
- :onchange => "toggle_multiple_ok_button(this)" %>
6
+ :onchange => "tfm.hosts.table.toggleMultipleOkButton (this)" %>
7
7
  <%= f.hidden_field :optimistic_import, :value => "yes" %>
8
8
  <% end %>
9
9
  </div>
@@ -3,7 +3,7 @@
3
3
  <div class="col-md-8">
4
4
  <%= form_for :organization, :url => update_multiple_organization_discovered_hosts_path(:host_ids => params[:host_ids]) do |f| %>
5
5
  <%= f.select :id, Organization.all.map{|e| [e.name, e.id]},{:include_blank => _("Select organization")},
6
- :onchange => "toggle_multiple_ok_button(this)" %>
6
+ :onchange => "tfm.hosts.table.toggleMultipleOkButton (this)" %>
7
7
  <%= f.hidden_field :optimistic_import, :value => "yes" %>
8
8
  <% end %>
9
9
  </div>
@@ -24,7 +24,7 @@ Please read kexec(8) man page for more information about semantics.
24
24
  mask = @host.facts['discovery_netmask']
25
25
  gw = @host.facts['discovery_gateway']
26
26
  dns = @host.facts['discovery_dns']
27
- options = ["nomodeset", "auto=true"]
27
+ options = ["nomodeset", "nokaslr", "auto=true"]
28
28
  options << @host.facts['append']
29
29
  options << "domain=#{@host.domain}"
30
30
  options << 'console-setup/ask_detect=false console-setup/layout=USA console-setup/variant=USA keyboard-configuration/layoutcode=us localechooser/translation/warn-light=true localechooser/translation/warn-severe=true'