25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/puppetclassify/classification.rb', line 25
def explain(name, facts={})
unless facts.class == Hash
STDERR.puts "Facts should be a hash, not a #{facts.class}"
return false
end
class_res = @puppet_https.post("#{@nc_api_url}/v1/classified/nodes/#{name}/explanation", facts.to_json)
unless class_res.code.to_i == 200
STDERR.puts "An error occured retreiving the classification explanation of node #{name}: HTTP #{class_res.code} #{class_res.message}"
STDERR.puts class_res.body
else
JSON.parse(class_res.body)
end
end
|