summaryrefslogtreecommitdiff
path: root/lib/puppet
diff options
context:
space:
mode:
authorMathieu Bornoz <mathieu.bornoz@camptocamp.com>2010-11-15 12:20:21 +0100
committerMathieu Bornoz <mathieu.bornoz@camptocamp.com>2010-11-15 12:20:21 +0100
commit1cca7f47a1508dc3c05b4eb33445d2f730de382c (patch)
treefb96b8f0c32916051e81acf215776c0fb8eab105 /lib/puppet
parentffab59de517086a3dc6372e5ec01fc789539030e (diff)
removed couchdb lookup
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/parser/functions/couchdblookup.rb38
1 files changed, 0 insertions, 38 deletions
diff --git a/lib/puppet/parser/functions/couchdblookup.rb b/lib/puppet/parser/functions/couchdblookup.rb
deleted file mode 100644
index 807c138..0000000
--- a/lib/puppet/parser/functions/couchdblookup.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-#
-# A basic function to retrieve data in couchdb
-#
-
-require 'json'
-require 'open-uri'
-
-module Puppet::Parser::Functions
- newfunction(:couchdblookup, :type => :rvalue) do |args|
-
- url = args[0]
- key = args[1]
-
- raise Puppet::ParseError, ("couchdblookup(): wrong number of arguments (#{args.length}; must be == 2)") if args.length != 2
-
- begin
- json = JSON.parse(open(URI.parse(url)).read)
- rescue OpenURI::HTTPError => error
- raise Puppet::ParseError, "couchdblookup(): fetching URL #{url} failed with status #{error.message}"
- end
-
- result = nil
- if json.has_key?("rows") and json['total_rows'] > 0 and json['rows'][0].has_key?(key)
- result = Array.new
- json['rows'].each do |x|
- result.push(x[key])
- end
- else
- if json.has_key?(key)
- result = json[key]
- end
- end
-
- result or raise Puppet::ParseError, "couchdblookup(): key '#{key}' not found in JSON object !"
-
- end
-end
-