foreman_discovery 16.0.0 → 16.0.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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: daf02841d730bd8c0bce174762bd59b42f323d1a971b40dc72a6bd5a32d350fd
|
4
|
+
data.tar.gz: 4c89487acc8feab8fdba5d76be4d8f54dc78970a0cff7b2b85945d6824890c9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 662c55ac2db702681b11bddcffa199048c6c62e2cc8d2b81a374426a45f8a6659fadf1a56642bc3667e534c534983acf970c5e7e1e7ec9b804d7b97a3ce58692
|
7
|
+
data.tar.gz: 2b185dcda6bb7eaa610c58eed077f753e0e5f4fb537276adb4cd48b8d339a154931d6cbdec64ec1416e91137f97fb9479c5a05b0b89d39f1d2469b3a5bc6c5ac
|
@@ -137,12 +137,12 @@ class Host::Discovered < ::Host::Base
|
|
137
137
|
subnet.present? && subnet.discovery.present?
|
138
138
|
end
|
139
139
|
|
140
|
-
def proxy_url
|
141
|
-
proxied? ? subnet.discovery.url + "/discovery/#{
|
140
|
+
def proxy_url(node_ip)
|
141
|
+
proxied? ? subnet.discovery.url + "/discovery/#{node_ip}" : "https://#{node_ip}:8443"
|
142
142
|
end
|
143
143
|
|
144
144
|
def refresh_facts
|
145
|
-
facts = ::ForemanDiscovery::NodeAPI::Inventory.new(:url => proxy_url).facter
|
145
|
+
facts = ::ForemanDiscovery::NodeAPI::Inventory.new(:url => proxy_url(self.ip)).facter
|
146
146
|
self.class.import_host facts
|
147
147
|
import_facts facts
|
148
148
|
rescue => e
|
@@ -150,20 +150,42 @@ class Host::Discovered < ::Host::Base
|
|
150
150
|
raise ::Foreman::WrappedException.new(e, N_("Could not get facts from proxy %{url}: %{error}"), :url => proxy_url, :error => e)
|
151
151
|
end
|
152
152
|
|
153
|
-
def reboot
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
153
|
+
def reboot(node_ip = nil)
|
154
|
+
# perform the action against the original lease as well as the new reservation
|
155
|
+
[node_ip || facts["discovery_bootip"] || facts["ipaddress"], self.ip].compact.each do |next_ip|
|
156
|
+
begin
|
157
|
+
node_url = proxy_url(next_ip)
|
158
|
+
logger.debug "Performing reboot call against #{node_url}"
|
159
|
+
resource = ::ForemanDiscovery::NodeAPI::Power.service(:url => node_url)
|
160
|
+
return true if resource.reboot
|
161
|
+
rescue => e
|
162
|
+
msg = N_("Unable to perform reboot on %{name} (%{url}): %{msg}")
|
163
|
+
::Foreman::Logging.exception(msg % { :name => name, :url => node_url, :msg => e.to_s }, e)
|
164
|
+
if next_ip == self.ip
|
165
|
+
raise ::Foreman::WrappedException.new(e, msg, :name => name, :url => node_url, :msg => e.to_s)
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
false
|
159
170
|
end
|
160
171
|
|
161
|
-
def kexec
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
172
|
+
def kexec(json, node_ip = nil)
|
173
|
+
# perform the action against the original lease as well as the new reservation
|
174
|
+
[node_ip || facts["discovery_bootip"] || facts["ipaddress"], self.ip].compact.each do |next_ip|
|
175
|
+
begin
|
176
|
+
node_url = proxy_url(next_ip)
|
177
|
+
logger.debug "Performing kexec call against #{node_url}"
|
178
|
+
resource = ::ForemanDiscovery::NodeAPI::Power.service(:url => node_url)
|
179
|
+
return true if resource.kexec(json)
|
180
|
+
rescue => e
|
181
|
+
msg = N_("Unable to perform kexec on %{name} (%{url}): %{msg}")
|
182
|
+
::Foreman::Logging.exception(msg % { :name => name, :url => node_url, :msg => e.to_s }, e)
|
183
|
+
if next_ip == self.ip
|
184
|
+
raise ::Foreman::WrappedException.new(e, msg, :name => name, :url => node_url, :msg => e.to_s)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
false
|
167
189
|
end
|
168
190
|
|
169
191
|
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(facts["discovery_bootip"] || facts["ipaddress"])
|
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.
|
@@ -183,7 +183,7 @@ class DiscoveredHostsControllerTest < ActionController::TestCase
|
|
183
183
|
def test_reboot_failure
|
184
184
|
@request.env["HTTP_REFERER"] = discovered_hosts_url
|
185
185
|
host = discover_host_from_facts(@facts)
|
186
|
-
::ForemanDiscovery::NodeAPI::PowerService.any_instance.expects(:reboot).returns(false)
|
186
|
+
::ForemanDiscovery::NodeAPI::PowerService.any_instance.expects(:reboot).twice.returns(false)
|
187
187
|
post :reboot, params: { :id => host.id }, session: set_session_user_default_manager
|
188
188
|
assert_redirected_to discovered_hosts_url
|
189
189
|
assert_equal "Failed to reboot host #{host.name}", flash[:error]
|
@@ -195,7 +195,7 @@ class DiscoveredHostsControllerTest < ActionController::TestCase
|
|
195
195
|
::ForemanDiscovery::NodeAPI::PowerService.any_instance.expects(:reboot).raises("request failed")
|
196
196
|
post :reboot, params: { :id => host.id }, session: set_session_user_default_manager
|
197
197
|
assert_redirected_to discovered_hosts_url
|
198
|
-
assert_match(/ERF50-
|
198
|
+
assert_match(/ERF50-9494/, flash[:error])
|
199
199
|
end
|
200
200
|
|
201
201
|
def test_auto_provision_success
|
@@ -271,7 +271,7 @@ class DiscoveredHostsControllerTest < ActionController::TestCase
|
|
271
271
|
def test_multiple_reboot_failure
|
272
272
|
@request.env["HTTP_REFERER"] = discovered_hosts_url
|
273
273
|
host = discover_host_from_facts(@facts)
|
274
|
-
::ForemanDiscovery::NodeAPI::PowerService.any_instance.expects(:reboot).returns(false)
|
274
|
+
::ForemanDiscovery::NodeAPI::PowerService.any_instance.expects(:reboot).twice.returns(false)
|
275
275
|
post :submit_multiple_reboot, params: {:host_ids => host.id}, session: set_session_user(User.current)
|
276
276
|
assert_redirected_to discovered_hosts_url
|
277
277
|
assert_equal "Errors during reboot: #{host.name}: failed to reboot", flash[:error]
|
@@ -284,7 +284,7 @@ class DiscoveredHostsControllerTest < ActionController::TestCase
|
|
284
284
|
::ForemanDiscovery::NodeAPI::PowerService.any_instance.expects(:reboot).raises("request failed")
|
285
285
|
post :submit_multiple_reboot, params: {:host_ids => host.id}, session: set_session_user(User.current)
|
286
286
|
assert_redirected_to discovered_hosts_url
|
287
|
-
assert_match(/ERF50-
|
287
|
+
assert_match(/ERF50-9494/, flash[:error])
|
288
288
|
assert_nil flash[:success]
|
289
289
|
end
|
290
290
|
|
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: 16.0.
|
4
|
+
version: 16.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aditi Puntambekar
|
@@ -69,7 +69,7 @@ authors:
|
|
69
69
|
autorequire:
|
70
70
|
bindir: bin
|
71
71
|
cert_chain: []
|
72
|
-
date: 2019-11-
|
72
|
+
date: 2019-11-26 00:00:00.000000000 Z
|
73
73
|
dependencies: []
|
74
74
|
description: MaaS Discovery Plugin engine for Foreman
|
75
75
|
email: gsutclif@redhat.com
|