foreman_discovery 17.0.3 → 17.0.4
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35fdf9e36a5a8093c7532a47c9e9a8fd2bae879a30eab70fcc286c9b6c1cd256
|
4
|
+
data.tar.gz: 145fc876af62068eebcdc997f6e8ffaa1bc9861ff6aab63ef992396da32277f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87665e788d3aa6db8d3b9b13d5165a23ca4509dfb1bd98cd76bdc46f6779d6aa279aa95a044ac0ae515ac652d88d28c0a792f7c8eeb7b664ec57dabc3aab2023
|
7
|
+
data.tar.gz: 5cad4226da69dd1ed80fcfa89ff20c4a590373c00753f1a390ceb0a324401b8c96f52aabece9f86ed70c86be542e6afd73e5dcbdd70367f1f2ddcfdd5cd7f924
|
@@ -133,26 +133,39 @@ class Host::Discovered < ::Host::Base
|
|
133
133
|
subnet.present? && subnet.discovery.present?
|
134
134
|
end
|
135
135
|
|
136
|
+
def ip4or6
|
137
|
+
if Setting[:discovery_prefer_ipv6]
|
138
|
+
IPAddr.new(self.ip6 || self.ip)
|
139
|
+
else
|
140
|
+
IPAddr.new(self.ip || self.ip6)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
136
144
|
def proxy_url(node_ip)
|
137
|
-
|
145
|
+
wrapped_ip = node_ip.ipv6? ? "[#{node_ip}]" : node_ip
|
146
|
+
proxied? ? subnet.discovery.url + "/discovery/#{node_ip}" : "https://#{wrapped_ip}:8443"
|
138
147
|
end
|
139
148
|
|
140
149
|
def refresh_facts
|
141
|
-
facts = ::ForemanDiscovery::NodeAPI::Inventory.new(:url => proxy_url(
|
150
|
+
facts = ::ForemanDiscovery::NodeAPI::Inventory.new(:url => proxy_url(ip4or6)).facter
|
142
151
|
self.class.import_host facts
|
143
152
|
::ForemanDiscovery::HostFactImporter.new(self).import_facts facts
|
144
153
|
rescue => e
|
145
154
|
::Foreman::Logging.exception("Unable to get facts from proxy", e)
|
146
|
-
raise ::Foreman::WrappedException.new(e, N_("Could not get facts from proxy %{url}: %{error}"), :url => proxy_url(
|
155
|
+
raise ::Foreman::WrappedException.new(e, N_("Could not get facts from proxy %{url}: %{error}"), :url => proxy_url(ip4or6), :error => e)
|
147
156
|
end
|
148
157
|
|
149
|
-
def reboot(old_ip = nil, new_ip = nil)
|
158
|
+
def reboot(old_ip = nil, new_ip = nil, old_ip6 = nil, new_ip6 = nil)
|
150
159
|
# perform the action against the original lease as well as the new reservation
|
151
|
-
|
160
|
+
if Setting[:discovery_prefer_ipv6]
|
161
|
+
ips = [old_ip6, new_ip6, self.ip6, old_ip, new_ip, self.ip].compact.uniq
|
162
|
+
else
|
163
|
+
ips = [old_ip, new_ip, self.ip, old_ip6, new_ip6, self.ip6].compact.uniq
|
164
|
+
end
|
152
165
|
logger.debug "Performing reboot calls against #{ips.to_sentence}, facts left #{facts.count}"
|
153
166
|
ips.each do |next_ip|
|
154
167
|
begin
|
155
|
-
node_url = proxy_url(next_ip)
|
168
|
+
node_url = proxy_url(IPAddr.new(next_ip))
|
156
169
|
logger.debug "Performing reboot call against #{node_url}"
|
157
170
|
resource = ::ForemanDiscovery::NodeAPI::Power.service(:url => node_url)
|
158
171
|
return true if resource.reboot
|
@@ -165,13 +178,17 @@ class Host::Discovered < ::Host::Base
|
|
165
178
|
raise ::Foreman::Exception.new(msg, action: "reboot", ips: ips.to_sentence)
|
166
179
|
end
|
167
180
|
|
168
|
-
def kexec(json, old_ip = nil, new_ip = nil)
|
181
|
+
def kexec(json, old_ip = nil, new_ip = nil, old_ip6 = nil, new_ip6 = nil)
|
169
182
|
# perform the action against the original lease as well as the new reservation
|
170
|
-
|
183
|
+
if Setting[:discovery_prefer_ipv6]
|
184
|
+
ips = [old_ip6, new_ip6, self.ip6, old_ip, new_ip, self.ip].compact.uniq
|
185
|
+
else
|
186
|
+
ips = [old_ip, new_ip, self.ip, old_ip6, new_ip6, self.ip6].compact.uniq
|
187
|
+
end
|
171
188
|
logger.debug "Performing kexec calls against #{ips.to_sentence}, #{facts.count} facts left"
|
172
189
|
ips.each do |next_ip|
|
173
190
|
begin
|
174
|
-
node_url = proxy_url(next_ip)
|
191
|
+
node_url = proxy_url(IPAddr.new(next_ip))
|
175
192
|
logger.debug "Performing kexec call against #{node_url}"
|
176
193
|
resource = ::ForemanDiscovery::NodeAPI::Power.service(:url => node_url)
|
177
194
|
return true if resource.kexec(json)
|
@@ -27,7 +27,7 @@ module Host::ManagedExtensions
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def setReboot
|
30
|
-
old.becomes(Host::Discovered).reboot(old.ip, ip)
|
30
|
+
old.becomes(Host::Discovered).reboot(old.ip, ip, old.ip6, ip6)
|
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, old.ip, ip)
|
58
|
+
old.becomes(Host::Discovered).kexec(render_kexec_template.to_json, old.ip, ip, old.ip6, ip6)
|
59
59
|
true
|
60
60
|
rescue ::Foreman::Exception => e
|
61
61
|
Foreman::Logging.exception("Unable to kexec", e)
|
@@ -37,6 +37,7 @@ class Setting::Discovered < ::Setting
|
|
37
37
|
self.set('discovery_always_rebuild_dns', N_("Force DNS entries creation when provisioning discovered host"), true, N_("Force DNS")),
|
38
38
|
self.set('discovery_error_on_existing', N_("Do not allow to discover existing managed host matching MAC of a provisioning NIC (errors out early)"), false, N_("Error on existing NIC")),
|
39
39
|
self.set('discovery_naming', N_("Discovery hostname naming pattern"), 'Fact', N_("Type of name generator"), nil, {:collection => Proc.new {::Host::Discovered::NAMING_PATTERNS} }),
|
40
|
+
self.set('discovery_prefer_ipv6', N_("Prefer IPv6 to IPv4 when calling discovered nodes"), false, N_("Prefer IPv6")),
|
40
41
|
]
|
41
42
|
end
|
42
43
|
|
@@ -19,6 +19,7 @@ class ManagedExtensionsTest < ActiveSupport::TestCase
|
|
19
19
|
@host = StubHost.new
|
20
20
|
@host.type = "Host::Discovered"
|
21
21
|
@host.stubs(:ip).returns("192.168.1.1")
|
22
|
+
@host.stubs(:ip6).returns(nil)
|
22
23
|
@host.stubs(:old).returns(@host)
|
23
24
|
@facts = {}
|
24
25
|
@host.stubs(:facts).returns(@facts)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_discovery
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 17.0.
|
4
|
+
version: 17.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aditi Puntambekar
|
@@ -73,7 +73,7 @@ authors:
|
|
73
73
|
autorequire:
|
74
74
|
bindir: bin
|
75
75
|
cert_chain: []
|
76
|
-
date: 2021-
|
76
|
+
date: 2021-10-05 00:00:00.000000000 Z
|
77
77
|
dependencies: []
|
78
78
|
description: MaaS Discovery Plugin engine for Foreman
|
79
79
|
email: gsutclif@redhat.com
|
@@ -366,8 +366,8 @@ test_files:
|
|
366
366
|
- test/unit/discovered_extensions_test.rb
|
367
367
|
- test/unit/discovery_attribute_set_test.rb
|
368
368
|
- test/unit/fact_parser_test.rb
|
369
|
-
- test/unit/managed_extensions_test.rb
|
370
369
|
- test/unit/setting_discovered_test.rb
|
370
|
+
- test/unit/managed_extensions_test.rb
|
371
371
|
- test/unit/host_discovered_test.rb
|
372
372
|
- test/models/setting_test.rb
|
373
373
|
- test/test_helper_discovery.rb
|