@@ -73,11 +73,12 @@ def find_nodes_rest(server)
7373
7474 def find_nodes_puppetdb ( env )
7575 require 'puppet/util/puppetdb'
76- port = Puppet ::Util ::Puppetdb . port
76+ server_url = Puppet ::Util ::Puppetdb . config . server_urls [ 0 ]
77+ port = server_url . port
7778 use_ssl = port != 8080
78- connection = Puppet ::Network ::HttpPool . http_instance ( Puppet :: Util :: Puppetdb . server , port , use_ssl )
79+ connection = Puppet ::Network ::HttpPool . http_instance ( server_url . host , port , use_ssl )
7980 base_query = [ "and" , [ "=" , [ "node" , "active" ] , true ] ]
80- base_query . concat ( [ [ "=" , "catalog-environment " , env ] ] ) if env
81+ base_query . concat ( [ [ "=" , "catalog_environment " , env ] ] ) if env
8182 real_facts = @facts . select { |k , v | !v . nil? }
8283 query = base_query . concat ( real_facts . map { |k , v | [ "=" , [ "fact" , k ] , v ] } )
8384 classes = Hash [ @facts . select { |k , v | v . nil? } ] . keys
@@ -97,7 +98,7 @@ def find_nodes_puppetdb(env)
9798 )
9899 end
99100 json_query = URI . escape ( query . to_json )
100- unless filtered = PSON . load ( connection . request_get ( "/v4/nodes/?query=#{ json_query } " , { "Accept" => 'application/json' } ) . body )
101+ unless filtered = PSON . load ( connection . request_get ( "/pdb/query/ v4/nodes/?query=#{ json_query } " , { "Accept" => 'application/json' } ) . body )
101102 raise "Error parsing json output of puppet search"
102103 end
103104 names = filtered . map { |node | node [ 'certname' ] }
0 commit comments