Skip to content

Commit

Permalink
find_nodes_puppetdb: get port from Util, tune ssl cx
Browse files Browse the repository at this point in the history
  • Loading branch information
raphink authored and Zack Smith committed Jun 2, 2015
1 parent 7c0fb4b commit c567a48
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/puppet/catalog-diff/searchfacts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,13 @@ def find_nodes_rest(server)
end

def find_nodes_puppetdb()
connection = Puppet::Network::HttpPool.http_instance(Puppet::Util::Puppetdb.server,'8081')
base_query = ["and", ["=", ["node","active"], true]]
query = base_query.concat(@facts.map { |k, v| ["=", ["fact", k], v] })
json_query = URI.escape(query.to_json)
require 'puppet/util/puppetdb'
port = Puppet::Util::Puppetdb.port
use_ssl = port != 8080
connection = Puppet::Network::HttpPool.http_instance(Puppet::Util::Puppetdb.server,port,use_ssl)
fact_query = @args.split("=")
#json_query = URI.escape(["=", ["fact", fact_query[0]], fact_query[1]].to_json)
json_query = URI.escape(["=", ["node","active"], true].to_json)
unless filtered = PSON.load(connection.request_get("/v2/nodes/?query=#{json_query}", {"Accept" => 'application/json'}).body)
raise "Error parsing json output of puppet search"
end
Expand Down

0 comments on commit c567a48

Please sign in to comment.