Bug #1285 ยป external_node.rb.erb.patch
external_node.rb.erb 2011-11-01 09:45:31.000000000 -0400 | ||
---|---|---|
end
|
||
require 'net/http'
|
||
require 'net/https' if url =~ /^https/
|
||
if url =~ /^https/
|
||
require 'net/https'
|
||
def ssl
|
||
true
|
||
end
|
||
end
|
||
require 'fileutils'
|
||
require 'timeout'
|
||
... | ... | |
if last_fact > last_run
|
||
fact = File.read(filename)
|
||
begin
|
||
Net::HTTP.post_form(URI.parse("#{url}/fact_values/create?format=yml"), {'facts'=> fact})
|
||
uri = URI.parse("#{url}/fact_values/create?format=yml")
|
||
http = Net::HTTP.new(uri.host, uri.port)
|
||
http.use_ssl = true if ssl
|
||
req = Net::HTTP::Post.new(uri.path)
|
||
req.set_form_data({'facts'=> fact})
|
||
http.start { |http| http.request(req) }
|
||
rescue => e
|
||
raise "Could not send facts to Foreman: #{e}"
|
||
end
|
||
... | ... | |
foreman_url = "#{url}/node/#{certname}?format=yml"
|
||
uri = URI.parse(foreman_url)
|
||
req = Net::HTTP::Get.new(foreman_url)
|
||
res = Net::HTTP.start(uri.host, uri.port) { |http| http.request(req) }
|
||
http = Net::HTTP.new(uri.host, uri.port)
|
||
http.use_ssl = true if ssl
|
||
res = http.start { |http| http.request(req) }
|
||
raise "Error retrieving node #{certname}: #{res.class}" unless res.code == "200"
|
||
res.body
|
||
end
|