foreman_discovery 16.0.0 → 16.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/api/v2/discovered_hosts_controller.rb +24 -11
  3. data/app/controllers/api/v2/discovery_rules_controller.rb +1 -1
  4. data/app/controllers/discovered_hosts_controller.rb +5 -3
  5. data/app/controllers/discovery_rules_controller.rb +1 -1
  6. data/app/models/discovery_rule.rb +1 -1
  7. data/app/models/host/discovered.rb +52 -34
  8. data/app/models/host/managed_extensions.rb +2 -2
  9. data/app/models/setting/discovered.rb +3 -1
  10. data/app/services/foreman_discovery/host_converter.rb +15 -7
  11. data/app/services/foreman_discovery/host_fact_importer.rb +10 -0
  12. data/app/services/foreman_discovery/import_hooks/subnet_and_taxonomy.rb +2 -0
  13. data/app/services/foreman_discovery/node_api/node_resource.rb +1 -0
  14. data/app/views/api/v2/discovery_rules/create.json.rabl +3 -0
  15. data/app/views/discovered_hosts/_discovered_host_modal.html.erb +0 -2
  16. data/app/views/discovered_hosts/welcome.html.erb +15 -9
  17. data/app/views/discovery_rules/index.html.erb +1 -1
  18. data/app/views/foreman_discovery/debian_kexec.erb +3 -2
  19. data/app/views/foreman_discovery/redhat_kexec.erb +2 -1
  20. data/db/migrate/20150512150432_remove_old_discovery_reader_permissions.rb +1 -1
  21. data/db/migrate/20151023144501_regenerate_red_hat_kexec.rb +1 -1
  22. data/db/migrate/20180412124505_add_priority_score_to_discovery_rules.rb +1 -1
  23. data/extra/discover-host +14 -8
  24. data/lib/foreman_discovery/engine.rb +5 -4
  25. data/lib/foreman_discovery/version.rb +1 -1
  26. data/locale/ca/LC_MESSAGES/foreman_discovery.mo +0 -0
  27. data/locale/ca/foreman_discovery.edit.po +195 -252
  28. data/locale/ca/foreman_discovery.po +40 -17
  29. data/locale/de/LC_MESSAGES/foreman_discovery.mo +0 -0
  30. data/locale/de/foreman_discovery.edit.po +201 -257
  31. data/locale/de/foreman_discovery.po +46 -23
  32. data/locale/en/LC_MESSAGES/foreman_discovery.mo +0 -0
  33. data/locale/en/foreman_discovery.edit.po +141 -111
  34. data/locale/en/foreman_discovery.po +36 -13
  35. data/locale/en_GB/LC_MESSAGES/foreman_discovery.mo +0 -0
  36. data/locale/en_GB/foreman_discovery.edit.po +205 -254
  37. data/locale/en_GB/foreman_discovery.po +42 -19
  38. data/locale/es/LC_MESSAGES/foreman_discovery.mo +0 -0
  39. data/locale/es/foreman_discovery.edit.po +209 -258
  40. data/locale/es/foreman_discovery.po +46 -23
  41. data/locale/foreman_discovery.pot +150 -117
  42. data/locale/fr/LC_MESSAGES/foreman_discovery.mo +0 -0
  43. data/locale/fr/foreman_discovery.edit.po +203 -255
  44. data/locale/fr/foreman_discovery.po +44 -21
  45. data/locale/gl/LC_MESSAGES/foreman_discovery.mo +0 -0
  46. data/locale/gl/foreman_discovery.edit.po +190 -250
  47. data/locale/gl/foreman_discovery.po +38 -15
  48. data/locale/it/LC_MESSAGES/foreman_discovery.mo +0 -0
  49. data/locale/it/foreman_discovery.edit.po +193 -253
  50. data/locale/it/foreman_discovery.po +41 -18
  51. data/locale/ja/LC_MESSAGES/foreman_discovery.mo +0 -0
  52. data/locale/ja/foreman_discovery.edit.po +207 -256
  53. data/locale/ja/foreman_discovery.po +44 -21
  54. data/locale/ko/LC_MESSAGES/foreman_discovery.mo +0 -0
  55. data/locale/ko/foreman_discovery.edit.po +196 -255
  56. data/locale/ko/foreman_discovery.po +44 -21
  57. data/locale/pt_BR/LC_MESSAGES/foreman_discovery.mo +0 -0
  58. data/locale/pt_BR/foreman_discovery.edit.po +205 -256
  59. data/locale/pt_BR/foreman_discovery.po +44 -21
  60. data/locale/ru/LC_MESSAGES/foreman_discovery.mo +0 -0
  61. data/locale/ru/foreman_discovery.edit.po +199 -257
  62. data/locale/ru/foreman_discovery.po +44 -21
  63. data/locale/sv_SE/LC_MESSAGES/foreman_discovery.mo +0 -0
  64. data/locale/sv_SE/foreman_discovery.edit.po +190 -250
  65. data/locale/sv_SE/foreman_discovery.po +38 -15
  66. data/locale/zh_CN/LC_MESSAGES/foreman_discovery.mo +0 -0
  67. data/locale/zh_CN/foreman_discovery.edit.po +207 -256
  68. data/locale/zh_CN/foreman_discovery.po +44 -21
  69. data/locale/zh_TW/LC_MESSAGES/foreman_discovery.mo +0 -0
  70. data/locale/zh_TW/foreman_discovery.edit.po +196 -254
  71. data/locale/zh_TW/foreman_discovery.po +42 -19
  72. data/package.json +39 -0
  73. data/test/facts/only-ipv6.json +205 -0
  74. data/test/facts/skylake-ipv6.json +223 -0
  75. data/test/functional/api/v2/settings_controller_test.rb +2 -2
  76. data/test/functional/discovered_hosts_controller_test.rb +16 -7
  77. data/test/functional/discovery_rules_controller_test.rb +1 -1
  78. data/test/unit/discovered_extensions_test.rb +6 -1
  79. data/test/unit/host_discovered_test.rb +0 -16
  80. data/test/unit/managed_extensions_test.rb +1 -0
  81. data/webpack/index.js +18 -0
  82. data/webpack/src/ForemanDiscovery/DiscoveredHosts/Components/EmptyState/EmptyState.js +28 -0
  83. data/webpack/src/ForemanDiscovery/DiscoveredHosts/Components/EmptyState/index.js +1 -0
  84. data/webpack/src/ForemanDiscovery/DiscoveredHosts/index.js +6 -0
  85. data/webpack/src/reducers.js +7 -0
  86. metadata +42 -28
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 40c64a4f3c756e207293b6e5be67190294b9c4f2ab5054e08edd8d085718556f
4
- data.tar.gz: b22ef9bf418ac18e94170429e7368cb1c6f94b9b0d2290b60341a9415e908b01
3
+ metadata.gz: 633d9a0f20147b982f23bbcc7fe02eb210bdbb060ac2f304b098620981502899
4
+ data.tar.gz: e80520e5eacd123161aa6da427e8185ff0d52dd44d8925319391563ba2634372
5
5
  SHA512:
6
- metadata.gz: d9f9013fa2d04e883da3c0c8c42b5a6e3552093323698359b8e9b70179f0284ccf35d633eac5720cc03fa79678af915b5eda3c7508be775b0836128ef6d738d8
7
- data.tar.gz: 688c8d68c1a87aff1fda0a00eef057daf0c35a06ce007746e568763e868c82ee718d15a51d1124cb9dc1a47498ec94bc7f33e62d986ba7ed23e3eb6babfd140f
6
+ metadata.gz: 36a6ab1d08a10291ba5fa6665649fbaa2b23779305b83826b86a62c1644d9f4545e069c1eba6d13cac27789c50faa2093058de9396d60a06d36f212d995f17c4
7
+ data.tar.gz: 8c2e52c9eee44e6bd3f22098059395e10b4250d193b331b787bb87ffc7f222911510e650645e6d9ff26bd46245680060e7f033fde62bc8bdf0c13d8f39e7aea0
@@ -51,24 +51,30 @@ module Api
51
51
  param :id, :identifier, :required => true
52
52
  param :discovered_host, Hash, :action_aware => true do
53
53
  param :name, String
54
- param :environment_id, String
54
+ param :environment_id, String, :desc => N_("required if host is managed and value is not inherited from host group")
55
55
  param :ip, String, :desc => N_("not required if using a subnet with DHCP proxy")
56
56
  param :mac, String, :desc => N_("not required if it's a virtual machine")
57
- param :architecture_id, :number
58
- param :domain_id, :number
57
+ param :architecture_id, :number, :desc => N_("required if host is managed and value is not inherited from host group")
58
+ param :domain_id, :number, :desc => N_("required if host is managed and value is not inherited from host group")
59
59
  param :puppet_proxy_id, :number
60
60
  param :puppet_class_ids, Array
61
- param :operatingsystem_id, String
62
- param :medium_id, :number
63
- param :ptable_id, :number
64
- param :subnet_id, :number
61
+ param :operatingsystem_id, :number, :desc => N_("required if host is managed and value is not inherited from host group")
62
+ param :medium_id, String, :desc => N_("required if not imaged based provisioning and host is managed and value is not inherited from host group")
63
+ param :ptable_id, :number, :desc => N_("required if host is managed and custom partition has not been defined")
64
+ param :subnet_id, :number, :desc => N_("required if host is managed and value is not inherited from host group")
65
65
  param :sp_subnet_id, :number
66
66
  param :model_id, :number
67
67
  param :hostgroup_id, :number
68
68
  param :owner_id, :number
69
+ param :owner_type, Host::Base::OWNER_TYPES, :desc => N_("Host's owner type")
69
70
  param :puppet_ca_proxy_id, :number
70
71
  param :image_id, :number
71
- param :host_parameters_attributes, Array
72
+ param :host_parameters_attributes, Array, :desc => N_("Host's parameters (array or indexed hash)") do
73
+ param :name, String, :desc => N_("Name of the parameter"), :required => true
74
+ param :value, String, :desc => N_("Parameter value"), :required => true
75
+ param :parameter_type, Parameter::KEY_TYPES, :desc => N_("Type of value")
76
+ param :hidden_value, :bool
77
+ end
72
78
  param :build, :bool
73
79
  param :enabled, :bool
74
80
  param :provision_method, String
@@ -102,9 +108,16 @@ module Api
102
108
  state = true
103
109
  User.as_anonymous_admin do
104
110
  @discovered_host = Host::Discovered.import_host(facts)
105
- Rails.logger.warn 'Discovered facts import unsuccessful, skipping auto provisioning' unless @discovered_host
106
- if Setting['discovery_auto'] && @discovered_host && (rule = find_discovery_rule(@discovered_host))
107
- state = perform_auto_provision(@discovered_host, rule)
111
+ # Host::Based.set_taxonomies sets taxonomies during import from either
112
+ # facts or via Global Foreman setting "default_taxonomy", reset it back so
113
+ # the anonymous admin can see all records. We set taxonomy explicitly via
114
+ # discovery SubnetAndTaxonomy import hook and enforce taxnomy manually
115
+ # in find_discovery_rule method via validate_rule_by_taxonomy.
116
+ Taxonomy.no_taxonomy_scope do
117
+ Rails.logger.warn 'Discovered facts import unsuccessful, skipping auto provisioning' unless @discovered_host
118
+ if Setting['discovery_auto'] && @discovered_host && (rule = find_discovery_rule(@discovered_host))
119
+ state = perform_auto_provision(@discovered_host, rule)
120
+ end
108
121
  end
109
122
  end
110
123
  process_response state
@@ -55,7 +55,7 @@ module Api
55
55
  param_group :discovery_rule, :as => :update
56
56
 
57
57
  def update
58
- process_response @discovery_rule.update_attributes(discovery_rule_params)
58
+ process_response @discovery_rule.update(discovery_rule_params)
59
59
  end
60
60
 
61
61
  api :DELETE, "/discovery_rules/:id/", N_("Delete a rule")
@@ -199,15 +199,17 @@ class DiscoveredHostsController < ::ApplicationController
199
199
 
200
200
  def setup_host_class_variables
201
201
  if @host.hostgroup
202
+ subnet = @host.hostgroup.subnet || @host.subnet
203
+ subnet6 = @host.hostgroup.subnet6 || @host.subnet6
202
204
  @architecture = @host.hostgroup.architecture
203
205
  @operatingsystem = @host.hostgroup.operatingsystem
204
206
  @environment = @host.hostgroup.environment
205
207
  @domain = @host.hostgroup.domain
206
- @subnet = @host.hostgroup.subnet
208
+ @subnet = subnet
209
+ @subnet6 = subnet6
207
210
  @compute_profile = @host.hostgroup.compute_profile
208
211
  @realm = @host.hostgroup.realm
209
- @host.interfaces.first.assign_attributes(subnet: @subnet,
210
- domain: @domain)
212
+ @host.interfaces.first.assign_attributes(subnet: subnet, subnet6: subnet6, domain: @domain)
211
213
  @host.environment = @environment
212
214
  end
213
215
  end
@@ -28,7 +28,7 @@ class DiscoveryRulesController < ApplicationController
28
28
  end
29
29
 
30
30
  def update
31
- if @discovery_rule.update_attributes(discovery_rule_params)
31
+ if @discovery_rule.update(discovery_rule_params)
32
32
  process_success
33
33
  else
34
34
  process_error
@@ -22,7 +22,7 @@ class DiscoveryRule < ApplicationRecord
22
22
  before_validation :enforce_taxonomy
23
23
 
24
24
  belongs_to :hostgroup
25
- has_many :hosts, :dependent => :nullify
25
+ has_many_hosts :dependent => :nullify
26
26
 
27
27
  scoped_search :on => :name, :complete_value => :true
28
28
  scoped_search :on => :priority, :only_explicit => true
@@ -44,9 +44,13 @@ class Host::Discovered < ::Host::Base
44
44
 
45
45
  # Discovery import workflow:
46
46
  # discovered#import_host ->
47
- # discovered#import_facts -> base#import_facts -> base#parse_facts ->
48
- # discovered#populate_fields_from_facts -> base#populate_fields_from_facts -> base#set_interfaces
49
- # discovered#populate_discovery_fields_from_facts
47
+ # ForemanDiscovery::HostFactImporter#import_facts ->
48
+ # ::HostFactImporter#import_facts ->
49
+ # ::HostFactImporter#parse_facts ->
50
+ # discovered#populate_fields_from_facts ->
51
+ # base#populate_fields_from_facts ->
52
+ # base#set_interfaces ->
53
+ # discovered#populate_discovery_fields_from_facts
50
54
  def self.import_host facts
51
55
  raise(::Foreman::Exception.new(N_("Invalid facts, must be a Hash"))) unless facts.is_a?(Hash) || facts.is_a?(ActionController::Parameters)
52
56
 
@@ -92,19 +96,11 @@ class Host::Discovered < ::Host::Base
92
96
 
93
97
  # and save (interfaces are created via puppet parser extension)
94
98
  host.save(:validate => false) if host.new_record?
95
- raise ::Foreman::Exception.new(N_("Facts could not be imported")) unless host.import_facts(facts)
99
+ importer = ForemanDiscovery::HostFactImporter.new(host)
100
+ raise ::Foreman::Exception.new(N_("Facts could not be imported")) unless importer.import_facts(facts)
96
101
  host
97
102
  end
98
103
 
99
- def import_facts(facts)
100
- # Discovered Hosts won't report in via puppet, so we can use that field to
101
- # record the last time it sent facts...
102
- self.last_report = Time.now
103
- # Set the correct facts type for new foreman facts importing code.
104
- facts[:_type] = :foreman_discovery
105
- super(facts)
106
- end
107
-
108
104
  def setup_clone
109
105
  # Nic::Managed needs this method but Discovered hosts shouldn't
110
106
  # be doing orchestration anyway...
@@ -137,33 +133,55 @@ class Host::Discovered < ::Host::Base
137
133
  subnet.present? && subnet.discovery.present?
138
134
  end
139
135
 
140
- def proxy_url
141
- proxied? ? subnet.discovery.url + "/discovery/#{self.ip}" : "https://#{self.ip}:8443"
136
+ def proxy_url(node_ip)
137
+ proxied? ? subnet.discovery.url + "/discovery/#{node_ip}" : "https://#{node_ip}:8443"
142
138
  end
143
139
 
144
140
  def refresh_facts
145
- facts = ::ForemanDiscovery::NodeAPI::Inventory.new(:url => proxy_url).facter
141
+ facts = ::ForemanDiscovery::NodeAPI::Inventory.new(:url => proxy_url(self.ip)).facter
146
142
  self.class.import_host facts
147
- import_facts facts
143
+ ::ForemanDiscovery::HostFactImporter.new(self).import_facts facts
148
144
  rescue => e
149
145
  ::Foreman::Logging.exception("Unable to get facts from proxy", e)
150
- raise ::Foreman::WrappedException.new(e, N_("Could not get facts from proxy %{url}: %{error}"), :url => proxy_url, :error => e)
151
- end
152
-
153
- def reboot
154
- resource = ::ForemanDiscovery::NodeAPI::Power.service(:url => proxy_url)
155
- resource.reboot
156
- rescue => e
157
- ::Foreman::Logging.exception("Unable to reboot #{name}", e)
158
- raise ::Foreman::WrappedException.new(e, N_("Unable to reboot %{name} via %{url}: %{msg}"), :name => name, :url => proxy_url, :msg => e.to_s)
159
- end
160
-
161
- def kexec json
162
- resource = ::ForemanDiscovery::NodeAPI::Power.service(:url => proxy_url)
163
- resource.kexec json
164
- rescue => e
165
- ::Foreman::Logging.exception("Unable to perform kexec on #{name}", e)
166
- raise ::Foreman::WrappedException.new(e, N_("Unable to perform kexec on %{name} via %{url}: %{msg}"), :name => name, :url => proxy_url, :msg => e.to_s)
146
+ raise ::Foreman::WrappedException.new(e, N_("Could not get facts from proxy %{url}: %{error}"), :url => proxy_url(self.ip), :error => e)
147
+ end
148
+
149
+ def reboot(old_ip = nil, new_ip = nil)
150
+ # perform the action against the original lease as well as the new reservation
151
+ ips = [old_ip, new_ip, self.ip].compact.uniq
152
+ logger.debug "Performing reboot calls against #{ips.to_sentence}, facts left #{facts.count}"
153
+ ips.each do |next_ip|
154
+ begin
155
+ node_url = proxy_url(next_ip)
156
+ logger.debug "Performing reboot call against #{node_url}"
157
+ resource = ::ForemanDiscovery::NodeAPI::Power.service(:url => node_url)
158
+ return true if resource.reboot
159
+ rescue => e
160
+ msg = N_("Unable to perform reboot on %{name} (%{url}): %{msg}")
161
+ ::Foreman::Logging.exception(msg % { :name => name, :url => node_url, :msg => e.to_s }, e)
162
+ end
163
+ end
164
+ msg = N_("Unable to perform %{action} on %{ips}")
165
+ raise ::Foreman::Exception.new(msg, action: "reboot", ips: ips.to_sentence)
166
+ end
167
+
168
+ def kexec(json, old_ip = nil, new_ip = nil)
169
+ # perform the action against the original lease as well as the new reservation
170
+ ips = [old_ip, new_ip, self.ip].compact.uniq
171
+ logger.debug "Performing kexec calls against #{ips.to_sentence}, #{facts.count} facts left"
172
+ ips.each do |next_ip|
173
+ begin
174
+ node_url = proxy_url(next_ip)
175
+ logger.debug "Performing kexec call against #{node_url}"
176
+ resource = ::ForemanDiscovery::NodeAPI::Power.service(:url => node_url)
177
+ return true if resource.kexec(json)
178
+ rescue => e
179
+ msg = N_("Unable to perform kexec on %{name} (%{url}): %{msg}")
180
+ ::Foreman::Logging.exception(msg % { :name => name, :url => node_url, :msg => e.to_s }, e)
181
+ end
182
+ end
183
+ msg = N_("Unable to perform %{action} on %{ips}")
184
+ raise ::Foreman::Exception.new(msg, action: "kexec", ips: ips.to_sentence)
167
185
  end
168
186
 
169
187
  def self.model_name
@@ -27,7 +27,7 @@ module Host::ManagedExtensions
27
27
  end
28
28
 
29
29
  def setReboot
30
- old.becomes(Host::Discovered).reboot
30
+ old.becomes(Host::Discovered).reboot(old.ip, ip)
31
31
  # It is too late to report error in the post_queue, we catch them and
32
32
  # continue. If flash is implemented for new hosts (http://projects.theforeman.org/issues/10559)
33
33
  # we can report the error to the user perhaps.
@@ -55,7 +55,7 @@ module Host::ManagedExtensions
55
55
  end
56
56
 
57
57
  def setKexec
58
- old.becomes(Host::Discovered).kexec(render_kexec_template.to_json)
58
+ old.becomes(Host::Discovered).kexec(render_kexec_template.to_json, old.ip, ip)
59
59
  true
60
60
  rescue ::Foreman::Exception => e
61
61
  Foreman::Logging.exception("Unable to kexec", e)
@@ -8,7 +8,9 @@ class Setting::Discovered < ::Setting
8
8
  BLANK_ATTRS << 'discovery_facts_hardware'
9
9
  BLANK_ATTRS << 'discovery_facts_network'
10
10
  BLANK_ATTRS << 'discovery_facts_ipmi'
11
- BLANK_ATTRS << 'discovery_prefix'
11
+
12
+ STRING_PRESENCE_ATTRS = ['discovery_hostname', 'discovery_prefix']
13
+ validates :value, :presence => true, :if => proc { |s| STRING_PRESENCE_ATTRS.include?(s.name) }
12
14
 
13
15
  def self.default_settings
14
16
  [
@@ -1,6 +1,6 @@
1
1
  class ForemanDiscovery::HostConverter
2
2
  # Converts discovered host to managed host without uptading the database.
3
- # Record must be saved explicitly (using save! or update_attributes! or similar).
3
+ # Record must be saved explicitly (using save! or update! or similar).
4
4
  # Creates shallow copy.
5
5
  def self.to_managed(original_host, set_managed = true, set_build = true, added_attributes = {})
6
6
  host = original_host.becomes(::Host::Managed)
@@ -35,12 +35,21 @@ class ForemanDiscovery::HostConverter
35
35
  end
36
36
 
37
37
  def self.unused_ip_for_subnet(subnet, mac, existing_ip)
38
- ipam = subnet.unused_ip(mac)
39
- raise(::Foreman::Exception.new(N_("IPAM must be configured for subnet '%s'"), subnet)) unless ipam.present?
38
+ # prefer existing reservation to prevent conflicts
39
+ existing_rec = subnet&.dhcp_proxy&.record(subnet.network, mac)
40
40
 
41
- # None IPAM returns nil - in that case keep the current address
42
- suggested_ip = ipam.suggest_ip
43
- suggested_ip.nil? ? existing_ip : suggested_ip
41
+ if existing_rec && existing_rec.type == "reservation"
42
+ # reuse the reservation
43
+ existing_rec.ip
44
+ else
45
+ # no reservation - find new unused IP
46
+ ipam = subnet.unused_ip(mac)
47
+ raise(::Foreman::Exception.new(N_("IPAM must be configured for subnet '%s'"), subnet)) unless ipam.present?
48
+
49
+ # None IPAM returns nil - in that case keep the current address
50
+ suggested_ip = ipam.suggest_ip
51
+ suggested_ip.nil? ? existing_ip : suggested_ip
52
+ end
44
53
  end
45
54
 
46
55
  def self.unused_ip_for_host(host, new_subnet = nil, new_subnet6 = nil)
@@ -51,7 +60,6 @@ class ForemanDiscovery::HostConverter
51
60
  interface.subnet6 = new_subnet6 if new_subnet6
52
61
  interface.ip = unused_ip_for_subnet(interface.subnet, interface.mac, interface.ip) if interface.subnet
53
62
  interface.ip6 = unused_ip_for_subnet(interface.subnet6, interface.mac, interface.ip6) if interface.subnet6
54
- interface.save!
55
63
  end
56
64
  end
57
65
 
@@ -0,0 +1,10 @@
1
+ class ForemanDiscovery::HostFactImporter < ::HostFactImporter
2
+ def import_facts(facts)
3
+ # Discovered Hosts won't report in via puppet, so we can use that field to
4
+ # record the last time it sent facts...
5
+ host.last_report = Time.now
6
+ # Set the correct facts type for new foreman facts importing code.
7
+ facts[:_type] = :foreman_discovery
8
+ super(facts)
9
+ end
10
+ end
@@ -35,6 +35,7 @@ module ForemanDiscovery
35
35
  Location.find_by_title(facts["discovery_location"]) ||
36
36
  Location.find_by_title(Setting[:discovery_location]) ||
37
37
  host.subnet.try(:locations).try(:first) ||
38
+ host.subnet6.try(:locations).try(:first) ||
38
39
  Location.first
39
40
  end
40
41
 
@@ -48,6 +49,7 @@ module ForemanDiscovery
48
49
  Organization.find_by_title(facts["discovery_organization"]) ||
49
50
  Organization.find_by_title(Setting[:discovery_organization]) ||
50
51
  host.subnet.try(:organizations).try(:first) ||
52
+ host.subnet6.try(:organizations).try(:first) ||
51
53
  Organization.first
52
54
  end
53
55
  end
@@ -6,6 +6,7 @@ module ForemanDiscovery::NodeAPI
6
6
  @args = args
7
7
  @connect_params = {
8
8
  :headers => { :accept => :json },
9
+ :timeout => 20, # tighter timeout, discovery performs up to two calls per request
9
10
  }
10
11
 
11
12
  if url.match(/^https/i) && Rails.env != "test"
@@ -0,0 +1,3 @@
1
+ object @discovery_rule
2
+
3
+ extends "api/v2/discovery_rules/show"
@@ -17,8 +17,6 @@
17
17
  <% if show_location_tab? %>
18
18
  <%= select_f f, :location_id, Location.my_locations, :id, :to_label, {}, {:size => 'col-md-10'} %>
19
19
  <% end %>
20
-
21
- <div>Changing the Host's Subnet is not possible via Customize Host form, use Create Host or Auto provisioning and set the desired Subnet in the Hostgroup.</div>
22
20
  </div>
23
21
  <div class="modal-footer">
24
22
  <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
@@ -1,10 +1,16 @@
1
+ <% content_for(:javascripts) do %>
2
+ <%= webpacked_plugins_js_for :'foreman_discovery' %>
3
+ <% end %>
4
+ <% content_for(:stylesheets) do %>
5
+ <%= webpacked_plugins_css_for :'foreman_discovery' %>
6
+ <% end %>
7
+
1
8
  <% content_for(:title, _("Discovered Hosts")) %>
2
- <div class="blank-slate-pf">
3
- <div class="blank-slate-pf-icon">
4
- <%= icon_text("gears", "", :kind => "fa") %>
5
- </div>
6
- <h1><%= _('Discovered Hosts') %></h1>
7
- <p><%= _("No discovered hosts found in this context.") %>
8
- <%= _("This page shows discovered bare-metal or virtual nodes waiting to be provisioned.") %></p>
9
- <p><%= link_to _('Learn more about this in the documentation.'), documentation_url("#{ForemanDiscovery::VERSION.scan(/\d+\.\d+/).first}/index.html", {:root_url => 'https://theforeman.org/plugins/foreman_discovery/'})%></p>
10
- </div>
9
+
10
+ <% content_for(:content) do %>
11
+ <%= notifications %>
12
+ <div id="organization-id" data-id="<%= Organization.current.id if Organization.current %>" ></div>
13
+ <div id="user-id" data-id="<%= User.current.id if User.current %>" ></div>
14
+ <%= react_component('DiscoveredHosts',
15
+ docUrl: "https://theforeman.org/plugins/foreman_discovery/#{ForemanDiscovery::VERSION.scan(/\d+\.\d+/).first}/index.html" ) %>
16
+ <% end %>
@@ -18,7 +18,7 @@
18
18
  <td><%= trunc_with_tooltip(rule.search) %></td>
19
19
  <td><%= label_with_link(rule.hostgroup, 26, authorizer) %></td>
20
20
  <td><%= rule.hosts.count %> / <%= rule.max_count %></td>
21
- <td><%= rule.enabled %></td>
21
+ <td><%= checked_icon rule.enabled %></td>
22
22
  <td><%= action_buttons(*permitted_discovery_actions(rule)) %></td>
23
23
  </tr>
24
24
  <% end %>
@@ -12,9 +12,10 @@ environments. The template must generate JSON format with the following items
12
12
  "kernel", "initram", "append" and "extra". The kexec command is composed in
13
13
  the following way:
14
14
 
15
- kexec --force --reset-vga --append=$append --initrd=$initram $extra $kernel
15
+ kexec --force --debug --append=$append --initrd=$initram $extra $kernel
16
16
 
17
17
  Please read kexec(8) man page for more information about semantics.
18
+ Extra options like --reset-vga can be set via "extra" array.
18
19
  -%>
19
20
  <%
20
21
  mac = @host.facts['discovery_bootif']
@@ -28,7 +29,7 @@ Please read kexec(8) man page for more information about semantics.
28
29
  options << @host.facts['append']
29
30
  options << "domain=#{@host.domain}"
30
31
  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'
31
- options << "locale=#{@host.params['lang'] || 'en_US'}"
32
+ options << "locale=#{host_param('lang') || 'en_US'}"
32
33
  options << "inst.stage2=#{@host.operatingsystem.medium_uri(@host)}" if @host.operatingsystem.name.match(/Atomic/i)
33
34
  -%>
34
35
  {
@@ -22,9 +22,10 @@ environments. The template must generate JSON format with the following items
22
22
  "kernel", "initram", "append" and "extra". The kexec command is composed in
23
23
  the following way:
24
24
 
25
- kexec --force --reset-vga --append=$append --initrd=$initram $extra $kernel
25
+ kexec --force --debug --append=$append --initrd=$initram $extra $kernel
26
26
 
27
27
  Please read kexec(8) man page for more information about semantics.
28
+ Extra options like --reset-vga can be set via "extra" array.
28
29
  -%>
29
30
  <%
30
31
  mac = @host.facts['discovery_bootif']
@@ -1,7 +1,7 @@
1
1
  class RemoveOldDiscoveryReaderPermissions < ActiveRecord::Migration[4.2]
2
2
  def up
3
3
  Permission.where("name like '%_discovery_rules' and resource_type is null").each do |permission|
4
- permission.update_attributes(:resource_type => 'DiscoveryRule')
4
+ permission.update(:resource_type => 'DiscoveryRule')
5
5
  end
6
6
  end
7
7
 
@@ -1,7 +1,7 @@
1
1
  class RegenerateRedHatKexec < ActiveRecord::Migration[4.2]
2
2
  def up
3
3
  t = ProvisioningTemplate.find_by_name("Discovery Red Hat kexec")
4
- t.update_attributes(:template => t.template.sub(/rescue ''$/, 'if mac')) if t
4
+ t.update(:template => t.template.sub(/rescue ''$/, 'if mac')) if t
5
5
  end
6
6
 
7
7
  def down