summaryrefslogtreecommitdiffstats
path: root/lib/puppet/network
diff options
context:
space:
mode:
authorMatt Robinson <matt@puppetlabs.com>2010-10-28 14:49:37 -0700
committerMatt Robinson <matt@puppetlabs.com>2010-10-28 15:09:15 -0700
commit45a9a97285d99db524d5330c236352b29e5884ed (patch)
tree65d227ec46a7259a2a06221889cb48d1698dff3a /lib/puppet/network
parente559b48d51c53c4a345353de1e196634c7430195 (diff)
downloadpuppet-45a9a97285d99db524d5330c236352b29e5884ed.tar.gz
puppet-45a9a97285d99db524d5330c236352b29e5884ed.tar.xz
puppet-45a9a97285d99db524d5330c236352b29e5884ed.zip
(#5132) Provide a query REST interface for inventory
This REST interface returns a list of nodes that match a fact query. Fact queries can use (in)equality testing as a string comparison, and >, <, >=, <= numerical comparisons. Multiple tests can be done as AND comparisons, not OR. The fact queries need to be prefixed by facts, and the comparisons other than equality are specified with a .comparison_type after the fact name. This will be better explained in the REST documentation on the website. Searches that don't match anything now return empty array instead of a 404 error.
Diffstat (limited to 'lib/puppet/network')
-rw-r--r--lib/puppet/network/http/api/v1.rb3
-rw-r--r--lib/puppet/network/http/handler.rb2
2 files changed, 2 insertions, 3 deletions
diff --git a/lib/puppet/network/http/api/v1.rb b/lib/puppet/network/http/api/v1.rb
index dd4612a14..2a4736365 100644
--- a/lib/puppet/network/http/api/v1.rb
+++ b/lib/puppet/network/http/api/v1.rb
@@ -57,9 +57,8 @@ module Puppet::Network::HTTP::API::V1
# fix to not need this, and our goal is to move away from the complication
# that leads to the fix being too long.
return :singular if indirection == "facts"
-
- # "status" really is singular
return :singular if indirection == "status"
+ return :plural if indirection == "inventory"
result = (indirection =~ /s$/) ? :plural : :singular
diff --git a/lib/puppet/network/http/handler.rb b/lib/puppet/network/http/handler.rb
index 61ae2d2fc..e5aa1c56f 100644
--- a/lib/puppet/network/http/handler.rb
+++ b/lib/puppet/network/http/handler.rb
@@ -116,7 +116,7 @@ module Puppet::Network::HTTP::Handler
def do_search(indirection_request, request, response)
result = indirection_request.model.search(indirection_request.key, indirection_request.to_hash)
- if result.nil? or (result.is_a?(Array) and result.empty?)
+ if result.nil?
return do_exception(response, "Could not find instances in #{indirection_request.indirection_name} with '#{indirection_request.key}'", 404)
end